babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050
  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/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  466. * @param convertedColor defines the Color3 object where to store the linear space version
  467. * @returns the unmodified Color3
  468. */
  469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  470. /**
  471. * Computes a new Color3 converted from the current one to gamma space
  472. * @returns a new Color3 object
  473. */
  474. toGammaSpace(): Color3;
  475. /**
  476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  477. * @param convertedColor defines the Color3 object where to store the gamma space version
  478. * @returns the unmodified Color3
  479. */
  480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  481. private static _BlackReadOnly;
  482. /**
  483. * Creates a new Color3 from the string containing valid hexadecimal values
  484. * @param hex defines a string containing valid hexadecimal values
  485. * @returns a new Color3 object
  486. */
  487. static FromHexString(hex: string): Color3;
  488. /**
  489. * Creates a new Color3 from the starting index of the given array
  490. * @param array defines the source array
  491. * @param offset defines an offset in the source array
  492. * @returns a new Color3 object
  493. */
  494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  495. /**
  496. * Creates a new Color3 from integer values (< 256)
  497. * @param r defines the red component to read from (value between 0 and 255)
  498. * @param g defines the green component to read from (value between 0 and 255)
  499. * @param b defines the blue component to read from (value between 0 and 255)
  500. * @returns a new Color3 object
  501. */
  502. static FromInts(r: number, g: number, b: number): Color3;
  503. /**
  504. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  505. * @param start defines the start Color3 value
  506. * @param end defines the end Color3 value
  507. * @param amount defines the gradient value between start and end
  508. * @returns a new Color3 object
  509. */
  510. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  511. /**
  512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  513. * @param left defines the start value
  514. * @param right defines the end value
  515. * @param amount defines the gradient factor
  516. * @param result defines the Color3 object where to store the result
  517. */
  518. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  519. /**
  520. * Returns a Color3 value containing a red color
  521. * @returns a new Color3 object
  522. */
  523. static Red(): Color3;
  524. /**
  525. * Returns a Color3 value containing a green color
  526. * @returns a new Color3 object
  527. */
  528. static Green(): Color3;
  529. /**
  530. * Returns a Color3 value containing a blue color
  531. * @returns a new Color3 object
  532. */
  533. static Blue(): Color3;
  534. /**
  535. * Returns a Color3 value containing a black color
  536. * @returns a new Color3 object
  537. */
  538. static Black(): Color3;
  539. /**
  540. * Gets a Color3 value containing a black color that must not be updated
  541. */
  542. static readonly BlackReadOnly: DeepImmutable<Color3>;
  543. /**
  544. * Returns a Color3 value containing a white color
  545. * @returns a new Color3 object
  546. */
  547. static White(): Color3;
  548. /**
  549. * Returns a Color3 value containing a purple color
  550. * @returns a new Color3 object
  551. */
  552. static Purple(): Color3;
  553. /**
  554. * Returns a Color3 value containing a magenta color
  555. * @returns a new Color3 object
  556. */
  557. static Magenta(): Color3;
  558. /**
  559. * Returns a Color3 value containing a yellow color
  560. * @returns a new Color3 object
  561. */
  562. static Yellow(): Color3;
  563. /**
  564. * Returns a Color3 value containing a gray color
  565. * @returns a new Color3 object
  566. */
  567. static Gray(): Color3;
  568. /**
  569. * Returns a Color3 value containing a teal color
  570. * @returns a new Color3 object
  571. */
  572. static Teal(): Color3;
  573. /**
  574. * Returns a Color3 value containing a random color
  575. * @returns a new Color3 object
  576. */
  577. static Random(): Color3;
  578. }
  579. /**
  580. * Class used to hold a RBGA color
  581. */
  582. export class Color4 {
  583. /**
  584. * Defines the red component (between 0 and 1, default is 0)
  585. */
  586. r: number;
  587. /**
  588. * Defines the green component (between 0 and 1, default is 0)
  589. */
  590. g: number;
  591. /**
  592. * Defines the blue component (between 0 and 1, default is 0)
  593. */
  594. b: number;
  595. /**
  596. * Defines the alpha component (between 0 and 1, default is 1)
  597. */
  598. a: number;
  599. /**
  600. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  601. * @param r defines the red component (between 0 and 1, default is 0)
  602. * @param g defines the green component (between 0 and 1, default is 0)
  603. * @param b defines the blue component (between 0 and 1, default is 0)
  604. * @param a defines the alpha component (between 0 and 1, default is 1)
  605. */
  606. constructor(
  607. /**
  608. * Defines the red component (between 0 and 1, default is 0)
  609. */
  610. r?: number,
  611. /**
  612. * Defines the green component (between 0 and 1, default is 0)
  613. */
  614. g?: number,
  615. /**
  616. * Defines the blue component (between 0 and 1, default is 0)
  617. */
  618. b?: number,
  619. /**
  620. * Defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. a?: number);
  623. /**
  624. * Adds in place the given Color4 values to the current Color4 object
  625. * @param right defines the second operand
  626. * @returns the current updated Color4 object
  627. */
  628. addInPlace(right: DeepImmutable<Color4>): Color4;
  629. /**
  630. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  631. * @returns the new array
  632. */
  633. asArray(): number[];
  634. /**
  635. * Stores from the starting index in the given array the Color4 successive values
  636. * @param array defines the array where to store the r,g,b components
  637. * @param index defines an optional index in the target array to define where to start storing values
  638. * @returns the current Color4 object
  639. */
  640. toArray(array: number[], index?: number): Color4;
  641. /**
  642. * Determines equality between Color4 objects
  643. * @param otherColor defines the second operand
  644. * @returns true if the rgba values are equal to the given ones
  645. */
  646. equals(otherColor: DeepImmutable<Color4>): boolean;
  647. /**
  648. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  649. * @param right defines the second operand
  650. * @returns a new Color4 object
  651. */
  652. add(right: DeepImmutable<Color4>): Color4;
  653. /**
  654. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  655. * @param right defines the second operand
  656. * @returns a new Color4 object
  657. */
  658. subtract(right: DeepImmutable<Color4>): Color4;
  659. /**
  660. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  661. * @param right defines the second operand
  662. * @param result defines the Color4 object where to store the result
  663. * @returns the current Color4 object
  664. */
  665. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  666. /**
  667. * Creates a new Color4 with the current Color4 values multiplied by scale
  668. * @param scale defines the scaling factor to apply
  669. * @returns a new Color4 object
  670. */
  671. scale(scale: number): Color4;
  672. /**
  673. * Multiplies the current Color4 values by scale and stores the result in "result"
  674. * @param scale defines the scaling factor to apply
  675. * @param result defines the Color4 object where to store the result
  676. * @returns the current unmodified Color4
  677. */
  678. scaleToRef(scale: number, result: Color4): Color4;
  679. /**
  680. * Scale the current Color4 values by a factor and add the result to a given Color4
  681. * @param scale defines the scale factor
  682. * @param result defines the Color4 object where to store the result
  683. * @returns the unmodified current Color4
  684. */
  685. scaleAndAddToRef(scale: number, result: Color4): Color4;
  686. /**
  687. * Clamps the rgb values by the min and max values and stores the result into "result"
  688. * @param min defines minimum clamping value (default is 0)
  689. * @param max defines maximum clamping value (default is 1)
  690. * @param result defines color to store the result into.
  691. * @returns the cuurent Color4
  692. */
  693. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  694. /**
  695. * Multipy an Color4 value by another and return a new Color4 object
  696. * @param color defines the Color4 value to multiply by
  697. * @returns a new Color4 object
  698. */
  699. multiply(color: Color4): Color4;
  700. /**
  701. * Multipy a Color4 value by another and push the result in a reference value
  702. * @param color defines the Color4 value to multiply by
  703. * @param result defines the Color4 to fill the result in
  704. * @returns the result Color4
  705. */
  706. multiplyToRef(color: Color4, result: Color4): Color4;
  707. /**
  708. * Creates a string with the Color4 current values
  709. * @returns the string representation of the Color4 object
  710. */
  711. toString(): string;
  712. /**
  713. * Returns the string "Color4"
  714. * @returns "Color4"
  715. */
  716. getClassName(): string;
  717. /**
  718. * Compute the Color4 hash code
  719. * @returns an unique number that can be used to hash Color4 objects
  720. */
  721. getHashCode(): number;
  722. /**
  723. * Creates a new Color4 copied from the current one
  724. * @returns a new Color4 object
  725. */
  726. clone(): Color4;
  727. /**
  728. * Copies the given Color4 values into the current one
  729. * @param source defines the source Color4 object
  730. * @returns the current updated Color4 object
  731. */
  732. copyFrom(source: Color4): Color4;
  733. /**
  734. * Copies the given float values into the current one
  735. * @param r defines the red component to read from
  736. * @param g defines the green component to read from
  737. * @param b defines the blue component to read from
  738. * @param a defines the alpha component to read from
  739. * @returns the current updated Color4 object
  740. */
  741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  742. /**
  743. * Copies the given float values into the current one
  744. * @param r defines the red component to read from
  745. * @param g defines the green component to read from
  746. * @param b defines the blue component to read from
  747. * @param a defines the alpha component to read from
  748. * @returns the current updated Color4 object
  749. */
  750. set(r: number, g: number, b: number, a: number): Color4;
  751. /**
  752. * Compute the Color4 hexadecimal code as a string
  753. * @returns a string containing the hexadecimal representation of the Color4 object
  754. */
  755. toHexString(): string;
  756. /**
  757. * Computes a new Color4 converted from the current one to linear space
  758. * @returns a new Color4 object
  759. */
  760. toLinearSpace(): Color4;
  761. /**
  762. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  763. * @param convertedColor defines the Color4 object where to store the linear space version
  764. * @returns the unmodified Color4
  765. */
  766. toLinearSpaceToRef(convertedColor: Color4): Color4;
  767. /**
  768. * Computes a new Color4 converted from the current one to gamma space
  769. * @returns a new Color4 object
  770. */
  771. toGammaSpace(): Color4;
  772. /**
  773. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  774. * @param convertedColor defines the Color4 object where to store the gamma space version
  775. * @returns the unmodified Color4
  776. */
  777. toGammaSpaceToRef(convertedColor: Color4): Color4;
  778. /**
  779. * Creates a new Color4 from the string containing valid hexadecimal values
  780. * @param hex defines a string containing valid hexadecimal values
  781. * @returns a new Color4 object
  782. */
  783. static FromHexString(hex: string): Color4;
  784. /**
  785. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  786. * @param left defines the start value
  787. * @param right defines the end value
  788. * @param amount defines the gradient factor
  789. * @returns a new Color4 object
  790. */
  791. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  792. /**
  793. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  794. * @param left defines the start value
  795. * @param right defines the end value
  796. * @param amount defines the gradient factor
  797. * @param result defines the Color4 object where to store data
  798. */
  799. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  800. /**
  801. * Creates a new Color4 from a Color3 and an alpha value
  802. * @param color3 defines the source Color3 to read from
  803. * @param alpha defines the alpha component (1.0 by default)
  804. * @returns a new Color4 object
  805. */
  806. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  807. /**
  808. * Creates a new Color4 from the starting index element of the given array
  809. * @param array defines the source array to read from
  810. * @param offset defines the offset in the source array
  811. * @returns a new Color4 object
  812. */
  813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  814. /**
  815. * Creates a new Color3 from integer values (< 256)
  816. * @param r defines the red component to read from (value between 0 and 255)
  817. * @param g defines the green component to read from (value between 0 and 255)
  818. * @param b defines the blue component to read from (value between 0 and 255)
  819. * @param a defines the alpha component to read from (value between 0 and 255)
  820. * @returns a new Color3 object
  821. */
  822. static FromInts(r: number, g: number, b: number, a: number): Color4;
  823. /**
  824. * Check the content of a given array and convert it to an array containing RGBA data
  825. * If the original array was already containing count * 4 values then it is returned directly
  826. * @param colors defines the array to check
  827. * @param count defines the number of RGBA data to expect
  828. * @returns an array containing count * 4 values (RGBA)
  829. */
  830. static CheckColors4(colors: number[], count: number): number[];
  831. }
  832. /**
  833. * Class representing a vector containing 2 coordinates
  834. */
  835. export class Vector2 {
  836. /** defines the first coordinate */
  837. x: number;
  838. /** defines the second coordinate */
  839. y: number;
  840. /**
  841. * Creates a new Vector2 from the given x and y coordinates
  842. * @param x defines the first coordinate
  843. * @param y defines the second coordinate
  844. */
  845. constructor(
  846. /** defines the first coordinate */
  847. x?: number,
  848. /** defines the second coordinate */
  849. y?: number);
  850. /**
  851. * Gets a string with the Vector2 coordinates
  852. * @returns a string with the Vector2 coordinates
  853. */
  854. toString(): string;
  855. /**
  856. * Gets class name
  857. * @returns the string "Vector2"
  858. */
  859. getClassName(): string;
  860. /**
  861. * Gets current vector hash code
  862. * @returns the Vector2 hash code as a number
  863. */
  864. getHashCode(): number;
  865. /**
  866. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  867. * @param array defines the source array
  868. * @param index defines the offset in source array
  869. * @returns the current Vector2
  870. */
  871. toArray(array: FloatArray, index?: number): Vector2;
  872. /**
  873. * Copy the current vector to an array
  874. * @returns a new array with 2 elements: the Vector2 coordinates.
  875. */
  876. asArray(): number[];
  877. /**
  878. * Sets the Vector2 coordinates with the given Vector2 coordinates
  879. * @param source defines the source Vector2
  880. * @returns the current updated Vector2
  881. */
  882. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  883. /**
  884. * Sets the Vector2 coordinates with the given floats
  885. * @param x defines the first coordinate
  886. * @param y defines the second coordinate
  887. * @returns the current updated Vector2
  888. */
  889. copyFromFloats(x: number, y: number): Vector2;
  890. /**
  891. * Sets the Vector2 coordinates with the given floats
  892. * @param x defines the first coordinate
  893. * @param y defines the second coordinate
  894. * @returns the current updated Vector2
  895. */
  896. set(x: number, y: number): Vector2;
  897. /**
  898. * Add another vector with the current one
  899. * @param otherVector defines the other vector
  900. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  901. */
  902. add(otherVector: DeepImmutable<Vector2>): Vector2;
  903. /**
  904. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  905. * @param otherVector defines the other vector
  906. * @param result defines the target vector
  907. * @returns the unmodified current Vector2
  908. */
  909. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  910. /**
  911. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  912. * @param otherVector defines the other vector
  913. * @returns the current updated Vector2
  914. */
  915. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  916. /**
  917. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  918. * @param otherVector defines the other vector
  919. * @returns a new Vector2
  920. */
  921. addVector3(otherVector: Vector3): Vector2;
  922. /**
  923. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  924. * @param otherVector defines the other vector
  925. * @returns a new Vector2
  926. */
  927. subtract(otherVector: Vector2): Vector2;
  928. /**
  929. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  930. * @param otherVector defines the other vector
  931. * @param result defines the target vector
  932. * @returns the unmodified current Vector2
  933. */
  934. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  935. /**
  936. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  937. * @param otherVector defines the other vector
  938. * @returns the current updated Vector2
  939. */
  940. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  941. /**
  942. * Multiplies in place the current Vector2 coordinates by the given ones
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  953. /**
  954. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @param result defines the target vector
  957. * @returns the unmodified current Vector2
  958. */
  959. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  960. /**
  961. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  962. * @param x defines the first coordinate
  963. * @param y defines the second coordinate
  964. * @returns a new Vector2
  965. */
  966. multiplyByFloats(x: number, y: number): Vector2;
  967. /**
  968. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  969. * @param otherVector defines the other vector
  970. * @returns a new Vector2
  971. */
  972. divide(otherVector: Vector2): Vector2;
  973. /**
  974. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  975. * @param otherVector defines the other vector
  976. * @param result defines the target vector
  977. * @returns the unmodified current Vector2
  978. */
  979. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  980. /**
  981. * Divides the current Vector2 coordinates by the given ones
  982. * @param otherVector defines the other vector
  983. * @returns the current updated Vector2
  984. */
  985. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  986. /**
  987. * Gets a new Vector2 with current Vector2 negated coordinates
  988. * @returns a new Vector2
  989. */
  990. negate(): Vector2;
  991. /**
  992. * Multiply the Vector2 coordinates by scale
  993. * @param scale defines the scaling factor
  994. * @returns the current updated Vector2
  995. */
  996. scaleInPlace(scale: number): Vector2;
  997. /**
  998. * Returns a new Vector2 scaled by "scale" from the current Vector2
  999. * @param scale defines the scaling factor
  1000. * @returns a new Vector2
  1001. */
  1002. scale(scale: number): Vector2;
  1003. /**
  1004. * Scale the current Vector2 values by a factor to a given Vector2
  1005. * @param scale defines the scale factor
  1006. * @param result defines the Vector2 object where to store the result
  1007. * @returns the unmodified current Vector2
  1008. */
  1009. scaleToRef(scale: number, result: Vector2): Vector2;
  1010. /**
  1011. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1012. * @param scale defines the scale factor
  1013. * @param result defines the Vector2 object where to store the result
  1014. * @returns the unmodified current Vector2
  1015. */
  1016. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1017. /**
  1018. * Gets a boolean if two vectors are equals
  1019. * @param otherVector defines the other vector
  1020. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1021. */
  1022. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1023. /**
  1024. * Gets a boolean if two vectors are equals (using an epsilon value)
  1025. * @param otherVector defines the other vector
  1026. * @param epsilon defines the minimal distance to consider equality
  1027. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1028. */
  1029. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1030. /**
  1031. * Gets a new Vector2 from current Vector2 floored values
  1032. * @returns a new Vector2
  1033. */
  1034. floor(): Vector2;
  1035. /**
  1036. * Gets a new Vector2 from current Vector2 floored values
  1037. * @returns a new Vector2
  1038. */
  1039. fract(): Vector2;
  1040. /**
  1041. * Gets the length of the vector
  1042. * @returns the vector length (float)
  1043. */
  1044. length(): number;
  1045. /**
  1046. * Gets the vector squared length
  1047. * @returns the vector squared length (float)
  1048. */
  1049. lengthSquared(): number;
  1050. /**
  1051. * Normalize the vector
  1052. * @returns the current updated Vector2
  1053. */
  1054. normalize(): Vector2;
  1055. /**
  1056. * Gets a new Vector2 copied from the Vector2
  1057. * @returns a new Vector2
  1058. */
  1059. clone(): Vector2;
  1060. /**
  1061. * Gets a new Vector2(0, 0)
  1062. * @returns a new Vector2
  1063. */
  1064. static Zero(): Vector2;
  1065. /**
  1066. * Gets a new Vector2(1, 1)
  1067. * @returns a new Vector2
  1068. */
  1069. static One(): Vector2;
  1070. /**
  1071. * Gets a new Vector2 set from the given index element of the given array
  1072. * @param array defines the data source
  1073. * @param offset defines the offset in the data source
  1074. * @returns a new Vector2
  1075. */
  1076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1077. /**
  1078. * Sets "result" from the given index element of the given array
  1079. * @param array defines the data source
  1080. * @param offset defines the offset in the data source
  1081. * @param result defines the target vector
  1082. */
  1083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1084. /**
  1085. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1086. * @param value1 defines 1st point of control
  1087. * @param value2 defines 2nd point of control
  1088. * @param value3 defines 3rd point of control
  1089. * @param value4 defines 4th point of control
  1090. * @param amount defines the interpolation factor
  1091. * @returns a new Vector2
  1092. */
  1093. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1094. /**
  1095. * 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".
  1096. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1097. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1098. * @param value defines the value to clamp
  1099. * @param min defines the lower limit
  1100. * @param max defines the upper limit
  1101. * @returns a new Vector2
  1102. */
  1103. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1104. /**
  1105. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1106. * @param value1 defines the 1st control point
  1107. * @param tangent1 defines the outgoing tangent
  1108. * @param value2 defines the 2nd control point
  1109. * @param tangent2 defines the incoming tangent
  1110. * @param amount defines the interpolation factor
  1111. * @returns a new Vector2
  1112. */
  1113. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1114. /**
  1115. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1116. * @param start defines the start vector
  1117. * @param end defines the end vector
  1118. * @param amount defines the interpolation factor
  1119. * @returns a new Vector2
  1120. */
  1121. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1122. /**
  1123. * Gets the dot product of the vector "left" and the vector "right"
  1124. * @param left defines first vector
  1125. * @param right defines second vector
  1126. * @returns the dot product (float)
  1127. */
  1128. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1129. /**
  1130. * Returns a new Vector2 equal to the normalized given vector
  1131. * @param vector defines the vector to normalize
  1132. * @returns a new Vector2
  1133. */
  1134. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1137. * @param left defines 1st vector
  1138. * @param right defines 2nd vector
  1139. * @returns a new Vector2
  1140. */
  1141. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1142. /**
  1143. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1144. * @param left defines 1st vector
  1145. * @param right defines 2nd vector
  1146. * @returns a new Vector2
  1147. */
  1148. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1149. /**
  1150. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1151. * @param vector defines the vector to transform
  1152. * @param transformation defines the matrix to apply
  1153. * @returns a new Vector2
  1154. */
  1155. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1156. /**
  1157. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1158. * @param vector defines the vector to transform
  1159. * @param transformation defines the matrix to apply
  1160. * @param result defines the target vector
  1161. */
  1162. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1163. /**
  1164. * Determines if a given vector is included in a triangle
  1165. * @param p defines the vector to test
  1166. * @param p0 defines 1st triangle point
  1167. * @param p1 defines 2nd triangle point
  1168. * @param p2 defines 3rd triangle point
  1169. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1170. */
  1171. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1172. /**
  1173. * Gets the distance between the vectors "value1" and "value2"
  1174. * @param value1 defines first vector
  1175. * @param value2 defines second vector
  1176. * @returns the distance between vectors
  1177. */
  1178. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1179. /**
  1180. * Returns the squared distance between the vectors "value1" and "value2"
  1181. * @param value1 defines first vector
  1182. * @param value2 defines second vector
  1183. * @returns the squared distance between vectors
  1184. */
  1185. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1186. /**
  1187. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1188. * @param value1 defines first vector
  1189. * @param value2 defines second vector
  1190. * @returns a new Vector2
  1191. */
  1192. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1193. /**
  1194. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1195. * @param p defines the middle point
  1196. * @param segA defines one point of the segment
  1197. * @param segB defines the other point of the segment
  1198. * @returns the shortest distance
  1199. */
  1200. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1201. }
  1202. /**
  1203. * Classed used to store (x,y,z) vector representation
  1204. * A Vector3 is the main object used in 3D geometry
  1205. * It can represent etiher the coordinates of a point the space, either a direction
  1206. * Reminder: js uses a left handed forward facing system
  1207. */
  1208. export class Vector3 {
  1209. /**
  1210. * Defines the first coordinates (on X axis)
  1211. */
  1212. x: number;
  1213. /**
  1214. * Defines the second coordinates (on Y axis)
  1215. */
  1216. y: number;
  1217. /**
  1218. * Defines the third coordinates (on Z axis)
  1219. */
  1220. z: number;
  1221. private static _UpReadOnly;
  1222. /**
  1223. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1224. * @param x defines the first coordinates (on X axis)
  1225. * @param y defines the second coordinates (on Y axis)
  1226. * @param z defines the third coordinates (on Z axis)
  1227. */
  1228. constructor(
  1229. /**
  1230. * Defines the first coordinates (on X axis)
  1231. */
  1232. x?: number,
  1233. /**
  1234. * Defines the second coordinates (on Y axis)
  1235. */
  1236. y?: number,
  1237. /**
  1238. * Defines the third coordinates (on Z axis)
  1239. */
  1240. z?: number);
  1241. /**
  1242. * Creates a string representation of the Vector3
  1243. * @returns a string with the Vector3 coordinates.
  1244. */
  1245. toString(): string;
  1246. /**
  1247. * Gets the class name
  1248. * @returns the string "Vector3"
  1249. */
  1250. getClassName(): string;
  1251. /**
  1252. * Creates the Vector3 hash code
  1253. * @returns a number which tends to be unique between Vector3 instances
  1254. */
  1255. getHashCode(): number;
  1256. /**
  1257. * Creates an array containing three elements : the coordinates of the Vector3
  1258. * @returns a new array of numbers
  1259. */
  1260. asArray(): number[];
  1261. /**
  1262. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1263. * @param array defines the destination array
  1264. * @param index defines the offset in the destination array
  1265. * @returns the current Vector3
  1266. */
  1267. toArray(array: FloatArray, index?: number): Vector3;
  1268. /**
  1269. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1270. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1271. */
  1272. toQuaternion(): Quaternion;
  1273. /**
  1274. * Adds the given vector to the current Vector3
  1275. * @param otherVector defines the second operand
  1276. * @returns the current updated Vector3
  1277. */
  1278. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1279. /**
  1280. * Adds the given coordinates to the current Vector3
  1281. * @param x defines the x coordinate of the operand
  1282. * @param y defines the y coordinate of the operand
  1283. * @param z defines the z coordinate of the operand
  1284. * @returns the current updated Vector3
  1285. */
  1286. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1287. /**
  1288. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1289. * @param otherVector defines the second operand
  1290. * @returns the resulting Vector3
  1291. */
  1292. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1293. /**
  1294. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1295. * @param otherVector defines the second operand
  1296. * @param result defines the Vector3 object where to store the result
  1297. * @returns the current Vector3
  1298. */
  1299. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1300. /**
  1301. * Subtract the given vector from the current Vector3
  1302. * @param otherVector defines the second operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1306. /**
  1307. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1321. * @param x defines the x coordinate of the operand
  1322. * @param y defines the y coordinate of the operand
  1323. * @param z defines the z coordinate of the operand
  1324. * @returns the resulting Vector3
  1325. */
  1326. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1327. /**
  1328. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1329. * @param x defines the x coordinate of the operand
  1330. * @param y defines the y coordinate of the operand
  1331. * @param z defines the z coordinate of the operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1336. /**
  1337. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1338. * @returns a new Vector3
  1339. */
  1340. negate(): Vector3;
  1341. /**
  1342. * Multiplies the Vector3 coordinates by the float "scale"
  1343. * @param scale defines the multiplier factor
  1344. * @returns the current updated Vector3
  1345. */
  1346. scaleInPlace(scale: number): Vector3;
  1347. /**
  1348. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1349. * @param scale defines the multiplier factor
  1350. * @returns a new Vector3
  1351. */
  1352. scale(scale: number): Vector3;
  1353. /**
  1354. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1355. * @param scale defines the multiplier factor
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the current Vector3
  1358. */
  1359. scaleToRef(scale: number, result: Vector3): Vector3;
  1360. /**
  1361. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1362. * @param scale defines the scale factor
  1363. * @param result defines the Vector3 object where to store the result
  1364. * @returns the unmodified current Vector3
  1365. */
  1366. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1367. /**
  1368. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1369. * @param otherVector defines the second operand
  1370. * @returns true if both vectors are equals
  1371. */
  1372. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1373. /**
  1374. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1375. * @param otherVector defines the second operand
  1376. * @param epsilon defines the minimal distance to define values as equals
  1377. * @returns true if both vectors are distant less than epsilon
  1378. */
  1379. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1380. /**
  1381. * Returns true if the current Vector3 coordinates equals the given floats
  1382. * @param x defines the x coordinate of the operand
  1383. * @param y defines the y coordinate of the operand
  1384. * @param z defines the z coordinate of the operand
  1385. * @returns true if both vectors are equals
  1386. */
  1387. equalsToFloats(x: number, y: number, z: number): boolean;
  1388. /**
  1389. * Multiplies the current Vector3 coordinates by the given ones
  1390. * @param otherVector defines the second operand
  1391. * @returns the current updated Vector3
  1392. */
  1393. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1394. /**
  1395. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1396. * @param otherVector defines the second operand
  1397. * @returns the new Vector3
  1398. */
  1399. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1400. /**
  1401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1402. * @param otherVector defines the second operand
  1403. * @param result defines the Vector3 object where to store the result
  1404. * @returns the current Vector3
  1405. */
  1406. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1407. /**
  1408. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1409. * @param x defines the x coordinate of the operand
  1410. * @param y defines the y coordinate of the operand
  1411. * @param z defines the z coordinate of the operand
  1412. * @returns the new Vector3
  1413. */
  1414. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1415. /**
  1416. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1417. * @param otherVector defines the second operand
  1418. * @returns the new Vector3
  1419. */
  1420. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1421. /**
  1422. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1423. * @param otherVector defines the second operand
  1424. * @param result defines the Vector3 object where to store the result
  1425. * @returns the current Vector3
  1426. */
  1427. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1428. /**
  1429. * Divides the current Vector3 coordinates by the given ones.
  1430. * @param otherVector defines the second operand
  1431. * @returns the current updated Vector3
  1432. */
  1433. divideInPlace(otherVector: Vector3): Vector3;
  1434. /**
  1435. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1436. * @param other defines the second operand
  1437. * @returns the current updated Vector3
  1438. */
  1439. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1442. * @param other defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1448. * @param x defines the x coordinate of the operand
  1449. * @param y defines the y coordinate of the operand
  1450. * @param z defines the z coordinate of the operand
  1451. * @returns the current updated Vector3
  1452. */
  1453. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1454. /**
  1455. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1456. * @param x defines the x coordinate of the operand
  1457. * @param y defines the y coordinate of the operand
  1458. * @param z defines the z coordinate of the operand
  1459. * @returns the current updated Vector3
  1460. */
  1461. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1462. /**
  1463. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1464. * Check if is non uniform within a certain amount of decimal places to account for this
  1465. * @param epsilon the amount the values can differ
  1466. * @returns if the the vector is non uniform to a certain number of decimal places
  1467. */
  1468. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1469. /**
  1470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1471. */
  1472. readonly isNonUniform: boolean;
  1473. /**
  1474. * Gets a new Vector3 from current Vector3 floored values
  1475. * @returns a new Vector3
  1476. */
  1477. floor(): Vector3;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. fract(): Vector3;
  1483. /**
  1484. * Gets the length of the Vector3
  1485. * @returns the length of the Vecto3
  1486. */
  1487. length(): number;
  1488. /**
  1489. * Gets the squared length of the Vector3
  1490. * @returns squared length of the Vector3
  1491. */
  1492. lengthSquared(): number;
  1493. /**
  1494. * Normalize the current Vector3.
  1495. * Please note that this is an in place operation.
  1496. * @returns the current updated Vector3
  1497. */
  1498. normalize(): Vector3;
  1499. /**
  1500. * Reorders the x y z properties of the vector in place
  1501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1502. * @returns the current updated vector
  1503. */
  1504. reorderInPlace(order: string): this;
  1505. /**
  1506. * Rotates the vector around 0,0,0 by a quaternion
  1507. * @param quaternion the rotation quaternion
  1508. * @param result vector to store the result
  1509. * @returns the resulting vector
  1510. */
  1511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1512. /**
  1513. * Rotates a vector around a given point
  1514. * @param quaternion the rotation quaternion
  1515. * @param point the point to rotate around
  1516. * @param result vector to store the result
  1517. * @returns the resulting vector
  1518. */
  1519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1520. /**
  1521. * Normalize the current Vector3 with the given input length.
  1522. * Please note that this is an in place operation.
  1523. * @param len the length of the vector
  1524. * @returns the current updated Vector3
  1525. */
  1526. normalizeFromLength(len: number): Vector3;
  1527. /**
  1528. * Normalize the current Vector3 to a new vector
  1529. * @returns the new Vector3
  1530. */
  1531. normalizeToNew(): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 to the reference
  1534. * @param reference define the Vector3 to update
  1535. * @returns the updated Vector3
  1536. */
  1537. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1538. /**
  1539. * Creates a new Vector3 copied from the current Vector3
  1540. * @returns the new Vector3
  1541. */
  1542. clone(): Vector3;
  1543. /**
  1544. * Copies the given vector coordinates to the current Vector3 ones
  1545. * @param source defines the source Vector3
  1546. * @returns the current updated Vector3
  1547. */
  1548. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Copies the given floats to the current Vector3 coordinates
  1551. * @param x defines the x coordinate of the operand
  1552. * @param y defines the y coordinate of the operand
  1553. * @param z defines the z coordinate of the operand
  1554. * @returns the current updated Vector3
  1555. */
  1556. copyFromFloats(x: number, y: number, z: number): Vector3;
  1557. /**
  1558. * Copies the given floats to the current Vector3 coordinates
  1559. * @param x defines the x coordinate of the operand
  1560. * @param y defines the y coordinate of the operand
  1561. * @param z defines the z coordinate of the operand
  1562. * @returns the current updated Vector3
  1563. */
  1564. set(x: number, y: number, z: number): Vector3;
  1565. /**
  1566. * Copies the given float to the current Vector3 coordinates
  1567. * @param v defines the x, y and z coordinates of the operand
  1568. * @returns the current updated Vector3
  1569. */
  1570. setAll(v: number): Vector3;
  1571. /**
  1572. * Get the clip factor between two vectors
  1573. * @param vector0 defines the first operand
  1574. * @param vector1 defines the second operand
  1575. * @param axis defines the axis to use
  1576. * @param size defines the size along the axis
  1577. * @returns the clip factor
  1578. */
  1579. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1580. /**
  1581. * Get angle between two vectors
  1582. * @param vector0 angle between vector0 and vector1
  1583. * @param vector1 angle between vector0 and vector1
  1584. * @param normal direction of the normal
  1585. * @return the angle between vector0 and vector1
  1586. */
  1587. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1588. /**
  1589. * Returns a new Vector3 set from the index "offset" of the given array
  1590. * @param array defines the source array
  1591. * @param offset defines the offset in the source array
  1592. * @returns the new Vector3
  1593. */
  1594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1595. /**
  1596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1597. * This function is deprecated. Use FromArray instead
  1598. * @param array defines the source array
  1599. * @param offset defines the offset in the source array
  1600. * @returns the new Vector3
  1601. */
  1602. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1603. /**
  1604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1605. * @param array defines the source array
  1606. * @param offset defines the offset in the source array
  1607. * @param result defines the Vector3 where to store the result
  1608. */
  1609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1610. /**
  1611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1612. * This function is deprecated. Use FromArrayToRef instead.
  1613. * @param array defines the source array
  1614. * @param offset defines the offset in the source array
  1615. * @param result defines the Vector3 where to store the result
  1616. */
  1617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1618. /**
  1619. * Sets the given vector "result" with the given floats.
  1620. * @param x defines the x coordinate of the source
  1621. * @param y defines the y coordinate of the source
  1622. * @param z defines the z coordinate of the source
  1623. * @param result defines the Vector3 where to store the result
  1624. */
  1625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1626. /**
  1627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1628. * @returns a new empty Vector3
  1629. */
  1630. static Zero(): Vector3;
  1631. /**
  1632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1633. * @returns a new unit Vector3
  1634. */
  1635. static One(): Vector3;
  1636. /**
  1637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1638. * @returns a new up Vector3
  1639. */
  1640. static Up(): Vector3;
  1641. /**
  1642. * Gets a up Vector3 that must not be updated
  1643. */
  1644. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1647. * @returns a new down Vector3
  1648. */
  1649. static Down(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1652. * @returns a new forward Vector3
  1653. */
  1654. static Forward(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1657. * @returns a new forward Vector3
  1658. */
  1659. static Backward(): Vector3;
  1660. /**
  1661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1662. * @returns a new right Vector3
  1663. */
  1664. static Right(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1667. * @returns a new left Vector3
  1668. */
  1669. static Left(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1673. * @param vector defines the Vector3 to transform
  1674. * @param transformation defines the transformation matrix
  1675. * @returns the transformed Vector3
  1676. */
  1677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1678. /**
  1679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1681. * @param vector defines the Vector3 to transform
  1682. * @param transformation defines the transformation matrix
  1683. * @param result defines the Vector3 where to store the result
  1684. */
  1685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1686. /**
  1687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1688. * This method computes tranformed coordinates only, not transformed direction vectors
  1689. * @param x define the x coordinate of the source vector
  1690. * @param y define the y coordinate of the source vector
  1691. * @param z define the z coordinate of the source vector
  1692. * @param transformation defines the transformation matrix
  1693. * @param result defines the Vector3 where to store the result
  1694. */
  1695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1696. /**
  1697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1699. * @param vector defines the Vector3 to transform
  1700. * @param transformation defines the transformation matrix
  1701. * @returns the new Vector3
  1702. */
  1703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1704. /**
  1705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1707. * @param vector defines the Vector3 to transform
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param x define the x coordinate of the source vector
  1716. * @param y define the y coordinate of the source vector
  1717. * @param z define the z coordinate of the source vector
  1718. * @param transformation defines the transformation matrix
  1719. * @param result defines the Vector3 where to store the result
  1720. */
  1721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1722. /**
  1723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1724. * @param value1 defines the first control point
  1725. * @param value2 defines the second control point
  1726. * @param value3 defines the third control point
  1727. * @param value4 defines the fourth control point
  1728. * @param amount defines the amount on the spline to use
  1729. * @returns the new Vector3
  1730. */
  1731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1732. /**
  1733. * 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"
  1734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1736. * @param value defines the current value
  1737. * @param min defines the lower range value
  1738. * @param max defines the upper range value
  1739. * @returns the new Vector3
  1740. */
  1741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1742. /**
  1743. * 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"
  1744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1746. * @param value defines the current value
  1747. * @param min defines the lower range value
  1748. * @param max defines the upper range value
  1749. * @param result defines the Vector3 where to store the result
  1750. */
  1751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1752. /**
  1753. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1754. * @param value1 defines the first control point
  1755. * @param tangent1 defines the first tangent vector
  1756. * @param value2 defines the second control point
  1757. * @param tangent2 defines the second tangent vector
  1758. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1759. * @returns the new Vector3
  1760. */
  1761. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1762. /**
  1763. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1764. * @param start defines the start value
  1765. * @param end defines the end value
  1766. * @param amount max defines amount between both (between 0 and 1)
  1767. * @returns the new Vector3
  1768. */
  1769. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1770. /**
  1771. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1772. * @param start defines the start value
  1773. * @param end defines the end value
  1774. * @param amount max defines amount between both (between 0 and 1)
  1775. * @param result defines the Vector3 where to store the result
  1776. */
  1777. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1778. /**
  1779. * Returns the dot product (float) between the vectors "left" and "right"
  1780. * @param left defines the left operand
  1781. * @param right defines the right operand
  1782. * @returns the dot product
  1783. */
  1784. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1785. /**
  1786. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1787. * The cross product is then orthogonal to both "left" and "right"
  1788. * @param left defines the left operand
  1789. * @param right defines the right operand
  1790. * @returns the cross product
  1791. */
  1792. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the cross product of "left" and "right"
  1795. * The cross product is then orthogonal to both "left" and "right"
  1796. * @param left defines the left operand
  1797. * @param right defines the right operand
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1801. /**
  1802. * Returns a new Vector3 as the normalization of the given vector
  1803. * @param vector defines the Vector3 to normalize
  1804. * @returns the new Vector3
  1805. */
  1806. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1807. /**
  1808. * Sets the given vector "result" with the normalization of the given first vector
  1809. * @param vector defines the Vector3 to normalize
  1810. * @param result defines the Vector3 where to store the result
  1811. */
  1812. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1813. /**
  1814. * Project a Vector3 onto screen space
  1815. * @param vector defines the Vector3 to project
  1816. * @param world defines the world matrix to use
  1817. * @param transform defines the transform (view x projection) matrix to use
  1818. * @param viewport defines the screen viewport to use
  1819. * @returns the new Vector3
  1820. */
  1821. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1822. /** @hidden */
  1823. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1824. /**
  1825. * Unproject from screen space to object space
  1826. * @param source defines the screen space Vector3 to use
  1827. * @param viewportWidth defines the current width of the viewport
  1828. * @param viewportHeight defines the current height of the viewport
  1829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1830. * @param transform defines the transform (view x projection) matrix to use
  1831. * @returns the new Vector3
  1832. */
  1833. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1834. /**
  1835. * Unproject from screen space to object space
  1836. * @param source defines the screen space Vector3 to use
  1837. * @param viewportWidth defines the current width of the viewport
  1838. * @param viewportHeight defines the current height of the viewport
  1839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1840. * @param view defines the view matrix to use
  1841. * @param projection defines the projection matrix to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param view defines the view matrix to use
  1852. * @param projection defines the projection matrix to use
  1853. * @param result defines the Vector3 where to store the result
  1854. */
  1855. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param sourceX defines the screen space x coordinate to use
  1859. * @param sourceY defines the screen space y coordinate to use
  1860. * @param sourceZ defines the screen space z coordinate to use
  1861. * @param viewportWidth defines the current width of the viewport
  1862. * @param viewportHeight defines the current height of the viewport
  1863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1864. * @param view defines the view matrix to use
  1865. * @param projection defines the projection matrix to use
  1866. * @param result defines the Vector3 where to store the result
  1867. */
  1868. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1869. /**
  1870. * Gets the minimal coordinate values between two Vector3
  1871. * @param left defines the first operand
  1872. * @param right defines the second operand
  1873. * @returns the new Vector3
  1874. */
  1875. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1876. /**
  1877. * Gets the maximal coordinate values between two Vector3
  1878. * @param left defines the first operand
  1879. * @param right defines the second operand
  1880. * @returns the new Vector3
  1881. */
  1882. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1883. /**
  1884. * Returns the distance between the vectors "value1" and "value2"
  1885. * @param value1 defines the first operand
  1886. * @param value2 defines the second operand
  1887. * @returns the distance
  1888. */
  1889. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1890. /**
  1891. * Returns the squared distance between the vectors "value1" and "value2"
  1892. * @param value1 defines the first operand
  1893. * @param value2 defines the second operand
  1894. * @returns the squared distance
  1895. */
  1896. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1897. /**
  1898. * Returns a new Vector3 located at the center between "value1" and "value2"
  1899. * @param value1 defines the first operand
  1900. * @param value2 defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1906. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1907. * to something in order to rotate it from its local system to the given target system
  1908. * Note: axis1, axis2 and axis3 are normalized during this operation
  1909. * @param axis1 defines the first axis
  1910. * @param axis2 defines the second axis
  1911. * @param axis3 defines the third axis
  1912. * @returns a new Vector3
  1913. */
  1914. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1915. /**
  1916. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1917. * @param axis1 defines the first axis
  1918. * @param axis2 defines the second axis
  1919. * @param axis3 defines the third axis
  1920. * @param ref defines the Vector3 where to store the result
  1921. */
  1922. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1923. }
  1924. /**
  1925. * Vector4 class created for EulerAngle class conversion to Quaternion
  1926. */
  1927. export class Vector4 {
  1928. /** x value of the vector */
  1929. x: number;
  1930. /** y value of the vector */
  1931. y: number;
  1932. /** z value of the vector */
  1933. z: number;
  1934. /** w value of the vector */
  1935. w: number;
  1936. /**
  1937. * Creates a Vector4 object from the given floats.
  1938. * @param x x value of the vector
  1939. * @param y y value of the vector
  1940. * @param z z value of the vector
  1941. * @param w w value of the vector
  1942. */
  1943. constructor(
  1944. /** x value of the vector */
  1945. x: number,
  1946. /** y value of the vector */
  1947. y: number,
  1948. /** z value of the vector */
  1949. z: number,
  1950. /** w value of the vector */
  1951. w: number);
  1952. /**
  1953. * Returns the string with the Vector4 coordinates.
  1954. * @returns a string containing all the vector values
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Returns the string "Vector4".
  1959. * @returns "Vector4"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Returns the Vector4 hash code.
  1964. * @returns a unique hash code
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1969. * @returns the resulting array
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Populates the given array from the given index with the Vector4 coordinates.
  1974. * @param array array to populate
  1975. * @param index index of the array to start at (default: 0)
  1976. * @returns the Vector4.
  1977. */
  1978. toArray(array: FloatArray, index?: number): Vector4;
  1979. /**
  1980. * Adds the given vector to the current Vector4.
  1981. * @param otherVector the vector to add
  1982. * @returns the updated Vector4.
  1983. */
  1984. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1985. /**
  1986. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1987. * @param otherVector the vector to add
  1988. * @returns the resulting vector
  1989. */
  1990. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1991. /**
  1992. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1993. * @param otherVector the vector to add
  1994. * @param result the vector to store the result
  1995. * @returns the current Vector4.
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1998. /**
  1999. * Subtract in place the given vector from the current Vector4.
  2000. * @param otherVector the vector to subtract
  2001. * @returns the updated Vector4.
  2002. */
  2003. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2004. /**
  2005. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2006. * @param otherVector the vector to add
  2007. * @returns the new vector with the result
  2008. */
  2009. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2010. /**
  2011. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2012. * @param otherVector the vector to subtract
  2013. * @param result the vector to store the result
  2014. * @returns the current Vector4.
  2015. */
  2016. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. */
  2020. /**
  2021. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2022. * @param x value to subtract
  2023. * @param y value to subtract
  2024. * @param z value to subtract
  2025. * @param w value to subtract
  2026. * @returns new vector containing the result
  2027. */
  2028. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2029. /**
  2030. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2031. * @param x value to subtract
  2032. * @param y value to subtract
  2033. * @param z value to subtract
  2034. * @param w value to subtract
  2035. * @param result the vector to store the result in
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2041. * @returns a new vector with the negated values
  2042. */
  2043. negate(): Vector4;
  2044. /**
  2045. * Multiplies the current Vector4 coordinates by scale (float).
  2046. * @param scale the number to scale with
  2047. * @returns the updated Vector4.
  2048. */
  2049. scaleInPlace(scale: number): Vector4;
  2050. /**
  2051. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2052. * @param scale the number to scale with
  2053. * @returns a new vector with the result
  2054. */
  2055. scale(scale: number): Vector4;
  2056. /**
  2057. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2058. * @param scale the number to scale with
  2059. * @param result a vector to store the result in
  2060. * @returns the current Vector4.
  2061. */
  2062. scaleToRef(scale: number, result: Vector4): Vector4;
  2063. /**
  2064. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2065. * @param scale defines the scale factor
  2066. * @param result defines the Vector4 object where to store the result
  2067. * @returns the unmodified current Vector4
  2068. */
  2069. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2070. /**
  2071. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2072. * @param otherVector the vector to compare against
  2073. * @returns true if they are equal
  2074. */
  2075. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2076. /**
  2077. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2078. * @param otherVector vector to compare against
  2079. * @param epsilon (Default: very small number)
  2080. * @returns true if they are equal
  2081. */
  2082. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2083. /**
  2084. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2085. * @param x x value to compare against
  2086. * @param y y value to compare against
  2087. * @param z z value to compare against
  2088. * @param w w value to compare against
  2089. * @returns true if equal
  2090. */
  2091. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2092. /**
  2093. * Multiplies in place the current Vector4 by the given one.
  2094. * @param otherVector vector to multiple with
  2095. * @returns the updated Vector4.
  2096. */
  2097. multiplyInPlace(otherVector: Vector4): Vector4;
  2098. /**
  2099. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2100. * @param otherVector vector to multiple with
  2101. * @returns resulting new vector
  2102. */
  2103. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2104. /**
  2105. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2106. * @param otherVector vector to multiple with
  2107. * @param result vector to store the result
  2108. * @returns the current Vector4.
  2109. */
  2110. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2111. /**
  2112. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2113. * @param x x value multiply with
  2114. * @param y y value multiply with
  2115. * @param z z value multiply with
  2116. * @param w w value multiply with
  2117. * @returns resulting new vector
  2118. */
  2119. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2122. * @param otherVector vector to devide with
  2123. * @returns resulting new vector
  2124. */
  2125. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2128. * @param otherVector vector to devide with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Divides the current Vector3 coordinates by the given ones.
  2135. * @param otherVector vector to devide with
  2136. * @returns the updated Vector3.
  2137. */
  2138. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2139. /**
  2140. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2141. * @param other defines the second operand
  2142. * @returns the current updated Vector4
  2143. */
  2144. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2145. /**
  2146. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2147. * @param other defines the second operand
  2148. * @returns the current updated Vector4
  2149. */
  2150. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2151. /**
  2152. * Gets a new Vector4 from current Vector4 floored values
  2153. * @returns a new Vector4
  2154. */
  2155. floor(): Vector4;
  2156. /**
  2157. * Gets a new Vector4 from current Vector3 floored values
  2158. * @returns a new Vector4
  2159. */
  2160. fract(): Vector4;
  2161. /**
  2162. * Returns the Vector4 length (float).
  2163. * @returns the length
  2164. */
  2165. length(): number;
  2166. /**
  2167. * Returns the Vector4 squared length (float).
  2168. * @returns the length squared
  2169. */
  2170. lengthSquared(): number;
  2171. /**
  2172. * Normalizes in place the Vector4.
  2173. * @returns the updated Vector4.
  2174. */
  2175. normalize(): Vector4;
  2176. /**
  2177. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2178. * @returns this converted to a new vector3
  2179. */
  2180. toVector3(): Vector3;
  2181. /**
  2182. * Returns a new Vector4 copied from the current one.
  2183. * @returns the new cloned vector
  2184. */
  2185. clone(): Vector4;
  2186. /**
  2187. * Updates the current Vector4 with the given one coordinates.
  2188. * @param source the source vector to copy from
  2189. * @returns the updated Vector4.
  2190. */
  2191. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2192. /**
  2193. * Updates the current Vector4 coordinates with the given floats.
  2194. * @param x float to copy from
  2195. * @param y float to copy from
  2196. * @param z float to copy from
  2197. * @param w float to copy from
  2198. * @returns the updated Vector4.
  2199. */
  2200. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2201. /**
  2202. * Updates the current Vector4 coordinates with the given floats.
  2203. * @param x float to set from
  2204. * @param y float to set from
  2205. * @param z float to set from
  2206. * @param w float to set from
  2207. * @returns the updated Vector4.
  2208. */
  2209. set(x: number, y: number, z: number, w: number): Vector4;
  2210. /**
  2211. * Copies the given float to the current Vector3 coordinates
  2212. * @param v defines the x, y, z and w coordinates of the operand
  2213. * @returns the current updated Vector3
  2214. */
  2215. setAll(v: number): Vector4;
  2216. /**
  2217. * Returns a new Vector4 set from the starting index of the given array.
  2218. * @param array the array to pull values from
  2219. * @param offset the offset into the array to start at
  2220. * @returns the new vector
  2221. */
  2222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2223. /**
  2224. * Updates the given vector "result" from the starting index of the given array.
  2225. * @param array the array to pull values from
  2226. * @param offset the offset into the array to start at
  2227. * @param result the vector to store the result in
  2228. */
  2229. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2230. /**
  2231. * Updates the given vector "result" from the starting index of the given Float32Array.
  2232. * @param array the array to pull values from
  2233. * @param offset the offset into the array to start at
  2234. * @param result the vector to store the result in
  2235. */
  2236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2237. /**
  2238. * Updates the given vector "result" coordinates from the given floats.
  2239. * @param x float to set from
  2240. * @param y float to set from
  2241. * @param z float to set from
  2242. * @param w float to set from
  2243. * @param result the vector to the floats in
  2244. */
  2245. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2246. /**
  2247. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2248. * @returns the new vector
  2249. */
  2250. static Zero(): Vector4;
  2251. /**
  2252. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2253. * @returns the new vector
  2254. */
  2255. static One(): Vector4;
  2256. /**
  2257. * Returns a new normalized Vector4 from the given one.
  2258. * @param vector the vector to normalize
  2259. * @returns the vector
  2260. */
  2261. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2262. /**
  2263. * Updates the given vector "result" from the normalization of the given one.
  2264. * @param vector the vector to normalize
  2265. * @param result the vector to store the result in
  2266. */
  2267. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2268. /**
  2269. * Returns a vector with the minimum values from the left and right vectors
  2270. * @param left left vector to minimize
  2271. * @param right right vector to minimize
  2272. * @returns a new vector with the minimum of the left and right vector values
  2273. */
  2274. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2275. /**
  2276. * Returns a vector with the maximum values from the left and right vectors
  2277. * @param left left vector to maximize
  2278. * @param right right vector to maximize
  2279. * @returns a new vector with the maximum of the left and right vector values
  2280. */
  2281. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Returns the distance (float) between the vectors "value1" and "value2".
  2284. * @param value1 value to calulate the distance between
  2285. * @param value2 value to calulate the distance between
  2286. * @return the distance between the two vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2289. /**
  2290. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2291. * @param value1 value to calulate the distance between
  2292. * @param value2 value to calulate the distance between
  2293. * @return the distance between the two vectors squared
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2296. /**
  2297. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2298. * @param value1 value to calulate the center between
  2299. * @param value2 value to calulate the center between
  2300. * @return the center between the two vectors
  2301. */
  2302. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2305. * This methods computes transformed normalized direction vectors only.
  2306. * @param vector the vector to transform
  2307. * @param transformation the transformation matrix to apply
  2308. * @returns the new vector
  2309. */
  2310. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2311. /**
  2312. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2313. * This methods computes transformed normalized direction vectors only.
  2314. * @param vector the vector to transform
  2315. * @param transformation the transformation matrix to apply
  2316. * @param result the vector to store the result in
  2317. */
  2318. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2319. /**
  2320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2321. * This methods computes transformed normalized direction vectors only.
  2322. * @param x value to transform
  2323. * @param y value to transform
  2324. * @param z value to transform
  2325. * @param w value to transform
  2326. * @param transformation the transformation matrix to apply
  2327. * @param result the vector to store the results in
  2328. */
  2329. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2330. /**
  2331. * Creates a new Vector4 from a Vector3
  2332. * @param source defines the source data
  2333. * @param w defines the 4th component (default is 0)
  2334. * @returns a new Vector4
  2335. */
  2336. static FromVector3(source: Vector3, w?: number): Vector4;
  2337. }
  2338. /**
  2339. * Interface for the size containing width and height
  2340. */
  2341. export interface ISize {
  2342. /**
  2343. * Width
  2344. */
  2345. width: number;
  2346. /**
  2347. * Heighht
  2348. */
  2349. height: number;
  2350. }
  2351. /**
  2352. * Size containing widht and height
  2353. */
  2354. export class Size implements ISize {
  2355. /**
  2356. * Width
  2357. */
  2358. width: number;
  2359. /**
  2360. * Height
  2361. */
  2362. height: number;
  2363. /**
  2364. * Creates a Size object from the given width and height (floats).
  2365. * @param width width of the new size
  2366. * @param height height of the new size
  2367. */
  2368. constructor(width: number, height: number);
  2369. /**
  2370. * Returns a string with the Size width and height
  2371. * @returns a string with the Size width and height
  2372. */
  2373. toString(): string;
  2374. /**
  2375. * "Size"
  2376. * @returns the string "Size"
  2377. */
  2378. getClassName(): string;
  2379. /**
  2380. * Returns the Size hash code.
  2381. * @returns a hash code for a unique width and height
  2382. */
  2383. getHashCode(): number;
  2384. /**
  2385. * Updates the current size from the given one.
  2386. * @param src the given size
  2387. */
  2388. copyFrom(src: Size): void;
  2389. /**
  2390. * Updates in place the current Size from the given floats.
  2391. * @param width width of the new size
  2392. * @param height height of the new size
  2393. * @returns the updated Size.
  2394. */
  2395. copyFromFloats(width: number, height: number): Size;
  2396. /**
  2397. * Updates in place the current Size from the given floats.
  2398. * @param width width to set
  2399. * @param height height to set
  2400. * @returns the updated Size.
  2401. */
  2402. set(width: number, height: number): Size;
  2403. /**
  2404. * Multiplies the width and height by numbers
  2405. * @param w factor to multiple the width by
  2406. * @param h factor to multiple the height by
  2407. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2408. */
  2409. multiplyByFloats(w: number, h: number): Size;
  2410. /**
  2411. * Clones the size
  2412. * @returns a new Size copied from the given one.
  2413. */
  2414. clone(): Size;
  2415. /**
  2416. * True if the current Size and the given one width and height are strictly equal.
  2417. * @param other the other size to compare against
  2418. * @returns True if the current Size and the given one width and height are strictly equal.
  2419. */
  2420. equals(other: Size): boolean;
  2421. /**
  2422. * The surface of the Size : width * height (float).
  2423. */
  2424. readonly surface: number;
  2425. /**
  2426. * Create a new size of zero
  2427. * @returns a new Size set to (0.0, 0.0)
  2428. */
  2429. static Zero(): Size;
  2430. /**
  2431. * Sums the width and height of two sizes
  2432. * @param otherSize size to add to this size
  2433. * @returns a new Size set as the addition result of the current Size and the given one.
  2434. */
  2435. add(otherSize: Size): Size;
  2436. /**
  2437. * Subtracts the width and height of two
  2438. * @param otherSize size to subtract to this size
  2439. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2440. */
  2441. subtract(otherSize: Size): Size;
  2442. /**
  2443. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2444. * @param start starting size to lerp between
  2445. * @param end end size to lerp between
  2446. * @param amount amount to lerp between the start and end values
  2447. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2448. */
  2449. static Lerp(start: Size, end: Size, amount: number): Size;
  2450. }
  2451. /**
  2452. * Class used to store quaternion data
  2453. * @see https://en.wikipedia.org/wiki/Quaternion
  2454. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2455. */
  2456. export class Quaternion {
  2457. /** defines the first component (0 by default) */
  2458. x: number;
  2459. /** defines the second component (0 by default) */
  2460. y: number;
  2461. /** defines the third component (0 by default) */
  2462. z: number;
  2463. /** defines the fourth component (1.0 by default) */
  2464. w: number;
  2465. /**
  2466. * Creates a new Quaternion from the given floats
  2467. * @param x defines the first component (0 by default)
  2468. * @param y defines the second component (0 by default)
  2469. * @param z defines the third component (0 by default)
  2470. * @param w defines the fourth component (1.0 by default)
  2471. */
  2472. constructor(
  2473. /** defines the first component (0 by default) */
  2474. x?: number,
  2475. /** defines the second component (0 by default) */
  2476. y?: number,
  2477. /** defines the third component (0 by default) */
  2478. z?: number,
  2479. /** defines the fourth component (1.0 by default) */
  2480. w?: number);
  2481. /**
  2482. * Gets a string representation for the current quaternion
  2483. * @returns a string with the Quaternion coordinates
  2484. */
  2485. toString(): string;
  2486. /**
  2487. * Gets the class name of the quaternion
  2488. * @returns the string "Quaternion"
  2489. */
  2490. getClassName(): string;
  2491. /**
  2492. * Gets a hash code for this quaternion
  2493. * @returns the quaternion hash code
  2494. */
  2495. getHashCode(): number;
  2496. /**
  2497. * Copy the quaternion to an array
  2498. * @returns a new array populated with 4 elements from the quaternion coordinates
  2499. */
  2500. asArray(): number[];
  2501. /**
  2502. * Check if two quaternions are equals
  2503. * @param otherQuaternion defines the second operand
  2504. * @return true if the current quaternion and the given one coordinates are strictly equals
  2505. */
  2506. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2507. /**
  2508. * Clone the current quaternion
  2509. * @returns a new quaternion copied from the current one
  2510. */
  2511. clone(): Quaternion;
  2512. /**
  2513. * Copy a quaternion to the current one
  2514. * @param other defines the other quaternion
  2515. * @returns the updated current quaternion
  2516. */
  2517. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2518. /**
  2519. * Updates the current quaternion with the given float coordinates
  2520. * @param x defines the x coordinate
  2521. * @param y defines the y coordinate
  2522. * @param z defines the z coordinate
  2523. * @param w defines the w coordinate
  2524. * @returns the updated current quaternion
  2525. */
  2526. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2527. /**
  2528. * Updates the current quaternion from the given float coordinates
  2529. * @param x defines the x coordinate
  2530. * @param y defines the y coordinate
  2531. * @param z defines the z coordinate
  2532. * @param w defines the w coordinate
  2533. * @returns the updated current quaternion
  2534. */
  2535. set(x: number, y: number, z: number, w: number): Quaternion;
  2536. /**
  2537. * Adds two quaternions
  2538. * @param other defines the second operand
  2539. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2540. */
  2541. add(other: DeepImmutable<Quaternion>): Quaternion;
  2542. /**
  2543. * Add a quaternion to the current one
  2544. * @param other defines the quaternion to add
  2545. * @returns the current quaternion
  2546. */
  2547. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2548. /**
  2549. * Subtract two quaternions
  2550. * @param other defines the second operand
  2551. * @returns a new quaternion as the subtraction result of the given one from the current one
  2552. */
  2553. subtract(other: Quaternion): Quaternion;
  2554. /**
  2555. * Multiplies the current quaternion by a scale factor
  2556. * @param value defines the scale factor
  2557. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2558. */
  2559. scale(value: number): Quaternion;
  2560. /**
  2561. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2562. * @param scale defines the scale factor
  2563. * @param result defines the Quaternion object where to store the result
  2564. * @returns the unmodified current quaternion
  2565. */
  2566. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2567. /**
  2568. * Multiplies in place the current quaternion by a scale factor
  2569. * @param value defines the scale factor
  2570. * @returns the current modified quaternion
  2571. */
  2572. scaleInPlace(value: number): Quaternion;
  2573. /**
  2574. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2575. * @param scale defines the scale factor
  2576. * @param result defines the Quaternion object where to store the result
  2577. * @returns the unmodified current quaternion
  2578. */
  2579. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2580. /**
  2581. * Multiplies two quaternions
  2582. * @param q1 defines the second operand
  2583. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2584. */
  2585. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2586. /**
  2587. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2588. * @param q1 defines the second operand
  2589. * @param result defines the target quaternion
  2590. * @returns the current quaternion
  2591. */
  2592. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2593. /**
  2594. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2595. * @param q1 defines the second operand
  2596. * @returns the currentupdated quaternion
  2597. */
  2598. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2599. /**
  2600. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2601. * @param ref defines the target quaternion
  2602. * @returns the current quaternion
  2603. */
  2604. conjugateToRef(ref: Quaternion): Quaternion;
  2605. /**
  2606. * Conjugates in place (1-q) the current quaternion
  2607. * @returns the current updated quaternion
  2608. */
  2609. conjugateInPlace(): Quaternion;
  2610. /**
  2611. * Conjugates in place (1-q) the current quaternion
  2612. * @returns a new quaternion
  2613. */
  2614. conjugate(): Quaternion;
  2615. /**
  2616. * Gets length of current quaternion
  2617. * @returns the quaternion length (float)
  2618. */
  2619. length(): number;
  2620. /**
  2621. * Normalize in place the current quaternion
  2622. * @returns the current updated quaternion
  2623. */
  2624. normalize(): Quaternion;
  2625. /**
  2626. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2627. * @param order is a reserved parameter and is ignore for now
  2628. * @returns a new Vector3 containing the Euler angles
  2629. */
  2630. toEulerAngles(order?: string): Vector3;
  2631. /**
  2632. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2633. * @param result defines the vector which will be filled with the Euler angles
  2634. * @param order is a reserved parameter and is ignore for now
  2635. * @returns the current unchanged quaternion
  2636. */
  2637. toEulerAnglesToRef(result: Vector3): Quaternion;
  2638. /**
  2639. * Updates the given rotation matrix with the current quaternion values
  2640. * @param result defines the target matrix
  2641. * @returns the current unchanged quaternion
  2642. */
  2643. toRotationMatrix(result: Matrix): Quaternion;
  2644. /**
  2645. * Updates the current quaternion from the given rotation matrix values
  2646. * @param matrix defines the source matrix
  2647. * @returns the current updated quaternion
  2648. */
  2649. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2650. /**
  2651. * Creates a new quaternion from a rotation matrix
  2652. * @param matrix defines the source matrix
  2653. * @returns a new quaternion created from the given rotation matrix values
  2654. */
  2655. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2656. /**
  2657. * Updates the given quaternion with the given rotation matrix values
  2658. * @param matrix defines the source matrix
  2659. * @param result defines the target quaternion
  2660. */
  2661. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2662. /**
  2663. * Returns the dot product (float) between the quaternions "left" and "right"
  2664. * @param left defines the left operand
  2665. * @param right defines the right operand
  2666. * @returns the dot product
  2667. */
  2668. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2669. /**
  2670. * Checks if the two quaternions are close to each other
  2671. * @param quat0 defines the first quaternion to check
  2672. * @param quat1 defines the second quaternion to check
  2673. * @returns true if the two quaternions are close to each other
  2674. */
  2675. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2676. /**
  2677. * Creates an empty quaternion
  2678. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2679. */
  2680. static Zero(): Quaternion;
  2681. /**
  2682. * Inverse a given quaternion
  2683. * @param q defines the source quaternion
  2684. * @returns a new quaternion as the inverted current quaternion
  2685. */
  2686. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2687. /**
  2688. * Inverse a given quaternion
  2689. * @param q defines the source quaternion
  2690. * @param result the quaternion the result will be stored in
  2691. * @returns the result quaternion
  2692. */
  2693. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates an identity quaternion
  2696. * @returns the identity quaternion
  2697. */
  2698. static Identity(): Quaternion;
  2699. /**
  2700. * Gets a boolean indicating if the given quaternion is identity
  2701. * @param quaternion defines the quaternion to check
  2702. * @returns true if the quaternion is identity
  2703. */
  2704. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2705. /**
  2706. * Creates a quaternion from a rotation around an axis
  2707. * @param axis defines the axis to use
  2708. * @param angle defines the angle to use
  2709. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2710. */
  2711. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2712. /**
  2713. * Creates a rotation around an axis and stores it into the given quaternion
  2714. * @param axis defines the axis to use
  2715. * @param angle defines the angle to use
  2716. * @param result defines the target quaternion
  2717. * @returns the target quaternion
  2718. */
  2719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2720. /**
  2721. * Creates a new quaternion from data stored into an array
  2722. * @param array defines the data source
  2723. * @param offset defines the offset in the source array where the data starts
  2724. * @returns a new quaternion
  2725. */
  2726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2727. /**
  2728. * Create a quaternion from Euler rotation angles
  2729. * @param x Pitch
  2730. * @param y Yaw
  2731. * @param z Roll
  2732. * @returns the new Quaternion
  2733. */
  2734. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2735. /**
  2736. * Updates a quaternion from Euler rotation angles
  2737. * @param x Pitch
  2738. * @param y Yaw
  2739. * @param z Roll
  2740. * @param result the quaternion to store the result
  2741. * @returns the updated quaternion
  2742. */
  2743. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2744. /**
  2745. * Create a quaternion from Euler rotation vector
  2746. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2747. * @returns the new Quaternion
  2748. */
  2749. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2750. /**
  2751. * Updates a quaternion from Euler rotation vector
  2752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2753. * @param result the quaternion to store the result
  2754. * @returns the updated quaternion
  2755. */
  2756. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2757. /**
  2758. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2759. * @param yaw defines the rotation around Y axis
  2760. * @param pitch defines the rotation around X axis
  2761. * @param roll defines the rotation around Z axis
  2762. * @returns the new quaternion
  2763. */
  2764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2765. /**
  2766. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2767. * @param yaw defines the rotation around Y axis
  2768. * @param pitch defines the rotation around X axis
  2769. * @param roll defines the rotation around Z axis
  2770. * @param result defines the target quaternion
  2771. */
  2772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2773. /**
  2774. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2775. * @param alpha defines the rotation around first axis
  2776. * @param beta defines the rotation around second axis
  2777. * @param gamma defines the rotation around third axis
  2778. * @returns the new quaternion
  2779. */
  2780. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2781. /**
  2782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2783. * @param alpha defines the rotation around first axis
  2784. * @param beta defines the rotation around second axis
  2785. * @param gamma defines the rotation around third axis
  2786. * @param result defines the target quaternion
  2787. */
  2788. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2789. /**
  2790. * 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)
  2791. * @param axis1 defines the first axis
  2792. * @param axis2 defines the second axis
  2793. * @param axis3 defines the third axis
  2794. * @returns the new quaternion
  2795. */
  2796. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2797. /**
  2798. * 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
  2799. * @param axis1 defines the first axis
  2800. * @param axis2 defines the second axis
  2801. * @param axis3 defines the third axis
  2802. * @param ref defines the target quaternion
  2803. */
  2804. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2805. /**
  2806. * Interpolates between two quaternions
  2807. * @param left defines first quaternion
  2808. * @param right defines second quaternion
  2809. * @param amount defines the gradient to use
  2810. * @returns the new interpolated quaternion
  2811. */
  2812. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2813. /**
  2814. * Interpolates between two quaternions and stores it into a target quaternion
  2815. * @param left defines first quaternion
  2816. * @param right defines second quaternion
  2817. * @param amount defines the gradient to use
  2818. * @param result defines the target quaternion
  2819. */
  2820. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2821. /**
  2822. * Interpolate between two quaternions using Hermite interpolation
  2823. * @param value1 defines first quaternion
  2824. * @param tangent1 defines the incoming tangent
  2825. * @param value2 defines second quaternion
  2826. * @param tangent2 defines the outgoing tangent
  2827. * @param amount defines the target quaternion
  2828. * @returns the new interpolated quaternion
  2829. */
  2830. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2831. }
  2832. /**
  2833. * Class used to store matrix data (4x4)
  2834. */
  2835. export class Matrix {
  2836. private static _updateFlagSeed;
  2837. private static _identityReadOnly;
  2838. private _isIdentity;
  2839. private _isIdentityDirty;
  2840. private _isIdentity3x2;
  2841. private _isIdentity3x2Dirty;
  2842. /**
  2843. * Gets the update flag of the matrix which is an unique number for the matrix.
  2844. * It will be incremented every time the matrix data change.
  2845. * You can use it to speed the comparison between two versions of the same matrix.
  2846. */
  2847. updateFlag: number;
  2848. private readonly _m;
  2849. /**
  2850. * Gets the internal data of the matrix
  2851. */
  2852. readonly m: DeepImmutable<Float32Array>;
  2853. /** @hidden */
  2854. _markAsUpdated(): void;
  2855. /** @hidden */
  2856. private _updateIdentityStatus;
  2857. /**
  2858. * Creates an empty matrix (filled with zeros)
  2859. */
  2860. constructor();
  2861. /**
  2862. * Check if the current matrix is identity
  2863. * @returns true is the matrix is the identity matrix
  2864. */
  2865. isIdentity(): boolean;
  2866. /**
  2867. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2868. * @returns true is the matrix is the identity matrix
  2869. */
  2870. isIdentityAs3x2(): boolean;
  2871. /**
  2872. * Gets the determinant of the matrix
  2873. * @returns the matrix determinant
  2874. */
  2875. determinant(): number;
  2876. /**
  2877. * Returns the matrix as a Float32Array
  2878. * @returns the matrix underlying array
  2879. */
  2880. toArray(): DeepImmutable<Float32Array>;
  2881. /**
  2882. * Returns the matrix as a Float32Array
  2883. * @returns the matrix underlying array.
  2884. */
  2885. asArray(): DeepImmutable<Float32Array>;
  2886. /**
  2887. * Inverts the current matrix in place
  2888. * @returns the current inverted matrix
  2889. */
  2890. invert(): Matrix;
  2891. /**
  2892. * Sets all the matrix elements to zero
  2893. * @returns the current matrix
  2894. */
  2895. reset(): Matrix;
  2896. /**
  2897. * Adds the current matrix with a second one
  2898. * @param other defines the matrix to add
  2899. * @returns a new matrix as the addition of the current matrix and the given one
  2900. */
  2901. add(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2904. * @param other defines the matrix to add
  2905. * @param result defines the target matrix
  2906. * @returns the current matrix
  2907. */
  2908. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Adds in place the given matrix to the current matrix
  2911. * @param other defines the second operand
  2912. * @returns the current updated matrix
  2913. */
  2914. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2915. /**
  2916. * Sets the given matrix to the current inverted Matrix
  2917. * @param other defines the target matrix
  2918. * @returns the unmodified current matrix
  2919. */
  2920. invertToRef(other: Matrix): Matrix;
  2921. /**
  2922. * add a value at the specified position in the current Matrix
  2923. * @param index the index of the value within the matrix. between 0 and 15.
  2924. * @param value the value to be added
  2925. * @returns the current updated matrix
  2926. */
  2927. addAtIndex(index: number, value: number): Matrix;
  2928. /**
  2929. * mutiply the specified position in the current Matrix by a value
  2930. * @param index the index of the value within the matrix. between 0 and 15.
  2931. * @param value the value to be added
  2932. * @returns the current updated matrix
  2933. */
  2934. multiplyAtIndex(index: number, value: number): Matrix;
  2935. /**
  2936. * Inserts the translation vector (using 3 floats) in the current matrix
  2937. * @param x defines the 1st component of the translation
  2938. * @param y defines the 2nd component of the translation
  2939. * @param z defines the 3rd component of the translation
  2940. * @returns the current updated matrix
  2941. */
  2942. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2943. /**
  2944. * Adds the translation vector (using 3 floats) in the current matrix
  2945. * @param x defines the 1st component of the translation
  2946. * @param y defines the 2nd component of the translation
  2947. * @param z defines the 3rd component of the translation
  2948. * @returns the current updated matrix
  2949. */
  2950. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2951. /**
  2952. * Inserts the translation vector in the current matrix
  2953. * @param vector3 defines the translation to insert
  2954. * @returns the current updated matrix
  2955. */
  2956. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2957. /**
  2958. * Gets the translation value of the current matrix
  2959. * @returns a new Vector3 as the extracted translation from the matrix
  2960. */
  2961. getTranslation(): Vector3;
  2962. /**
  2963. * Fill a Vector3 with the extracted translation from the matrix
  2964. * @param result defines the Vector3 where to store the translation
  2965. * @returns the current matrix
  2966. */
  2967. getTranslationToRef(result: Vector3): Matrix;
  2968. /**
  2969. * Remove rotation and scaling part from the matrix
  2970. * @returns the updated matrix
  2971. */
  2972. removeRotationAndScaling(): Matrix;
  2973. /**
  2974. * Multiply two matrices
  2975. * @param other defines the second operand
  2976. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2977. */
  2978. multiply(other: DeepImmutable<Matrix>): Matrix;
  2979. /**
  2980. * Copy the current matrix from the given one
  2981. * @param other defines the source matrix
  2982. * @returns the current updated matrix
  2983. */
  2984. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2985. /**
  2986. * Populates the given array from the starting index with the current matrix values
  2987. * @param array defines the target array
  2988. * @param offset defines the offset in the target array where to start storing values
  2989. * @returns the current matrix
  2990. */
  2991. copyToArray(array: Float32Array, offset?: number): Matrix;
  2992. /**
  2993. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2994. * @param other defines the second operand
  2995. * @param result defines the matrix where to store the multiplication
  2996. * @returns the current matrix
  2997. */
  2998. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2999. /**
  3000. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3001. * @param other defines the second operand
  3002. * @param result defines the array where to store the multiplication
  3003. * @param offset defines the offset in the target array where to start storing values
  3004. * @returns the current matrix
  3005. */
  3006. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3007. /**
  3008. * Check equality between this matrix and a second one
  3009. * @param value defines the second matrix to compare
  3010. * @returns true is the current matrix and the given one values are strictly equal
  3011. */
  3012. equals(value: DeepImmutable<Matrix>): boolean;
  3013. /**
  3014. * Clone the current matrix
  3015. * @returns a new matrix from the current matrix
  3016. */
  3017. clone(): Matrix;
  3018. /**
  3019. * Returns the name of the current matrix class
  3020. * @returns the string "Matrix"
  3021. */
  3022. getClassName(): string;
  3023. /**
  3024. * Gets the hash code of the current matrix
  3025. * @returns the hash code
  3026. */
  3027. getHashCode(): number;
  3028. /**
  3029. * Decomposes the current Matrix into a translation, rotation and scaling components
  3030. * @param scale defines the scale vector3 given as a reference to update
  3031. * @param rotation defines the rotation quaternion given as a reference to update
  3032. * @param translation defines the translation vector3 given as a reference to update
  3033. * @returns true if operation was successful
  3034. */
  3035. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3036. /**
  3037. * Gets specific row of the matrix
  3038. * @param index defines the number of the row to get
  3039. * @returns the index-th row of the current matrix as a new Vector4
  3040. */
  3041. getRow(index: number): Nullable<Vector4>;
  3042. /**
  3043. * Sets the index-th row of the current matrix to the vector4 values
  3044. * @param index defines the number of the row to set
  3045. * @param row defines the target vector4
  3046. * @returns the updated current matrix
  3047. */
  3048. setRow(index: number, row: Vector4): Matrix;
  3049. /**
  3050. * Compute the transpose of the matrix
  3051. * @returns the new transposed matrix
  3052. */
  3053. transpose(): Matrix;
  3054. /**
  3055. * Compute the transpose of the matrix and store it in a given matrix
  3056. * @param result defines the target matrix
  3057. * @returns the current matrix
  3058. */
  3059. transposeToRef(result: Matrix): Matrix;
  3060. /**
  3061. * Sets the index-th row of the current matrix with the given 4 x float values
  3062. * @param index defines the row index
  3063. * @param x defines the x component to set
  3064. * @param y defines the y component to set
  3065. * @param z defines the z component to set
  3066. * @param w defines the w component to set
  3067. * @returns the updated current matrix
  3068. */
  3069. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3070. /**
  3071. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3072. * @param scale defines the scale factor
  3073. * @returns a new matrix
  3074. */
  3075. scale(scale: number): Matrix;
  3076. /**
  3077. * Scale the current matrix values by a factor to a given result matrix
  3078. * @param scale defines the scale factor
  3079. * @param result defines the matrix to store the result
  3080. * @returns the current matrix
  3081. */
  3082. scaleToRef(scale: number, result: Matrix): Matrix;
  3083. /**
  3084. * Scale the current matrix values by a factor and add the result to a given matrix
  3085. * @param scale defines the scale factor
  3086. * @param result defines the Matrix to store the result
  3087. * @returns the current matrix
  3088. */
  3089. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3090. /**
  3091. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3092. * @param ref matrix to store the result
  3093. */
  3094. toNormalMatrix(ref: Matrix): void;
  3095. /**
  3096. * Gets only rotation part of the current matrix
  3097. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3098. */
  3099. getRotationMatrix(): Matrix;
  3100. /**
  3101. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3102. * @param result defines the target matrix to store data to
  3103. * @returns the current matrix
  3104. */
  3105. getRotationMatrixToRef(result: Matrix): Matrix;
  3106. /**
  3107. * Toggles model matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleModelMatrixHandInPlace(): void;
  3110. /**
  3111. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3112. */
  3113. toggleProjectionMatrixHandInPlace(): void;
  3114. /**
  3115. * Creates a matrix from an array
  3116. * @param array defines the source array
  3117. * @param offset defines an offset in the source array
  3118. * @returns a new Matrix set from the starting index of the given array
  3119. */
  3120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3121. /**
  3122. * Copy the content of an array into a given matrix
  3123. * @param array defines the source array
  3124. * @param offset defines an offset in the source array
  3125. * @param result defines the target matrix
  3126. */
  3127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3128. /**
  3129. * Stores an array into a matrix after having multiplied each component by a given factor
  3130. * @param array defines the source array
  3131. * @param offset defines the offset in the source array
  3132. * @param scale defines the scaling factor
  3133. * @param result defines the target matrix
  3134. */
  3135. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3136. /**
  3137. * Gets an identity matrix that must not be updated
  3138. */
  3139. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3140. /**
  3141. * Stores a list of values (16) inside a given matrix
  3142. * @param initialM11 defines 1st value of 1st row
  3143. * @param initialM12 defines 2nd value of 1st row
  3144. * @param initialM13 defines 3rd value of 1st row
  3145. * @param initialM14 defines 4th value of 1st row
  3146. * @param initialM21 defines 1st value of 2nd row
  3147. * @param initialM22 defines 2nd value of 2nd row
  3148. * @param initialM23 defines 3rd value of 2nd row
  3149. * @param initialM24 defines 4th value of 2nd row
  3150. * @param initialM31 defines 1st value of 3rd row
  3151. * @param initialM32 defines 2nd value of 3rd row
  3152. * @param initialM33 defines 3rd value of 3rd row
  3153. * @param initialM34 defines 4th value of 3rd row
  3154. * @param initialM41 defines 1st value of 4th row
  3155. * @param initialM42 defines 2nd value of 4th row
  3156. * @param initialM43 defines 3rd value of 4th row
  3157. * @param initialM44 defines 4th value of 4th row
  3158. * @param result defines the target matrix
  3159. */
  3160. 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;
  3161. /**
  3162. * Creates new matrix from a list of values (16)
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @returns the new matrix
  3180. */
  3181. 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;
  3182. /**
  3183. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3184. * @param scale defines the scale vector3
  3185. * @param rotation defines the rotation quaternion
  3186. * @param translation defines the translation vector3
  3187. * @returns a new matrix
  3188. */
  3189. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3190. /**
  3191. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3192. * @param scale defines the scale vector3
  3193. * @param rotation defines the rotation quaternion
  3194. * @param translation defines the translation vector3
  3195. * @param result defines the target matrix
  3196. */
  3197. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3198. /**
  3199. * Creates a new identity matrix
  3200. * @returns a new identity matrix
  3201. */
  3202. static Identity(): Matrix;
  3203. /**
  3204. * Creates a new identity matrix and stores the result in a given matrix
  3205. * @param result defines the target matrix
  3206. */
  3207. static IdentityToRef(result: Matrix): void;
  3208. /**
  3209. * Creates a new zero matrix
  3210. * @returns a new zero matrix
  3211. */
  3212. static Zero(): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis
  3215. * @param angle defines the angle (in radians) to use
  3216. * @return the new matrix
  3217. */
  3218. static RotationX(angle: number): Matrix;
  3219. /**
  3220. * Creates a new matrix as the invert of a given matrix
  3221. * @param source defines the source matrix
  3222. * @returns the new matrix
  3223. */
  3224. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationXToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Y axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationY(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationYToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the Z axis
  3245. * @param angle defines the angle (in radians) to use
  3246. * @return the new matrix
  3247. */
  3248. static RotationZ(angle: number): Matrix;
  3249. /**
  3250. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3251. * @param angle defines the angle (in radians) to use
  3252. * @param result defines the target matrix
  3253. */
  3254. static RotationZToRef(angle: number, result: Matrix): void;
  3255. /**
  3256. * Creates a new rotation matrix for "angle" radians around the given axis
  3257. * @param axis defines the axis to use
  3258. * @param angle defines the angle (in radians) to use
  3259. * @return the new matrix
  3260. */
  3261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3264. * @param axis defines the axis to use
  3265. * @param angle defines the angle (in radians) to use
  3266. * @param result defines the target matrix
  3267. */
  3268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3269. /**
  3270. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3271. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3272. * @param from defines the vector to align
  3273. * @param to defines the vector to align to
  3274. * @param result defines the target matrix
  3275. */
  3276. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3277. /**
  3278. * Creates a rotation matrix
  3279. * @param yaw defines the yaw angle in radians (Y axis)
  3280. * @param pitch defines the pitch angle in radians (X axis)
  3281. * @param roll defines the roll angle in radians (X axis)
  3282. * @returns the new rotation matrix
  3283. */
  3284. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3285. /**
  3286. * Creates a rotation matrix and stores it in a given matrix
  3287. * @param yaw defines the yaw angle in radians (Y axis)
  3288. * @param pitch defines the pitch angle in radians (X axis)
  3289. * @param roll defines the roll angle in radians (X axis)
  3290. * @param result defines the target matrix
  3291. */
  3292. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3293. /**
  3294. * Creates a scaling matrix
  3295. * @param x defines the scale factor on X axis
  3296. * @param y defines the scale factor on Y axis
  3297. * @param z defines the scale factor on Z axis
  3298. * @returns the new matrix
  3299. */
  3300. static Scaling(x: number, y: number, z: number): Matrix;
  3301. /**
  3302. * Creates a scaling matrix and stores it in a given matrix
  3303. * @param x defines the scale factor on X axis
  3304. * @param y defines the scale factor on Y axis
  3305. * @param z defines the scale factor on Z axis
  3306. * @param result defines the target matrix
  3307. */
  3308. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3309. /**
  3310. * Creates a translation matrix
  3311. * @param x defines the translation on X axis
  3312. * @param y defines the translation on Y axis
  3313. * @param z defines the translationon Z axis
  3314. * @returns the new matrix
  3315. */
  3316. static Translation(x: number, y: number, z: number): Matrix;
  3317. /**
  3318. * Creates a translation matrix and stores it in a given matrix
  3319. * @param x defines the translation on X axis
  3320. * @param y defines the translation on Y axis
  3321. * @param z defines the translationon Z axis
  3322. * @param result defines the target matrix
  3323. */
  3324. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3325. /**
  3326. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3327. * @param startValue defines the start value
  3328. * @param endValue defines the end value
  3329. * @param gradient defines the gradient factor
  3330. * @returns the new matrix
  3331. */
  3332. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3333. /**
  3334. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3335. * @param startValue defines the start value
  3336. * @param endValue defines the end value
  3337. * @param gradient defines the gradient factor
  3338. * @param result defines the Matrix object where to store data
  3339. */
  3340. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3341. /**
  3342. * Builds a new matrix whose values are computed by:
  3343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3346. * @param startValue defines the first matrix
  3347. * @param endValue defines the second matrix
  3348. * @param gradient defines the gradient between the two matrices
  3349. * @returns the new matrix
  3350. */
  3351. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Update a matrix to values which are computed by:
  3354. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3355. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3356. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3357. * @param startValue defines the first matrix
  3358. * @param endValue defines the second matrix
  3359. * @param gradient defines the gradient between the two matrices
  3360. * @param result defines the target matrix
  3361. */
  3362. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3363. /**
  3364. * 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"
  3365. * This function works in left handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * 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".
  3374. * This function works in left handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * 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"
  3383. * This function works in right handed mode
  3384. * @param eye defines the final position of the entity
  3385. * @param target defines where the entity should look at
  3386. * @param up defines the up vector for the entity
  3387. * @returns the new matrix
  3388. */
  3389. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3390. /**
  3391. * 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".
  3392. * This function works in right handed mode
  3393. * @param eye defines the final position of the entity
  3394. * @param target defines where the entity should look at
  3395. * @param up defines the up vector for the entity
  3396. * @param result defines the target matrix
  3397. */
  3398. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param width defines the viewport width
  3402. * @param height defines the viewport height
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Store a left-handed orthographic projection to a given matrix
  3410. * @param width defines the viewport width
  3411. * @param height defines the viewport height
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. */
  3416. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3417. /**
  3418. * Create a left-handed orthographic projection matrix
  3419. * @param left defines the viewport left coordinate
  3420. * @param right defines the viewport right coordinate
  3421. * @param bottom defines the viewport bottom coordinate
  3422. * @param top defines the viewport top coordinate
  3423. * @param znear defines the near clip plane
  3424. * @param zfar defines the far clip plane
  3425. * @returns a new matrix as a left-handed orthographic projection matrix
  3426. */
  3427. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3428. /**
  3429. * Stores a left-handed orthographic projection into a given matrix
  3430. * @param left defines the viewport left coordinate
  3431. * @param right defines the viewport right coordinate
  3432. * @param bottom defines the viewport bottom coordinate
  3433. * @param top defines the viewport top coordinate
  3434. * @param znear defines the near clip plane
  3435. * @param zfar defines the far clip plane
  3436. * @param result defines the target matrix
  3437. */
  3438. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3439. /**
  3440. * Creates a right-handed orthographic projection matrix
  3441. * @param left defines the viewport left coordinate
  3442. * @param right defines the viewport right coordinate
  3443. * @param bottom defines the viewport bottom coordinate
  3444. * @param top defines the viewport top coordinate
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a right-handed orthographic projection matrix
  3448. */
  3449. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Stores a right-handed orthographic projection into a given matrix
  3452. * @param left defines the viewport left coordinate
  3453. * @param right defines the viewport right coordinate
  3454. * @param bottom defines the viewport bottom coordinate
  3455. * @param top defines the viewport top coordinate
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @param result defines the target matrix
  3459. */
  3460. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3461. /**
  3462. * Creates a left-handed perspective projection matrix
  3463. * @param width defines the viewport width
  3464. * @param height defines the viewport height
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @returns a new matrix as a left-handed perspective projection matrix
  3468. */
  3469. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3470. /**
  3471. * Creates a left-handed perspective projection matrix
  3472. * @param fov defines the horizontal field of view
  3473. * @param aspect defines the aspect ratio
  3474. * @param znear defines the near clip plane
  3475. * @param zfar defines the far clip plane
  3476. * @returns a new matrix as a left-handed perspective projection matrix
  3477. */
  3478. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3479. /**
  3480. * Stores a left-handed perspective projection into a given matrix
  3481. * @param fov defines the horizontal field of view
  3482. * @param aspect defines the aspect ratio
  3483. * @param znear defines the near clip plane
  3484. * @param zfar defines the far clip plane
  3485. * @param result defines the target matrix
  3486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3487. */
  3488. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3489. /**
  3490. * Creates a right-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a right-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a right-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Stores a perspective projection for WebVR info a given matrix
  3510. * @param fov defines the field of view
  3511. * @param znear defines the near clip plane
  3512. * @param zfar defines the far clip plane
  3513. * @param result defines the target matrix
  3514. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3515. */
  3516. static PerspectiveFovWebVRToRef(fov: {
  3517. upDegrees: number;
  3518. downDegrees: number;
  3519. leftDegrees: number;
  3520. rightDegrees: number;
  3521. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3522. /**
  3523. * Computes a complete transformation matrix
  3524. * @param viewport defines the viewport to use
  3525. * @param world defines the world matrix
  3526. * @param view defines the view matrix
  3527. * @param projection defines the projection matrix
  3528. * @param zmin defines the near clip plane
  3529. * @param zmax defines the far clip plane
  3530. * @returns the transformation matrix
  3531. */
  3532. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3533. /**
  3534. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3535. * @param matrix defines the matrix to use
  3536. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3537. */
  3538. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3539. /**
  3540. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3541. * @param matrix defines the matrix to use
  3542. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3543. */
  3544. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3545. /**
  3546. * Compute the transpose of a given matrix
  3547. * @param matrix defines the matrix to transpose
  3548. * @returns the new matrix
  3549. */
  3550. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3551. /**
  3552. * Compute the transpose of a matrix and store it in a target matrix
  3553. * @param matrix defines the matrix to transpose
  3554. * @param result defines the target matrix
  3555. */
  3556. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3557. /**
  3558. * Computes a reflection matrix from a plane
  3559. * @param plane defines the reflection plane
  3560. * @returns a new matrix
  3561. */
  3562. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3563. /**
  3564. * Computes a reflection matrix from a plane
  3565. * @param plane defines the reflection plane
  3566. * @param result defines the target matrix
  3567. */
  3568. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3569. /**
  3570. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3571. * @param xaxis defines the value of the 1st axis
  3572. * @param yaxis defines the value of the 2nd axis
  3573. * @param zaxis defines the value of the 3rd axis
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3577. /**
  3578. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3579. * @param quat defines the quaternion to use
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3583. }
  3584. /**
  3585. * Represens a plane by the equation ax + by + cz + d = 0
  3586. */
  3587. export class Plane {
  3588. /**
  3589. * Normal of the plane (a,b,c)
  3590. */
  3591. normal: Vector3;
  3592. /**
  3593. * d component of the plane
  3594. */
  3595. d: number;
  3596. /**
  3597. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3598. * @param a a component of the plane
  3599. * @param b b component of the plane
  3600. * @param c c component of the plane
  3601. * @param d d component of the plane
  3602. */
  3603. constructor(a: number, b: number, c: number, d: number);
  3604. /**
  3605. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3606. */
  3607. asArray(): number[];
  3608. /**
  3609. * @returns a new plane copied from the current Plane.
  3610. */
  3611. clone(): Plane;
  3612. /**
  3613. * @returns the string "Plane".
  3614. */
  3615. getClassName(): string;
  3616. /**
  3617. * @returns the Plane hash code.
  3618. */
  3619. getHashCode(): number;
  3620. /**
  3621. * Normalize the current Plane in place.
  3622. * @returns the updated Plane.
  3623. */
  3624. normalize(): Plane;
  3625. /**
  3626. * Applies a transformation the plane and returns the result
  3627. * @param transformation the transformation matrix to be applied to the plane
  3628. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3629. */
  3630. transform(transformation: DeepImmutable<Matrix>): Plane;
  3631. /**
  3632. * Calcualtte the dot product between the point and the plane normal
  3633. * @param point point to calculate the dot product with
  3634. * @returns the dot product (float) of the point coordinates and the plane normal.
  3635. */
  3636. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3637. /**
  3638. * Updates the current Plane from the plane defined by the three given points.
  3639. * @param point1 one of the points used to contruct the plane
  3640. * @param point2 one of the points used to contruct the plane
  3641. * @param point3 one of the points used to contruct the plane
  3642. * @returns the updated Plane.
  3643. */
  3644. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3645. /**
  3646. * Checks if the plane is facing a given direction
  3647. * @param direction the direction to check if the plane is facing
  3648. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3649. * @returns True is the vector "direction" is the same side than the plane normal.
  3650. */
  3651. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3652. /**
  3653. * Calculates the distance to a point
  3654. * @param point point to calculate distance to
  3655. * @returns the signed distance (float) from the given point to the Plane.
  3656. */
  3657. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Creates a plane from an array
  3660. * @param array the array to create a plane from
  3661. * @returns a new Plane from the given array.
  3662. */
  3663. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3664. /**
  3665. * Creates a plane from three points
  3666. * @param point1 point used to create the plane
  3667. * @param point2 point used to create the plane
  3668. * @param point3 point used to create the plane
  3669. * @returns a new Plane defined by the three given points.
  3670. */
  3671. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3672. /**
  3673. * Creates a plane from an origin point and a normal
  3674. * @param origin origin of the plane to be constructed
  3675. * @param normal normal of the plane to be constructed
  3676. * @returns a new Plane the normal vector to this plane at the given origin point.
  3677. * Note : the vector "normal" is updated because normalized.
  3678. */
  3679. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3680. /**
  3681. * Calculates the distance from a plane and a point
  3682. * @param origin origin of the plane to be constructed
  3683. * @param normal normal of the plane to be constructed
  3684. * @param point point to calculate distance to
  3685. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3686. */
  3687. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3688. }
  3689. /**
  3690. * Class used to represent a viewport on screen
  3691. */
  3692. export class Viewport {
  3693. /** viewport left coordinate */
  3694. x: number;
  3695. /** viewport top coordinate */
  3696. y: number;
  3697. /**viewport width */
  3698. width: number;
  3699. /** viewport height */
  3700. height: number;
  3701. /**
  3702. * Creates a Viewport object located at (x, y) and sized (width, height)
  3703. * @param x defines viewport left coordinate
  3704. * @param y defines viewport top coordinate
  3705. * @param width defines the viewport width
  3706. * @param height defines the viewport height
  3707. */
  3708. constructor(
  3709. /** viewport left coordinate */
  3710. x: number,
  3711. /** viewport top coordinate */
  3712. y: number,
  3713. /**viewport width */
  3714. width: number,
  3715. /** viewport height */
  3716. height: number);
  3717. /**
  3718. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3719. * @param renderWidth defines the rendering width
  3720. * @param renderHeight defines the rendering height
  3721. * @returns a new Viewport
  3722. */
  3723. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3724. /**
  3725. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3726. * @param renderWidth defines the rendering width
  3727. * @param renderHeight defines the rendering height
  3728. * @param ref defines the target viewport
  3729. * @returns the current viewport
  3730. */
  3731. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3732. /**
  3733. * Returns a new Viewport copied from the current one
  3734. * @returns a new Viewport
  3735. */
  3736. clone(): Viewport;
  3737. }
  3738. /**
  3739. * Reprasents a camera frustum
  3740. */
  3741. export class Frustum {
  3742. /**
  3743. * Gets the planes representing the frustum
  3744. * @param transform matrix to be applied to the returned planes
  3745. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3746. */
  3747. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3748. /**
  3749. * Gets the near frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the far frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the left frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Gets the right frustum plane transformed by the transform matrix
  3768. * @param transform transformation matrix to be applied to the resulting frustum plane
  3769. * @param frustumPlane the resuling frustum plane
  3770. */
  3771. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3772. /**
  3773. * Gets the top frustum plane transformed by the transform matrix
  3774. * @param transform transformation matrix to be applied to the resulting frustum plane
  3775. * @param frustumPlane the resuling frustum plane
  3776. */
  3777. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3778. /**
  3779. * Gets the bottom frustum plane transformed by the transform matrix
  3780. * @param transform transformation matrix to be applied to the resulting frustum plane
  3781. * @param frustumPlane the resuling frustum plane
  3782. */
  3783. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3784. /**
  3785. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3786. * @param transform transformation matrix to be applied to the resulting frustum planes
  3787. * @param frustumPlanes the resuling frustum planes
  3788. */
  3789. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3790. }
  3791. /** Defines supported spaces */
  3792. export enum Space {
  3793. /** Local (object) space */
  3794. LOCAL = 0,
  3795. /** World space */
  3796. WORLD = 1,
  3797. /** Bone space */
  3798. BONE = 2
  3799. }
  3800. /** Defines the 3 main axes */
  3801. export class Axis {
  3802. /** X axis */
  3803. static X: Vector3;
  3804. /** Y axis */
  3805. static Y: Vector3;
  3806. /** Z axis */
  3807. static Z: Vector3;
  3808. }
  3809. /** Class used to represent a Bezier curve */
  3810. export class BezierCurve {
  3811. /**
  3812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3813. * @param t defines the time
  3814. * @param x1 defines the left coordinate on X axis
  3815. * @param y1 defines the left coordinate on Y axis
  3816. * @param x2 defines the right coordinate on X axis
  3817. * @param y2 defines the right coordinate on Y axis
  3818. * @returns the interpolated value
  3819. */
  3820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3821. }
  3822. /**
  3823. * Defines potential orientation for back face culling
  3824. */
  3825. export enum Orientation {
  3826. /**
  3827. * Clockwise
  3828. */
  3829. CW = 0,
  3830. /** Counter clockwise */
  3831. CCW = 1
  3832. }
  3833. /**
  3834. * Defines angle representation
  3835. */
  3836. export class Angle {
  3837. private _radians;
  3838. /**
  3839. * Creates an Angle object of "radians" radians (float).
  3840. * @param radians the angle in radians
  3841. */
  3842. constructor(radians: number);
  3843. /**
  3844. * Get value in degrees
  3845. * @returns the Angle value in degrees (float)
  3846. */
  3847. degrees(): number;
  3848. /**
  3849. * Get value in radians
  3850. * @returns the Angle value in radians (float)
  3851. */
  3852. radians(): number;
  3853. /**
  3854. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3855. * @param a defines first vector
  3856. * @param b defines second vector
  3857. * @returns a new Angle
  3858. */
  3859. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3860. /**
  3861. * Gets a new Angle object from the given float in radians
  3862. * @param radians defines the angle value in radians
  3863. * @returns a new Angle
  3864. */
  3865. static FromRadians(radians: number): Angle;
  3866. /**
  3867. * Gets a new Angle object from the given float in degrees
  3868. * @param degrees defines the angle value in degrees
  3869. * @returns a new Angle
  3870. */
  3871. static FromDegrees(degrees: number): Angle;
  3872. }
  3873. /**
  3874. * This represents an arc in a 2d space.
  3875. */
  3876. export class Arc2 {
  3877. /** Defines the start point of the arc */
  3878. startPoint: Vector2;
  3879. /** Defines the mid point of the arc */
  3880. midPoint: Vector2;
  3881. /** Defines the end point of the arc */
  3882. endPoint: Vector2;
  3883. /**
  3884. * Defines the center point of the arc.
  3885. */
  3886. centerPoint: Vector2;
  3887. /**
  3888. * Defines the radius of the arc.
  3889. */
  3890. radius: number;
  3891. /**
  3892. * Defines the angle of the arc (from mid point to end point).
  3893. */
  3894. angle: Angle;
  3895. /**
  3896. * Defines the start angle of the arc (from start point to middle point).
  3897. */
  3898. startAngle: Angle;
  3899. /**
  3900. * Defines the orientation of the arc (clock wise/counter clock wise).
  3901. */
  3902. orientation: Orientation;
  3903. /**
  3904. * Creates an Arc object from the three given points : start, middle and end.
  3905. * @param startPoint Defines the start point of the arc
  3906. * @param midPoint Defines the midlle point of the arc
  3907. * @param endPoint Defines the end point of the arc
  3908. */
  3909. constructor(
  3910. /** Defines the start point of the arc */
  3911. startPoint: Vector2,
  3912. /** Defines the mid point of the arc */
  3913. midPoint: Vector2,
  3914. /** Defines the end point of the arc */
  3915. endPoint: Vector2);
  3916. }
  3917. /**
  3918. * Represents a 2D path made up of multiple 2D points
  3919. */
  3920. export class Path2 {
  3921. private _points;
  3922. private _length;
  3923. /**
  3924. * If the path start and end point are the same
  3925. */
  3926. closed: boolean;
  3927. /**
  3928. * Creates a Path2 object from the starting 2D coordinates x and y.
  3929. * @param x the starting points x value
  3930. * @param y the starting points y value
  3931. */
  3932. constructor(x: number, y: number);
  3933. /**
  3934. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3935. * @param x the added points x value
  3936. * @param y the added points y value
  3937. * @returns the updated Path2.
  3938. */
  3939. addLineTo(x: number, y: number): Path2;
  3940. /**
  3941. * 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.
  3942. * @param midX middle point x value
  3943. * @param midY middle point y value
  3944. * @param endX end point x value
  3945. * @param endY end point y value
  3946. * @param numberOfSegments (default: 36)
  3947. * @returns the updated Path2.
  3948. */
  3949. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3950. /**
  3951. * Closes the Path2.
  3952. * @returns the Path2.
  3953. */
  3954. close(): Path2;
  3955. /**
  3956. * Gets the sum of the distance between each sequential point in the path
  3957. * @returns the Path2 total length (float).
  3958. */
  3959. length(): number;
  3960. /**
  3961. * Gets the points which construct the path
  3962. * @returns the Path2 internal array of points.
  3963. */
  3964. getPoints(): Vector2[];
  3965. /**
  3966. * Retreives the point at the distance aways from the starting point
  3967. * @param normalizedLengthPosition the length along the path to retreive the point from
  3968. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3969. */
  3970. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3971. /**
  3972. * Creates a new path starting from an x and y position
  3973. * @param x starting x value
  3974. * @param y starting y value
  3975. * @returns a new Path2 starting at the coordinates (x, y).
  3976. */
  3977. static StartingAt(x: number, y: number): Path2;
  3978. }
  3979. /**
  3980. * Represents a 3D path made up of multiple 3D points
  3981. */
  3982. export class Path3D {
  3983. /**
  3984. * an array of Vector3, the curve axis of the Path3D
  3985. */
  3986. path: Vector3[];
  3987. private _curve;
  3988. private _distances;
  3989. private _tangents;
  3990. private _normals;
  3991. private _binormals;
  3992. private _raw;
  3993. /**
  3994. * new Path3D(path, normal, raw)
  3995. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3996. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3997. * @param path an array of Vector3, the curve axis of the Path3D
  3998. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3999. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4000. */
  4001. constructor(
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4006. /**
  4007. * Returns the Path3D array of successive Vector3 designing its curve.
  4008. * @returns the Path3D array of successive Vector3 designing its curve.
  4009. */
  4010. getCurve(): Vector3[];
  4011. /**
  4012. * Returns an array populated with tangent vectors on each Path3D curve point.
  4013. * @returns an array populated with tangent vectors on each Path3D curve point.
  4014. */
  4015. getTangents(): Vector3[];
  4016. /**
  4017. * Returns an array populated with normal vectors on each Path3D curve point.
  4018. * @returns an array populated with normal vectors on each Path3D curve point.
  4019. */
  4020. getNormals(): Vector3[];
  4021. /**
  4022. * Returns an array populated with binormal vectors on each Path3D curve point.
  4023. * @returns an array populated with binormal vectors on each Path3D curve point.
  4024. */
  4025. getBinormals(): Vector3[];
  4026. /**
  4027. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4028. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4029. */
  4030. getDistances(): number[];
  4031. /**
  4032. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4033. * @param path path which all values are copied into the curves points
  4034. * @param firstNormal which should be projected onto the curve
  4035. * @returns the same object updated.
  4036. */
  4037. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4038. private _compute;
  4039. private _getFirstNonNullVector;
  4040. private _getLastNonNullVector;
  4041. private _normalVector;
  4042. }
  4043. /**
  4044. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4045. * A Curve3 is designed from a series of successive Vector3.
  4046. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4047. */
  4048. export class Curve3 {
  4049. private _points;
  4050. private _length;
  4051. /**
  4052. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4054. * @param v1 (Vector3) the control point
  4055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4062. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4063. * @param v1 (Vector3) the first control point
  4064. * @param v2 (Vector3) the second control point
  4065. * @param v3 (Vector3) the end point of the Cubic Bezier
  4066. * @param nbPoints (integer) the wanted number of points in the curve
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4070. /**
  4071. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4072. * @param p1 (Vector3) the origin point of the Hermite Spline
  4073. * @param t1 (Vector3) the tangent vector at the origin point
  4074. * @param p2 (Vector3) the end point of the Hermite Spline
  4075. * @param t2 (Vector3) the tangent vector at the end point
  4076. * @param nbPoints (integer) the wanted number of points in the curve
  4077. * @returns the created Curve3
  4078. */
  4079. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4080. /**
  4081. * Returns a Curve3 object along a CatmullRom Spline curve :
  4082. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4083. * @param nbPoints (integer) the wanted number of points between each curve control points
  4084. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4085. * @returns the created Curve3
  4086. */
  4087. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4088. /**
  4089. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4090. * A Curve3 is designed from a series of successive Vector3.
  4091. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4092. * @param points points which make up the curve
  4093. */
  4094. constructor(points: Vector3[]);
  4095. /**
  4096. * @returns the Curve3 stored array of successive Vector3
  4097. */
  4098. getPoints(): Vector3[];
  4099. /**
  4100. * @returns the computed length (float) of the curve.
  4101. */
  4102. length(): number;
  4103. /**
  4104. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4105. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4106. * curveA and curveB keep unchanged.
  4107. * @param curve the curve to continue from this curve
  4108. * @returns the newly constructed curve
  4109. */
  4110. continue(curve: DeepImmutable<Curve3>): Curve3;
  4111. private _computeLength;
  4112. }
  4113. /**
  4114. * Contains position and normal vectors for a vertex
  4115. */
  4116. export class PositionNormalVertex {
  4117. /** the position of the vertex (defaut: 0,0,0) */
  4118. position: Vector3;
  4119. /** the normal of the vertex (defaut: 0,1,0) */
  4120. normal: Vector3;
  4121. /**
  4122. * Creates a PositionNormalVertex
  4123. * @param position the position of the vertex (defaut: 0,0,0)
  4124. * @param normal the normal of the vertex (defaut: 0,1,0)
  4125. */
  4126. constructor(
  4127. /** the position of the vertex (defaut: 0,0,0) */
  4128. position?: Vector3,
  4129. /** the normal of the vertex (defaut: 0,1,0) */
  4130. normal?: Vector3);
  4131. /**
  4132. * Clones the PositionNormalVertex
  4133. * @returns the cloned PositionNormalVertex
  4134. */
  4135. clone(): PositionNormalVertex;
  4136. }
  4137. /**
  4138. * Contains position, normal and uv vectors for a vertex
  4139. */
  4140. export class PositionNormalTextureVertex {
  4141. /** the position of the vertex (defaut: 0,0,0) */
  4142. position: Vector3;
  4143. /** the normal of the vertex (defaut: 0,1,0) */
  4144. normal: Vector3;
  4145. /** the uv of the vertex (default: 0,0) */
  4146. uv: Vector2;
  4147. /**
  4148. * Creates a PositionNormalTextureVertex
  4149. * @param position the position of the vertex (defaut: 0,0,0)
  4150. * @param normal the normal of the vertex (defaut: 0,1,0)
  4151. * @param uv the uv of the vertex (default: 0,0)
  4152. */
  4153. constructor(
  4154. /** the position of the vertex (defaut: 0,0,0) */
  4155. position?: Vector3,
  4156. /** the normal of the vertex (defaut: 0,1,0) */
  4157. normal?: Vector3,
  4158. /** the uv of the vertex (default: 0,0) */
  4159. uv?: Vector2);
  4160. /**
  4161. * Clones the PositionNormalTextureVertex
  4162. * @returns the cloned PositionNormalTextureVertex
  4163. */
  4164. clone(): PositionNormalTextureVertex;
  4165. }
  4166. /**
  4167. * @hidden
  4168. */
  4169. export class Tmp {
  4170. static Color3: Color3[];
  4171. static Color4: Color4[];
  4172. static Vector2: Vector2[];
  4173. static Vector3: Vector3[];
  4174. static Vector4: Vector4[];
  4175. static Quaternion: Quaternion[];
  4176. static Matrix: Matrix[];
  4177. }
  4178. }
  4179. declare module "babylonjs/Offline/IOfflineProvider" {
  4180. /**
  4181. * Class used to enable access to offline support
  4182. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4183. */
  4184. export interface IOfflineProvider {
  4185. /**
  4186. * Gets a boolean indicating if scene must be saved in the database
  4187. */
  4188. enableSceneOffline: boolean;
  4189. /**
  4190. * Gets a boolean indicating if textures must be saved in the database
  4191. */
  4192. enableTexturesOffline: boolean;
  4193. /**
  4194. * Open the offline support and make it available
  4195. * @param successCallback defines the callback to call on success
  4196. * @param errorCallback defines the callback to call on error
  4197. */
  4198. open(successCallback: () => void, errorCallback: () => void): void;
  4199. /**
  4200. * Loads an image from the offline support
  4201. * @param url defines the url to load from
  4202. * @param image defines the target DOM image
  4203. */
  4204. loadImage(url: string, image: HTMLImageElement): void;
  4205. /**
  4206. * Loads a file from offline support
  4207. * @param url defines the URL to load from
  4208. * @param sceneLoaded defines a callback to call on success
  4209. * @param progressCallBack defines a callback to call when progress changed
  4210. * @param errorCallback defines a callback to call on error
  4211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4212. */
  4213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4214. }
  4215. }
  4216. declare module "babylonjs/Misc/observable" {
  4217. import { Nullable } from "babylonjs/types";
  4218. /**
  4219. * A class serves as a medium between the observable and its observers
  4220. */
  4221. export class EventState {
  4222. /**
  4223. * Create a new EventState
  4224. * @param mask defines the mask associated with this state
  4225. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4226. * @param target defines the original target of the state
  4227. * @param currentTarget defines the current target of the state
  4228. */
  4229. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4230. /**
  4231. * Initialize the current event state
  4232. * @param mask defines the mask associated with this state
  4233. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4234. * @param target defines the original target of the state
  4235. * @param currentTarget defines the current target of the state
  4236. * @returns the current event state
  4237. */
  4238. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4239. /**
  4240. * An Observer can set this property to true to prevent subsequent observers of being notified
  4241. */
  4242. skipNextObservers: boolean;
  4243. /**
  4244. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4245. */
  4246. mask: number;
  4247. /**
  4248. * The object that originally notified the event
  4249. */
  4250. target?: any;
  4251. /**
  4252. * The current object in the bubbling phase
  4253. */
  4254. currentTarget?: any;
  4255. /**
  4256. * This will be populated with the return value of the last function that was executed.
  4257. * If it is the first function in the callback chain it will be the event data.
  4258. */
  4259. lastReturnValue?: any;
  4260. }
  4261. /**
  4262. * Represent an Observer registered to a given Observable object.
  4263. */
  4264. export class Observer<T> {
  4265. /**
  4266. * Defines the callback to call when the observer is notified
  4267. */
  4268. callback: (eventData: T, eventState: EventState) => void;
  4269. /**
  4270. * Defines the mask of the observer (used to filter notifications)
  4271. */
  4272. mask: number;
  4273. /**
  4274. * Defines the current scope used to restore the JS context
  4275. */
  4276. scope: any;
  4277. /** @hidden */
  4278. _willBeUnregistered: boolean;
  4279. /**
  4280. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4281. */
  4282. unregisterOnNextCall: boolean;
  4283. /**
  4284. * Creates a new observer
  4285. * @param callback defines the callback to call when the observer is notified
  4286. * @param mask defines the mask of the observer (used to filter notifications)
  4287. * @param scope defines the current scope used to restore the JS context
  4288. */
  4289. constructor(
  4290. /**
  4291. * Defines the callback to call when the observer is notified
  4292. */
  4293. callback: (eventData: T, eventState: EventState) => void,
  4294. /**
  4295. * Defines the mask of the observer (used to filter notifications)
  4296. */
  4297. mask: number,
  4298. /**
  4299. * Defines the current scope used to restore the JS context
  4300. */
  4301. scope?: any);
  4302. }
  4303. /**
  4304. * Represent a list of observers registered to multiple Observables object.
  4305. */
  4306. export class MultiObserver<T> {
  4307. private _observers;
  4308. private _observables;
  4309. /**
  4310. * Release associated resources
  4311. */
  4312. dispose(): void;
  4313. /**
  4314. * Raise a callback when one of the observable will notify
  4315. * @param observables defines a list of observables to watch
  4316. * @param callback defines the callback to call on notification
  4317. * @param mask defines the mask used to filter notifications
  4318. * @param scope defines the current scope used to restore the JS context
  4319. * @returns the new MultiObserver
  4320. */
  4321. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4322. }
  4323. /**
  4324. * The Observable class is a simple implementation of the Observable pattern.
  4325. *
  4326. * 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.
  4327. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4328. * 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).
  4329. * 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.
  4330. */
  4331. export class Observable<T> {
  4332. private _observers;
  4333. private _eventState;
  4334. private _onObserverAdded;
  4335. /**
  4336. * Creates a new observable
  4337. * @param onObserverAdded defines a callback to call when a new observer is added
  4338. */
  4339. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4340. /**
  4341. * Create a new Observer with the specified callback
  4342. * @param callback the callback that will be executed for that Observer
  4343. * @param mask the mask used to filter observers
  4344. * @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.
  4345. * @param scope optional scope for the callback to be called from
  4346. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4347. * @returns the new observer created for the callback
  4348. */
  4349. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4350. /**
  4351. * Create a new Observer with the specified callback and unregisters after the next notification
  4352. * @param callback the callback that will be executed for that Observer
  4353. * @returns the new observer created for the callback
  4354. */
  4355. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4356. /**
  4357. * Remove an Observer from the Observable object
  4358. * @param observer the instance of the Observer to remove
  4359. * @returns false if it doesn't belong to this Observable
  4360. */
  4361. remove(observer: Nullable<Observer<T>>): boolean;
  4362. /**
  4363. * Remove a callback from the Observable object
  4364. * @param callback the callback to remove
  4365. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4366. * @returns false if it doesn't belong to this Observable
  4367. */
  4368. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4369. private _deferUnregister;
  4370. private _remove;
  4371. /**
  4372. * Moves the observable to the top of the observer list making it get called first when notified
  4373. * @param observer the observer to move
  4374. */
  4375. makeObserverTopPriority(observer: Observer<T>): void;
  4376. /**
  4377. * Moves the observable to the bottom of the observer list making it get called last when notified
  4378. * @param observer the observer to move
  4379. */
  4380. makeObserverBottomPriority(observer: Observer<T>): void;
  4381. /**
  4382. * Notify all Observers by calling their respective callback with the given data
  4383. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4384. * @param eventData defines the data to send to all observers
  4385. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4386. * @param target defines the original target of the state
  4387. * @param currentTarget defines the current target of the state
  4388. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4389. */
  4390. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4391. /**
  4392. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4393. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4394. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4395. * and it is crucial that all callbacks will be executed.
  4396. * The order of the callbacks is kept, callbacks are not executed parallel.
  4397. *
  4398. * @param eventData The data to be sent to each callback
  4399. * @param mask is used to filter observers defaults to -1
  4400. * @param target defines the callback target (see EventState)
  4401. * @param currentTarget defines he current object in the bubbling phase
  4402. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4403. */
  4404. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4405. /**
  4406. * Notify a specific observer
  4407. * @param observer defines the observer to notify
  4408. * @param eventData defines the data to be sent to each callback
  4409. * @param mask is used to filter observers defaults to -1
  4410. */
  4411. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4412. /**
  4413. * Gets a boolean indicating if the observable has at least one observer
  4414. * @returns true is the Observable has at least one Observer registered
  4415. */
  4416. hasObservers(): boolean;
  4417. /**
  4418. * Clear the list of observers
  4419. */
  4420. clear(): void;
  4421. /**
  4422. * Clone the current observable
  4423. * @returns a new observable
  4424. */
  4425. clone(): Observable<T>;
  4426. /**
  4427. * Does this observable handles observer registered with a given mask
  4428. * @param mask defines the mask to be tested
  4429. * @return whether or not one observer registered with the given mask is handeled
  4430. **/
  4431. hasSpecificMask(mask?: number): boolean;
  4432. }
  4433. }
  4434. declare module "babylonjs/Misc/filesInputStore" {
  4435. /**
  4436. * Class used to help managing file picking and drag'n'drop
  4437. * File Storage
  4438. */
  4439. export class FilesInputStore {
  4440. /**
  4441. * List of files ready to be loaded
  4442. */
  4443. static FilesToLoad: {
  4444. [key: string]: File;
  4445. };
  4446. }
  4447. }
  4448. declare module "babylonjs/Engines/constants" {
  4449. /** Defines the cross module used constants to avoid circular dependncies */
  4450. export class Constants {
  4451. /** Defines that alpha blending is disabled */
  4452. static readonly ALPHA_DISABLE: number;
  4453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4454. static readonly ALPHA_ADD: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4456. static readonly ALPHA_COMBINE: number;
  4457. /** Defines that alpha blending to DEST - SRC * DEST */
  4458. static readonly ALPHA_SUBTRACT: number;
  4459. /** Defines that alpha blending to SRC * DEST */
  4460. static readonly ALPHA_MULTIPLY: number;
  4461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4462. static readonly ALPHA_MAXIMIZED: number;
  4463. /** Defines that alpha blending to SRC + DEST */
  4464. static readonly ALPHA_ONEONE: number;
  4465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4466. static readonly ALPHA_PREMULTIPLIED: number;
  4467. /**
  4468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4470. */
  4471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4473. static readonly ALPHA_INTERPOLATE: number;
  4474. /**
  4475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4477. */
  4478. static readonly ALPHA_SCREENMODE: number;
  4479. /** Defines that the ressource is not delayed*/
  4480. static readonly DELAYLOADSTATE_NONE: number;
  4481. /** Defines that the ressource was successfully delay loaded */
  4482. static readonly DELAYLOADSTATE_LOADED: number;
  4483. /** Defines that the ressource is currently delay loading */
  4484. static readonly DELAYLOADSTATE_LOADING: number;
  4485. /** Defines that the ressource is delayed and has not started loading */
  4486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4488. static readonly NEVER: number;
  4489. /** 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 */
  4490. static readonly ALWAYS: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4492. static readonly LESS: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4494. static readonly EQUAL: number;
  4495. /** 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 */
  4496. static readonly LEQUAL: number;
  4497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4498. static readonly GREATER: number;
  4499. /** 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 */
  4500. static readonly GEQUAL: number;
  4501. /** 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 */
  4502. static readonly NOTEQUAL: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be kept */
  4504. static readonly KEEP: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4506. static readonly REPLACE: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4508. static readonly INCR: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4510. static readonly DECR: number;
  4511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4512. static readonly INVERT: number;
  4513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4514. static readonly INCR_WRAP: number;
  4515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4516. static readonly DECR_WRAP: number;
  4517. /** Texture is not repeating outside of 0..1 UVs */
  4518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4519. /** Texture is repeating outside of 0..1 UVs */
  4520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4521. /** Texture is repeating and mirrored */
  4522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4523. /** ALPHA */
  4524. static readonly TEXTUREFORMAT_ALPHA: number;
  4525. /** LUMINANCE */
  4526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4527. /** LUMINANCE_ALPHA */
  4528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4529. /** RGB */
  4530. static readonly TEXTUREFORMAT_RGB: number;
  4531. /** RGBA */
  4532. static readonly TEXTUREFORMAT_RGBA: number;
  4533. /** RED */
  4534. static readonly TEXTUREFORMAT_RED: number;
  4535. /** RED (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R: number;
  4537. /** RG */
  4538. static readonly TEXTUREFORMAT_RG: number;
  4539. /** RED_INTEGER */
  4540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4541. /** RED_INTEGER (2nd reference) */
  4542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4543. /** RG_INTEGER */
  4544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4545. /** RGB_INTEGER */
  4546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4547. /** RGBA_INTEGER */
  4548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4549. /** UNSIGNED_BYTE */
  4550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4551. /** UNSIGNED_BYTE (2nd reference) */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4553. /** FLOAT */
  4554. static readonly TEXTURETYPE_FLOAT: number;
  4555. /** HALF_FLOAT */
  4556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4557. /** BYTE */
  4558. static readonly TEXTURETYPE_BYTE: number;
  4559. /** SHORT */
  4560. static readonly TEXTURETYPE_SHORT: number;
  4561. /** UNSIGNED_SHORT */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4563. /** INT */
  4564. static readonly TEXTURETYPE_INT: number;
  4565. /** UNSIGNED_INT */
  4566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4567. /** UNSIGNED_SHORT_4_4_4_4 */
  4568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4569. /** UNSIGNED_SHORT_5_5_5_1 */
  4570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4571. /** UNSIGNED_SHORT_5_6_5 */
  4572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4573. /** UNSIGNED_INT_2_10_10_10_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4575. /** UNSIGNED_INT_24_8 */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4577. /** UNSIGNED_INT_10F_11F_11F_REV */
  4578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4579. /** UNSIGNED_INT_5_9_9_9_REV */
  4580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4589. /** nearest is mag = nearest and min = nearest and mip = linear */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4593. /** Trilinear is mag = linear and min = linear and mip = linear */
  4594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = nearest and mip = nearest */
  4596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4597. /** mag = nearest and min = linear and mip = nearest */
  4598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4599. /** mag = nearest and min = linear and mip = linear */
  4600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4601. /** mag = nearest and min = linear and mip = none */
  4602. static readonly TEXTURE_NEAREST_LINEAR: number;
  4603. /** mag = nearest and min = nearest and mip = none */
  4604. static readonly TEXTURE_NEAREST_NEAREST: number;
  4605. /** mag = linear and min = nearest and mip = nearest */
  4606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4607. /** mag = linear and min = nearest and mip = linear */
  4608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4609. /** mag = linear and min = linear and mip = none */
  4610. static readonly TEXTURE_LINEAR_LINEAR: number;
  4611. /** mag = linear and min = nearest and mip = none */
  4612. static readonly TEXTURE_LINEAR_NEAREST: number;
  4613. /** Explicit coordinates mode */
  4614. static readonly TEXTURE_EXPLICIT_MODE: number;
  4615. /** Spherical coordinates mode */
  4616. static readonly TEXTURE_SPHERICAL_MODE: number;
  4617. /** Planar coordinates mode */
  4618. static readonly TEXTURE_PLANAR_MODE: number;
  4619. /** Cubic coordinates mode */
  4620. static readonly TEXTURE_CUBIC_MODE: number;
  4621. /** Projection coordinates mode */
  4622. static readonly TEXTURE_PROJECTION_MODE: number;
  4623. /** Skybox coordinates mode */
  4624. static readonly TEXTURE_SKYBOX_MODE: number;
  4625. /** Inverse Cubic coordinates mode */
  4626. static readonly TEXTURE_INVCUBIC_MODE: number;
  4627. /** Equirectangular coordinates mode */
  4628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4629. /** Equirectangular Fixed coordinates mode */
  4630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4631. /** Equirectangular Fixed Mirrored coordinates mode */
  4632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4634. static readonly SCALEMODE_FLOOR: number;
  4635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4636. static readonly SCALEMODE_NEAREST: number;
  4637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4638. static readonly SCALEMODE_CEILING: number;
  4639. /**
  4640. * The dirty texture flag value
  4641. */
  4642. static readonly MATERIAL_TextureDirtyFlag: number;
  4643. /**
  4644. * The dirty light flag value
  4645. */
  4646. static readonly MATERIAL_LightDirtyFlag: number;
  4647. /**
  4648. * The dirty fresnel flag value
  4649. */
  4650. static readonly MATERIAL_FresnelDirtyFlag: number;
  4651. /**
  4652. * The dirty attribute flag value
  4653. */
  4654. static readonly MATERIAL_AttributesDirtyFlag: number;
  4655. /**
  4656. * The dirty misc flag value
  4657. */
  4658. static readonly MATERIAL_MiscDirtyFlag: number;
  4659. /**
  4660. * The all dirty flag value
  4661. */
  4662. static readonly MATERIAL_AllDirtyFlag: number;
  4663. /**
  4664. * Returns the triangle fill mode
  4665. */
  4666. static readonly MATERIAL_TriangleFillMode: number;
  4667. /**
  4668. * Returns the wireframe mode
  4669. */
  4670. static readonly MATERIAL_WireFrameFillMode: number;
  4671. /**
  4672. * Returns the point fill mode
  4673. */
  4674. static readonly MATERIAL_PointFillMode: number;
  4675. /**
  4676. * Returns the point list draw mode
  4677. */
  4678. static readonly MATERIAL_PointListDrawMode: number;
  4679. /**
  4680. * Returns the line list draw mode
  4681. */
  4682. static readonly MATERIAL_LineListDrawMode: number;
  4683. /**
  4684. * Returns the line loop draw mode
  4685. */
  4686. static readonly MATERIAL_LineLoopDrawMode: number;
  4687. /**
  4688. * Returns the line strip draw mode
  4689. */
  4690. static readonly MATERIAL_LineStripDrawMode: number;
  4691. /**
  4692. * Returns the triangle strip draw mode
  4693. */
  4694. static readonly MATERIAL_TriangleStripDrawMode: number;
  4695. /**
  4696. * Returns the triangle fan draw mode
  4697. */
  4698. static readonly MATERIAL_TriangleFanDrawMode: number;
  4699. /**
  4700. * Stores the clock-wise side orientation
  4701. */
  4702. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4703. /**
  4704. * Stores the counter clock-wise side orientation
  4705. */
  4706. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4707. /**
  4708. * Nothing
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_NothingTrigger: number;
  4712. /**
  4713. * On pick
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnPickTrigger: number;
  4717. /**
  4718. * On left pick
  4719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4720. */
  4721. static readonly ACTION_OnLeftPickTrigger: number;
  4722. /**
  4723. * On right pick
  4724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4725. */
  4726. static readonly ACTION_OnRightPickTrigger: number;
  4727. /**
  4728. * On center pick
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_OnCenterPickTrigger: number;
  4732. /**
  4733. * On pick down
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickDownTrigger: number;
  4737. /**
  4738. * On double pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnDoublePickTrigger: number;
  4742. /**
  4743. * On pick up
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickUpTrigger: number;
  4747. /**
  4748. * On pick out.
  4749. * This trigger will only be raised if you also declared a OnPickDown
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnPickOutTrigger: number;
  4753. /**
  4754. * On long press
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnLongPressTrigger: number;
  4758. /**
  4759. * On pointer over
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnPointerOverTrigger: number;
  4763. /**
  4764. * On pointer out
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPointerOutTrigger: number;
  4768. /**
  4769. * On every frame
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnEveryFrameTrigger: number;
  4773. /**
  4774. * On intersection enter
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4778. /**
  4779. * On intersection exit
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnIntersectionExitTrigger: number;
  4783. /**
  4784. * On key down
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnKeyDownTrigger: number;
  4788. /**
  4789. * On key up
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnKeyUpTrigger: number;
  4793. /**
  4794. * Billboard mode will only apply to Y axis
  4795. */
  4796. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4797. /**
  4798. * Billboard mode will apply to all axes
  4799. */
  4800. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4801. /**
  4802. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4803. */
  4804. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4805. /**
  4806. * Gets or sets base Assets URL
  4807. */
  4808. static readonly PARTICLES_BaseAssetsUrl: string;
  4809. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4810. * Test order :
  4811. * Is the bounding sphere outside the frustum ?
  4812. * If not, are the bounding box vertices outside the frustum ?
  4813. * It not, then the cullable object is in the frustum.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4816. /** Culling strategy : Bounding Sphere Only.
  4817. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4818. * It's also less accurate than the standard because some not visible objects can still be selected.
  4819. * Test : is the bounding sphere outside the frustum ?
  4820. * If not, then the cullable object is in the frustum.
  4821. */
  4822. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4823. /** Culling strategy : Optimistic Inclusion.
  4824. * This in an inclusion test first, then the standard exclusion test.
  4825. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4826. * 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.
  4827. * Anyway, it's as accurate as the standard strategy.
  4828. * Test :
  4829. * Is the cullable object bounding sphere center in the frustum ?
  4830. * If not, apply the default culling strategy.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4833. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4834. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4835. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4836. * 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.
  4837. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4838. * Test :
  4839. * Is the cullable object bounding sphere center in the frustum ?
  4840. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4843. /**
  4844. * No logging while loading
  4845. */
  4846. static readonly SCENELOADER_NO_LOGGING: number;
  4847. /**
  4848. * Minimal logging while loading
  4849. */
  4850. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4851. /**
  4852. * Summary logging while loading
  4853. */
  4854. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4855. /**
  4856. * Detailled logging while loading
  4857. */
  4858. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4859. }
  4860. }
  4861. declare module "babylonjs/Misc/domManagement" {
  4862. /**
  4863. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4864. * Babylon.js
  4865. */
  4866. export class DomManagement {
  4867. /**
  4868. * Checks if the window object exists
  4869. * @returns true if the window object exists
  4870. */
  4871. static IsWindowObjectExist(): boolean;
  4872. /**
  4873. * Extracts text content from a DOM element hierarchy
  4874. * @param element defines the root element
  4875. * @returns a string
  4876. */
  4877. static GetDOMTextContent(element: HTMLElement): string;
  4878. }
  4879. }
  4880. declare module "babylonjs/Misc/logger" {
  4881. /**
  4882. * Logger used througouht the application to allow configuration of
  4883. * the log level required for the messages.
  4884. */
  4885. export class Logger {
  4886. /**
  4887. * No log
  4888. */
  4889. static readonly NoneLogLevel: number;
  4890. /**
  4891. * Only message logs
  4892. */
  4893. static readonly MessageLogLevel: number;
  4894. /**
  4895. * Only warning logs
  4896. */
  4897. static readonly WarningLogLevel: number;
  4898. /**
  4899. * Only error logs
  4900. */
  4901. static readonly ErrorLogLevel: number;
  4902. /**
  4903. * All logs
  4904. */
  4905. static readonly AllLogLevel: number;
  4906. private static _LogCache;
  4907. /**
  4908. * Gets a value indicating the number of loading errors
  4909. * @ignorenaming
  4910. */
  4911. static errorsCount: number;
  4912. /**
  4913. * Callback called when a new log is added
  4914. */
  4915. static OnNewCacheEntry: (entry: string) => void;
  4916. private static _AddLogEntry;
  4917. private static _FormatMessage;
  4918. private static _LogDisabled;
  4919. private static _LogEnabled;
  4920. private static _WarnDisabled;
  4921. private static _WarnEnabled;
  4922. private static _ErrorDisabled;
  4923. private static _ErrorEnabled;
  4924. /**
  4925. * Log a message to the console
  4926. */
  4927. static Log: (message: string) => void;
  4928. /**
  4929. * Write a warning message to the console
  4930. */
  4931. static Warn: (message: string) => void;
  4932. /**
  4933. * Write an error message to the console
  4934. */
  4935. static Error: (message: string) => void;
  4936. /**
  4937. * Gets current log cache (list of logs)
  4938. */
  4939. static readonly LogCache: string;
  4940. /**
  4941. * Clears the log cache
  4942. */
  4943. static ClearLogCache(): void;
  4944. /**
  4945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4946. */
  4947. static LogLevels: number;
  4948. }
  4949. }
  4950. declare module "babylonjs/Misc/typeStore" {
  4951. /** @hidden */
  4952. export class _TypeStore {
  4953. /** @hidden */
  4954. static RegisteredTypes: {
  4955. [key: string]: Object;
  4956. };
  4957. /** @hidden */
  4958. static GetClass(fqdn: string): any;
  4959. }
  4960. }
  4961. declare module "babylonjs/Misc/deepCopier" {
  4962. /**
  4963. * Class containing a set of static utilities functions for deep copy.
  4964. */
  4965. export class DeepCopier {
  4966. /**
  4967. * Tries to copy an object by duplicating every property
  4968. * @param source defines the source object
  4969. * @param destination defines the target object
  4970. * @param doNotCopyList defines a list of properties to avoid
  4971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4972. */
  4973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/precisionDate" {
  4977. /**
  4978. * Class containing a set of static utilities functions for precision date
  4979. */
  4980. export class PrecisionDate {
  4981. /**
  4982. * Gets either window.performance.now() if supported or Date.now() else
  4983. */
  4984. static readonly Now: number;
  4985. }
  4986. }
  4987. declare module "babylonjs/Misc/devTools" {
  4988. /** @hidden */
  4989. export class _DevTools {
  4990. static WarnImport(name: string): string;
  4991. }
  4992. }
  4993. declare module "babylonjs/Misc/webRequest" {
  4994. /**
  4995. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4996. */
  4997. export class WebRequest {
  4998. private _xhr;
  4999. /**
  5000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5001. * i.e. when loading files, where the server/service expects an Authorization header
  5002. */
  5003. static CustomRequestHeaders: {
  5004. [key: string]: string;
  5005. };
  5006. /**
  5007. * Add callback functions in this array to update all the requests before they get sent to the network
  5008. */
  5009. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5010. private _injectCustomRequestHeaders;
  5011. /**
  5012. * Gets or sets a function to be called when loading progress changes
  5013. */
  5014. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5015. /**
  5016. * Returns client's state
  5017. */
  5018. readonly readyState: number;
  5019. /**
  5020. * Returns client's status
  5021. */
  5022. readonly status: number;
  5023. /**
  5024. * Returns client's status as a text
  5025. */
  5026. readonly statusText: string;
  5027. /**
  5028. * Returns client's response
  5029. */
  5030. readonly response: any;
  5031. /**
  5032. * Returns client's response url
  5033. */
  5034. readonly responseURL: string;
  5035. /**
  5036. * Returns client's response as text
  5037. */
  5038. readonly responseText: string;
  5039. /**
  5040. * Gets or sets the expected response type
  5041. */
  5042. responseType: XMLHttpRequestResponseType;
  5043. /** @hidden */
  5044. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5045. /** @hidden */
  5046. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5047. /**
  5048. * Cancels any network activity
  5049. */
  5050. abort(): void;
  5051. /**
  5052. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5053. * @param body defines an optional request body
  5054. */
  5055. send(body?: Document | BodyInit | null): void;
  5056. /**
  5057. * Sets the request method, request URL
  5058. * @param method defines the method to use (GET, POST, etc..)
  5059. * @param url defines the url to connect with
  5060. */
  5061. open(method: string, url: string): void;
  5062. }
  5063. }
  5064. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5065. /**
  5066. * Class used to evalaute queries containing `and` and `or` operators
  5067. */
  5068. export class AndOrNotEvaluator {
  5069. /**
  5070. * Evaluate a query
  5071. * @param query defines the query to evaluate
  5072. * @param evaluateCallback defines the callback used to filter result
  5073. * @returns true if the query matches
  5074. */
  5075. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5076. private static _HandleParenthesisContent;
  5077. private static _SimplifyNegation;
  5078. }
  5079. }
  5080. declare module "babylonjs/Misc/tags" {
  5081. /**
  5082. * Class used to store custom tags
  5083. */
  5084. export class Tags {
  5085. /**
  5086. * Adds support for tags on the given object
  5087. * @param obj defines the object to use
  5088. */
  5089. static EnableFor(obj: any): void;
  5090. /**
  5091. * Removes tags support
  5092. * @param obj defines the object to use
  5093. */
  5094. static DisableFor(obj: any): void;
  5095. /**
  5096. * Gets a boolean indicating if the given object has tags
  5097. * @param obj defines the object to use
  5098. * @returns a boolean
  5099. */
  5100. static HasTags(obj: any): boolean;
  5101. /**
  5102. * Gets the tags available on a given object
  5103. * @param obj defines the object to use
  5104. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5105. * @returns the tags
  5106. */
  5107. static GetTags(obj: any, asString?: boolean): any;
  5108. /**
  5109. * Adds tags to an object
  5110. * @param obj defines the object to use
  5111. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5112. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5113. */
  5114. static AddTagsTo(obj: any, tagsString: string): void;
  5115. /**
  5116. * @hidden
  5117. */
  5118. static _AddTagTo(obj: any, tag: string): void;
  5119. /**
  5120. * Removes specific tags from a specific object
  5121. * @param obj defines the object to use
  5122. * @param tagsString defines the tags to remove
  5123. */
  5124. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5125. /**
  5126. * @hidden
  5127. */
  5128. static _RemoveTagFrom(obj: any, tag: string): void;
  5129. /**
  5130. * Defines if tags hosted on an object match a given query
  5131. * @param obj defines the object to use
  5132. * @param tagsQuery defines the tag query
  5133. * @returns a boolean
  5134. */
  5135. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5136. }
  5137. }
  5138. declare module "babylonjs/Materials/materialDefines" {
  5139. /**
  5140. * Manages the defines for the Material
  5141. */
  5142. export class MaterialDefines {
  5143. private _keys;
  5144. private _isDirty;
  5145. /** @hidden */
  5146. _renderId: number;
  5147. /** @hidden */
  5148. _areLightsDirty: boolean;
  5149. /** @hidden */
  5150. _areAttributesDirty: boolean;
  5151. /** @hidden */
  5152. _areTexturesDirty: boolean;
  5153. /** @hidden */
  5154. _areFresnelDirty: boolean;
  5155. /** @hidden */
  5156. _areMiscDirty: boolean;
  5157. /** @hidden */
  5158. _areImageProcessingDirty: boolean;
  5159. /** @hidden */
  5160. _normals: boolean;
  5161. /** @hidden */
  5162. _uvs: boolean;
  5163. /** @hidden */
  5164. _needNormals: boolean;
  5165. /** @hidden */
  5166. _needUVs: boolean;
  5167. /**
  5168. * Specifies if the material needs to be re-calculated
  5169. */
  5170. readonly isDirty: boolean;
  5171. /**
  5172. * Marks the material to indicate that it has been re-calculated
  5173. */
  5174. markAsProcessed(): void;
  5175. /**
  5176. * Marks the material to indicate that it needs to be re-calculated
  5177. */
  5178. markAsUnprocessed(): void;
  5179. /**
  5180. * Marks the material to indicate all of its defines need to be re-calculated
  5181. */
  5182. markAllAsDirty(): void;
  5183. /**
  5184. * Marks the material to indicate that image processing needs to be re-calculated
  5185. */
  5186. markAsImageProcessingDirty(): void;
  5187. /**
  5188. * Marks the material to indicate the lights need to be re-calculated
  5189. */
  5190. markAsLightDirty(): void;
  5191. /**
  5192. * Marks the attribute state as changed
  5193. */
  5194. markAsAttributesDirty(): void;
  5195. /**
  5196. * Marks the texture state as changed
  5197. */
  5198. markAsTexturesDirty(): void;
  5199. /**
  5200. * Marks the fresnel state as changed
  5201. */
  5202. markAsFresnelDirty(): void;
  5203. /**
  5204. * Marks the misc state as changed
  5205. */
  5206. markAsMiscDirty(): void;
  5207. /**
  5208. * Rebuilds the material defines
  5209. */
  5210. rebuild(): void;
  5211. /**
  5212. * Specifies if two material defines are equal
  5213. * @param other - A material define instance to compare to
  5214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5215. */
  5216. isEqual(other: MaterialDefines): boolean;
  5217. /**
  5218. * Clones this instance's defines to another instance
  5219. * @param other - material defines to clone values to
  5220. */
  5221. cloneTo(other: MaterialDefines): void;
  5222. /**
  5223. * Resets the material define values
  5224. */
  5225. reset(): void;
  5226. /**
  5227. * Converts the material define values to a string
  5228. * @returns - String of material define information
  5229. */
  5230. toString(): string;
  5231. }
  5232. }
  5233. declare module "babylonjs/Engines/IPipelineContext" {
  5234. /**
  5235. * Class used to store and describe the pipeline context associated with an effect
  5236. */
  5237. export interface IPipelineContext {
  5238. /**
  5239. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5240. */
  5241. isAsync: boolean;
  5242. /**
  5243. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5244. */
  5245. isReady: boolean;
  5246. /** @hidden */
  5247. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5248. }
  5249. }
  5250. declare module "babylonjs/Meshes/dataBuffer" {
  5251. /**
  5252. * Class used to store gfx data (like WebGLBuffer)
  5253. */
  5254. export class DataBuffer {
  5255. /**
  5256. * Gets or sets the number of objects referencing this buffer
  5257. */
  5258. references: number;
  5259. /** Gets or sets the size of the underlying buffer */
  5260. capacity: number;
  5261. /**
  5262. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5263. */
  5264. is32Bits: boolean;
  5265. /**
  5266. * Gets the underlying buffer
  5267. */
  5268. readonly underlyingResource: any;
  5269. }
  5270. }
  5271. declare module "babylonjs/Misc/performanceMonitor" {
  5272. /**
  5273. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5274. */
  5275. export class PerformanceMonitor {
  5276. private _enabled;
  5277. private _rollingFrameTime;
  5278. private _lastFrameTimeMs;
  5279. /**
  5280. * constructor
  5281. * @param frameSampleSize The number of samples required to saturate the sliding window
  5282. */
  5283. constructor(frameSampleSize?: number);
  5284. /**
  5285. * Samples current frame
  5286. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5287. */
  5288. sampleFrame(timeMs?: number): void;
  5289. /**
  5290. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5291. */
  5292. readonly averageFrameTime: number;
  5293. /**
  5294. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5295. */
  5296. readonly averageFrameTimeVariance: number;
  5297. /**
  5298. * Returns the frame time of the most recent frame
  5299. */
  5300. readonly instantaneousFrameTime: number;
  5301. /**
  5302. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5303. */
  5304. readonly averageFPS: number;
  5305. /**
  5306. * Returns the average framerate in frames per second using the most recent frame time
  5307. */
  5308. readonly instantaneousFPS: number;
  5309. /**
  5310. * Returns true if enough samples have been taken to completely fill the sliding window
  5311. */
  5312. readonly isSaturated: boolean;
  5313. /**
  5314. * Enables contributions to the sliding window sample set
  5315. */
  5316. enable(): void;
  5317. /**
  5318. * Disables contributions to the sliding window sample set
  5319. * Samples will not be interpolated over the disabled period
  5320. */
  5321. disable(): void;
  5322. /**
  5323. * Returns true if sampling is enabled
  5324. */
  5325. readonly isEnabled: boolean;
  5326. /**
  5327. * Resets performance monitor
  5328. */
  5329. reset(): void;
  5330. }
  5331. /**
  5332. * RollingAverage
  5333. *
  5334. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5335. */
  5336. export class RollingAverage {
  5337. /**
  5338. * Current average
  5339. */
  5340. average: number;
  5341. /**
  5342. * Current variance
  5343. */
  5344. variance: number;
  5345. protected _samples: Array<number>;
  5346. protected _sampleCount: number;
  5347. protected _pos: number;
  5348. protected _m2: number;
  5349. /**
  5350. * constructor
  5351. * @param length The number of samples required to saturate the sliding window
  5352. */
  5353. constructor(length: number);
  5354. /**
  5355. * Adds a sample to the sample set
  5356. * @param v The sample value
  5357. */
  5358. add(v: number): void;
  5359. /**
  5360. * Returns previously added values or null if outside of history or outside the sliding window domain
  5361. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5362. * @return Value previously recorded with add() or null if outside of range
  5363. */
  5364. history(i: number): number;
  5365. /**
  5366. * Returns true if enough samples have been taken to completely fill the sliding window
  5367. * @return true if sample-set saturated
  5368. */
  5369. isSaturated(): boolean;
  5370. /**
  5371. * Resets the rolling average (equivalent to 0 samples taken so far)
  5372. */
  5373. reset(): void;
  5374. /**
  5375. * Wraps a value around the sample range boundaries
  5376. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5377. * @return Wrapped position in sample range
  5378. */
  5379. protected _wrapPosition(i: number): number;
  5380. }
  5381. }
  5382. declare module "babylonjs/Misc/stringDictionary" {
  5383. import { Nullable } from "babylonjs/types";
  5384. /**
  5385. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5386. * The underlying implementation relies on an associative array to ensure the best performances.
  5387. * The value can be anything including 'null' but except 'undefined'
  5388. */
  5389. export class StringDictionary<T> {
  5390. /**
  5391. * This will clear this dictionary and copy the content from the 'source' one.
  5392. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5393. * @param source the dictionary to take the content from and copy to this dictionary
  5394. */
  5395. copyFrom(source: StringDictionary<T>): void;
  5396. /**
  5397. * Get a value based from its key
  5398. * @param key the given key to get the matching value from
  5399. * @return the value if found, otherwise undefined is returned
  5400. */
  5401. get(key: string): T | undefined;
  5402. /**
  5403. * Get a value from its key or add it if it doesn't exist.
  5404. * This method will ensure you that a given key/data will be present in the dictionary.
  5405. * @param key the given key to get the matching value from
  5406. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5407. * The factory will only be invoked if there's no data for the given key.
  5408. * @return the value corresponding to the key.
  5409. */
  5410. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5411. /**
  5412. * Get a value from its key if present in the dictionary otherwise add it
  5413. * @param key the key to get the value from
  5414. * @param val if there's no such key/value pair in the dictionary add it with this value
  5415. * @return the value corresponding to the key
  5416. */
  5417. getOrAdd(key: string, val: T): T;
  5418. /**
  5419. * Check if there's a given key in the dictionary
  5420. * @param key the key to check for
  5421. * @return true if the key is present, false otherwise
  5422. */
  5423. contains(key: string): boolean;
  5424. /**
  5425. * Add a new key and its corresponding value
  5426. * @param key the key to add
  5427. * @param value the value corresponding to the key
  5428. * @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
  5429. */
  5430. add(key: string, value: T): boolean;
  5431. /**
  5432. * Update a specific value associated to a key
  5433. * @param key defines the key to use
  5434. * @param value defines the value to store
  5435. * @returns true if the value was updated (or false if the key was not found)
  5436. */
  5437. set(key: string, value: T): boolean;
  5438. /**
  5439. * Get the element of the given key and remove it from the dictionary
  5440. * @param key defines the key to search
  5441. * @returns the value associated with the key or null if not found
  5442. */
  5443. getAndRemove(key: string): Nullable<T>;
  5444. /**
  5445. * Remove a key/value from the dictionary.
  5446. * @param key the key to remove
  5447. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5448. */
  5449. remove(key: string): boolean;
  5450. /**
  5451. * Clear the whole content of the dictionary
  5452. */
  5453. clear(): void;
  5454. /**
  5455. * Gets the current count
  5456. */
  5457. readonly count: number;
  5458. /**
  5459. * Execute a callback on each key/val of the dictionary.
  5460. * Note that you can remove any element in this dictionary in the callback implementation
  5461. * @param callback the callback to execute on a given key/value pair
  5462. */
  5463. forEach(callback: (key: string, val: T) => void): void;
  5464. /**
  5465. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5466. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5467. * Note that you can remove any element in this dictionary in the callback implementation
  5468. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5469. * @returns the first item
  5470. */
  5471. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5472. private _count;
  5473. private _data;
  5474. }
  5475. }
  5476. declare module "babylonjs/Misc/promise" {
  5477. /**
  5478. * Helper class that provides a small promise polyfill
  5479. */
  5480. export class PromisePolyfill {
  5481. /**
  5482. * Static function used to check if the polyfill is required
  5483. * If this is the case then the function will inject the polyfill to window.Promise
  5484. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5485. */
  5486. static Apply(force?: boolean): void;
  5487. }
  5488. }
  5489. declare module "babylonjs/Meshes/buffer" {
  5490. import { Nullable, DataArray } from "babylonjs/types";
  5491. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5492. /**
  5493. * Class used to store data that will be store in GPU memory
  5494. */
  5495. export class Buffer {
  5496. private _engine;
  5497. private _buffer;
  5498. /** @hidden */
  5499. _data: Nullable<DataArray>;
  5500. private _updatable;
  5501. private _instanced;
  5502. /**
  5503. * Gets the byte stride.
  5504. */
  5505. readonly byteStride: number;
  5506. /**
  5507. * Constructor
  5508. * @param engine the engine
  5509. * @param data the data to use for this buffer
  5510. * @param updatable whether the data is updatable
  5511. * @param stride the stride (optional)
  5512. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5513. * @param instanced whether the buffer is instanced (optional)
  5514. * @param useBytes set to true if the stride in in bytes (optional)
  5515. */
  5516. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5517. /**
  5518. * Create a new VertexBuffer based on the current buffer
  5519. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5520. * @param offset defines offset in the buffer (0 by default)
  5521. * @param size defines the size in floats of attributes (position is 3 for instance)
  5522. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5523. * @param instanced defines if the vertex buffer contains indexed data
  5524. * @param useBytes defines if the offset and stride are in bytes
  5525. * @returns the new vertex buffer
  5526. */
  5527. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5528. /**
  5529. * Gets a boolean indicating if the Buffer is updatable?
  5530. * @returns true if the buffer is updatable
  5531. */
  5532. isUpdatable(): boolean;
  5533. /**
  5534. * Gets current buffer's data
  5535. * @returns a DataArray or null
  5536. */
  5537. getData(): Nullable<DataArray>;
  5538. /**
  5539. * Gets underlying native buffer
  5540. * @returns underlying native buffer
  5541. */
  5542. getBuffer(): Nullable<DataBuffer>;
  5543. /**
  5544. * Gets the stride in float32 units (i.e. byte stride / 4).
  5545. * May not be an integer if the byte stride is not divisible by 4.
  5546. * DEPRECATED. Use byteStride instead.
  5547. * @returns the stride in float32 units
  5548. */
  5549. getStrideSize(): number;
  5550. /**
  5551. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5552. * @param data defines the data to store
  5553. */
  5554. create(data?: Nullable<DataArray>): void;
  5555. /** @hidden */
  5556. _rebuild(): void;
  5557. /**
  5558. * Update current buffer data
  5559. * @param data defines the data to store
  5560. */
  5561. update(data: DataArray): void;
  5562. /**
  5563. * Updates the data directly.
  5564. * @param data the new data
  5565. * @param offset the new offset
  5566. * @param vertexCount the vertex count (optional)
  5567. * @param useBytes set to true if the offset is in bytes
  5568. */
  5569. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5570. /**
  5571. * Release all resources
  5572. */
  5573. dispose(): void;
  5574. }
  5575. /**
  5576. * Specialized buffer used to store vertex data
  5577. */
  5578. export class VertexBuffer {
  5579. /** @hidden */
  5580. _buffer: Buffer;
  5581. private _kind;
  5582. private _size;
  5583. private _ownsBuffer;
  5584. private _instanced;
  5585. private _instanceDivisor;
  5586. /**
  5587. * The byte type.
  5588. */
  5589. static readonly BYTE: number;
  5590. /**
  5591. * The unsigned byte type.
  5592. */
  5593. static readonly UNSIGNED_BYTE: number;
  5594. /**
  5595. * The short type.
  5596. */
  5597. static readonly SHORT: number;
  5598. /**
  5599. * The unsigned short type.
  5600. */
  5601. static readonly UNSIGNED_SHORT: number;
  5602. /**
  5603. * The integer type.
  5604. */
  5605. static readonly INT: number;
  5606. /**
  5607. * The unsigned integer type.
  5608. */
  5609. static readonly UNSIGNED_INT: number;
  5610. /**
  5611. * The float type.
  5612. */
  5613. static readonly FLOAT: number;
  5614. /**
  5615. * Gets or sets the instance divisor when in instanced mode
  5616. */
  5617. instanceDivisor: number;
  5618. /**
  5619. * Gets the byte stride.
  5620. */
  5621. readonly byteStride: number;
  5622. /**
  5623. * Gets the byte offset.
  5624. */
  5625. readonly byteOffset: number;
  5626. /**
  5627. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5628. */
  5629. readonly normalized: boolean;
  5630. /**
  5631. * Gets the data type of each component in the array.
  5632. */
  5633. readonly type: number;
  5634. /**
  5635. * Constructor
  5636. * @param engine the engine
  5637. * @param data the data to use for this vertex buffer
  5638. * @param kind the vertex buffer kind
  5639. * @param updatable whether the data is updatable
  5640. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5641. * @param stride the stride (optional)
  5642. * @param instanced whether the buffer is instanced (optional)
  5643. * @param offset the offset of the data (optional)
  5644. * @param size the number of components (optional)
  5645. * @param type the type of the component (optional)
  5646. * @param normalized whether the data contains normalized data (optional)
  5647. * @param useBytes set to true if stride and offset are in bytes (optional)
  5648. */
  5649. 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);
  5650. /** @hidden */
  5651. _rebuild(): void;
  5652. /**
  5653. * Returns the kind of the VertexBuffer (string)
  5654. * @returns a string
  5655. */
  5656. getKind(): string;
  5657. /**
  5658. * Gets a boolean indicating if the VertexBuffer is updatable?
  5659. * @returns true if the buffer is updatable
  5660. */
  5661. isUpdatable(): boolean;
  5662. /**
  5663. * Gets current buffer's data
  5664. * @returns a DataArray or null
  5665. */
  5666. getData(): Nullable<DataArray>;
  5667. /**
  5668. * Gets underlying native buffer
  5669. * @returns underlying native buffer
  5670. */
  5671. getBuffer(): Nullable<DataBuffer>;
  5672. /**
  5673. * Gets the stride in float32 units (i.e. byte stride / 4).
  5674. * May not be an integer if the byte stride is not divisible by 4.
  5675. * DEPRECATED. Use byteStride instead.
  5676. * @returns the stride in float32 units
  5677. */
  5678. getStrideSize(): number;
  5679. /**
  5680. * Returns the offset as a multiple of the type byte length.
  5681. * DEPRECATED. Use byteOffset instead.
  5682. * @returns the offset in bytes
  5683. */
  5684. getOffset(): number;
  5685. /**
  5686. * Returns the number of components per vertex attribute (integer)
  5687. * @returns the size in float
  5688. */
  5689. getSize(): number;
  5690. /**
  5691. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5692. * @returns true if this buffer is instanced
  5693. */
  5694. getIsInstanced(): boolean;
  5695. /**
  5696. * Returns the instancing divisor, zero for non-instanced (integer).
  5697. * @returns a number
  5698. */
  5699. getInstanceDivisor(): number;
  5700. /**
  5701. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5702. * @param data defines the data to store
  5703. */
  5704. create(data?: DataArray): void;
  5705. /**
  5706. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5707. * This function will create a new buffer if the current one is not updatable
  5708. * @param data defines the data to store
  5709. */
  5710. update(data: DataArray): void;
  5711. /**
  5712. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5713. * Returns the directly updated WebGLBuffer.
  5714. * @param data the new data
  5715. * @param offset the new offset
  5716. * @param useBytes set to true if the offset is in bytes
  5717. */
  5718. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5719. /**
  5720. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5721. */
  5722. dispose(): void;
  5723. /**
  5724. * Enumerates each value of this vertex buffer as numbers.
  5725. * @param count the number of values to enumerate
  5726. * @param callback the callback function called for each value
  5727. */
  5728. forEach(count: number, callback: (value: number, index: number) => void): void;
  5729. /**
  5730. * Positions
  5731. */
  5732. static readonly PositionKind: string;
  5733. /**
  5734. * Normals
  5735. */
  5736. static readonly NormalKind: string;
  5737. /**
  5738. * Tangents
  5739. */
  5740. static readonly TangentKind: string;
  5741. /**
  5742. * Texture coordinates
  5743. */
  5744. static readonly UVKind: string;
  5745. /**
  5746. * Texture coordinates 2
  5747. */
  5748. static readonly UV2Kind: string;
  5749. /**
  5750. * Texture coordinates 3
  5751. */
  5752. static readonly UV3Kind: string;
  5753. /**
  5754. * Texture coordinates 4
  5755. */
  5756. static readonly UV4Kind: string;
  5757. /**
  5758. * Texture coordinates 5
  5759. */
  5760. static readonly UV5Kind: string;
  5761. /**
  5762. * Texture coordinates 6
  5763. */
  5764. static readonly UV6Kind: string;
  5765. /**
  5766. * Colors
  5767. */
  5768. static readonly ColorKind: string;
  5769. /**
  5770. * Matrix indices (for bones)
  5771. */
  5772. static readonly MatricesIndicesKind: string;
  5773. /**
  5774. * Matrix weights (for bones)
  5775. */
  5776. static readonly MatricesWeightsKind: string;
  5777. /**
  5778. * Additional matrix indices (for bones)
  5779. */
  5780. static readonly MatricesIndicesExtraKind: string;
  5781. /**
  5782. * Additional matrix weights (for bones)
  5783. */
  5784. static readonly MatricesWeightsExtraKind: string;
  5785. /**
  5786. * Deduces the stride given a kind.
  5787. * @param kind The kind string to deduce
  5788. * @returns The deduced stride
  5789. */
  5790. static DeduceStride(kind: string): number;
  5791. /**
  5792. * Gets the byte length of the given type.
  5793. * @param type the type
  5794. * @returns the number of bytes
  5795. */
  5796. static GetTypeByteLength(type: number): number;
  5797. /**
  5798. * Enumerates each value of the given parameters as numbers.
  5799. * @param data the data to enumerate
  5800. * @param byteOffset the byte offset of the data
  5801. * @param byteStride the byte stride of the data
  5802. * @param componentCount the number of components per element
  5803. * @param componentType the type of the component
  5804. * @param count the total number of components
  5805. * @param normalized whether the data is normalized
  5806. * @param callback the callback function called for each value
  5807. */
  5808. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5809. private static _GetFloatValue;
  5810. }
  5811. }
  5812. declare module "babylonjs/Maths/sphericalPolynomial" {
  5813. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5814. /**
  5815. * Class representing spherical harmonics coefficients to the 3rd degree
  5816. */
  5817. export class SphericalHarmonics {
  5818. /**
  5819. * Defines whether or not the harmonics have been prescaled for rendering.
  5820. */
  5821. preScaled: boolean;
  5822. /**
  5823. * The l0,0 coefficients of the spherical harmonics
  5824. */
  5825. l00: Vector3;
  5826. /**
  5827. * The l1,-1 coefficients of the spherical harmonics
  5828. */
  5829. l1_1: Vector3;
  5830. /**
  5831. * The l1,0 coefficients of the spherical harmonics
  5832. */
  5833. l10: Vector3;
  5834. /**
  5835. * The l1,1 coefficients of the spherical harmonics
  5836. */
  5837. l11: Vector3;
  5838. /**
  5839. * The l2,-2 coefficients of the spherical harmonics
  5840. */
  5841. l2_2: Vector3;
  5842. /**
  5843. * The l2,-1 coefficients of the spherical harmonics
  5844. */
  5845. l2_1: Vector3;
  5846. /**
  5847. * The l2,0 coefficients of the spherical harmonics
  5848. */
  5849. l20: Vector3;
  5850. /**
  5851. * The l2,1 coefficients of the spherical harmonics
  5852. */
  5853. l21: Vector3;
  5854. /**
  5855. * The l2,2 coefficients of the spherical harmonics
  5856. */
  5857. l22: Vector3;
  5858. /**
  5859. * Adds a light to the spherical harmonics
  5860. * @param direction the direction of the light
  5861. * @param color the color of the light
  5862. * @param deltaSolidAngle the delta solid angle of the light
  5863. */
  5864. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5865. /**
  5866. * Scales the spherical harmonics by the given amount
  5867. * @param scale the amount to scale
  5868. */
  5869. scaleInPlace(scale: number): void;
  5870. /**
  5871. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5872. *
  5873. * ```
  5874. * E_lm = A_l * L_lm
  5875. * ```
  5876. *
  5877. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5878. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5879. * the scaling factors are given in equation 9.
  5880. */
  5881. convertIncidentRadianceToIrradiance(): void;
  5882. /**
  5883. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5884. *
  5885. * ```
  5886. * L = (1/pi) * E * rho
  5887. * ```
  5888. *
  5889. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5890. */
  5891. convertIrradianceToLambertianRadiance(): void;
  5892. /**
  5893. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5894. * required operations at run time.
  5895. *
  5896. * This is simply done by scaling back the SH with Ylm constants parameter.
  5897. * The trigonometric part being applied by the shader at run time.
  5898. */
  5899. preScaleForRendering(): void;
  5900. /**
  5901. * Constructs a spherical harmonics from an array.
  5902. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5903. * @returns the spherical harmonics
  5904. */
  5905. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5906. /**
  5907. * Gets the spherical harmonics from polynomial
  5908. * @param polynomial the spherical polynomial
  5909. * @returns the spherical harmonics
  5910. */
  5911. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5912. }
  5913. /**
  5914. * Class representing spherical polynomial coefficients to the 3rd degree
  5915. */
  5916. export class SphericalPolynomial {
  5917. private _harmonics;
  5918. /**
  5919. * The spherical harmonics used to create the polynomials.
  5920. */
  5921. readonly preScaledHarmonics: SphericalHarmonics;
  5922. /**
  5923. * The x coefficients of the spherical polynomial
  5924. */
  5925. x: Vector3;
  5926. /**
  5927. * The y coefficients of the spherical polynomial
  5928. */
  5929. y: Vector3;
  5930. /**
  5931. * The z coefficients of the spherical polynomial
  5932. */
  5933. z: Vector3;
  5934. /**
  5935. * The xx coefficients of the spherical polynomial
  5936. */
  5937. xx: Vector3;
  5938. /**
  5939. * The yy coefficients of the spherical polynomial
  5940. */
  5941. yy: Vector3;
  5942. /**
  5943. * The zz coefficients of the spherical polynomial
  5944. */
  5945. zz: Vector3;
  5946. /**
  5947. * The xy coefficients of the spherical polynomial
  5948. */
  5949. xy: Vector3;
  5950. /**
  5951. * The yz coefficients of the spherical polynomial
  5952. */
  5953. yz: Vector3;
  5954. /**
  5955. * The zx coefficients of the spherical polynomial
  5956. */
  5957. zx: Vector3;
  5958. /**
  5959. * Adds an ambient color to the spherical polynomial
  5960. * @param color the color to add
  5961. */
  5962. addAmbient(color: Color3): void;
  5963. /**
  5964. * Scales the spherical polynomial by the given amount
  5965. * @param scale the amount to scale
  5966. */
  5967. scaleInPlace(scale: number): void;
  5968. /**
  5969. * Gets the spherical polynomial from harmonics
  5970. * @param harmonics the spherical harmonics
  5971. * @returns the spherical polynomial
  5972. */
  5973. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5974. /**
  5975. * Constructs a spherical polynomial from an array.
  5976. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5977. * @returns the spherical polynomial
  5978. */
  5979. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5983. import { Nullable } from "babylonjs/types";
  5984. /**
  5985. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5986. */
  5987. export interface CubeMapInfo {
  5988. /**
  5989. * The pixel array for the front face.
  5990. * This is stored in format, left to right, up to down format.
  5991. */
  5992. front: Nullable<ArrayBufferView>;
  5993. /**
  5994. * The pixel array for the back face.
  5995. * This is stored in format, left to right, up to down format.
  5996. */
  5997. back: Nullable<ArrayBufferView>;
  5998. /**
  5999. * The pixel array for the left face.
  6000. * This is stored in format, left to right, up to down format.
  6001. */
  6002. left: Nullable<ArrayBufferView>;
  6003. /**
  6004. * The pixel array for the right face.
  6005. * This is stored in format, left to right, up to down format.
  6006. */
  6007. right: Nullable<ArrayBufferView>;
  6008. /**
  6009. * The pixel array for the up face.
  6010. * This is stored in format, left to right, up to down format.
  6011. */
  6012. up: Nullable<ArrayBufferView>;
  6013. /**
  6014. * The pixel array for the down face.
  6015. * This is stored in format, left to right, up to down format.
  6016. */
  6017. down: Nullable<ArrayBufferView>;
  6018. /**
  6019. * The size of the cubemap stored.
  6020. *
  6021. * Each faces will be size * size pixels.
  6022. */
  6023. size: number;
  6024. /**
  6025. * The format of the texture.
  6026. *
  6027. * RGBA, RGB.
  6028. */
  6029. format: number;
  6030. /**
  6031. * The type of the texture data.
  6032. *
  6033. * UNSIGNED_INT, FLOAT.
  6034. */
  6035. type: number;
  6036. /**
  6037. * Specifies whether the texture is in gamma space.
  6038. */
  6039. gammaSpace: boolean;
  6040. }
  6041. /**
  6042. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6043. */
  6044. export class PanoramaToCubeMapTools {
  6045. private static FACE_FRONT;
  6046. private static FACE_BACK;
  6047. private static FACE_RIGHT;
  6048. private static FACE_LEFT;
  6049. private static FACE_DOWN;
  6050. private static FACE_UP;
  6051. /**
  6052. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6053. *
  6054. * @param float32Array The source data.
  6055. * @param inputWidth The width of the input panorama.
  6056. * @param inputHeight The height of the input panorama.
  6057. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6058. * @return The cubemap data
  6059. */
  6060. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6061. private static CreateCubemapTexture;
  6062. private static CalcProjectionSpherical;
  6063. }
  6064. }
  6065. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6066. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6068. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6069. /**
  6070. * Helper class dealing with the extraction of spherical polynomial dataArray
  6071. * from a cube map.
  6072. */
  6073. export class CubeMapToSphericalPolynomialTools {
  6074. private static FileFaces;
  6075. /**
  6076. * Converts a texture to the according Spherical Polynomial data.
  6077. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6078. *
  6079. * @param texture The texture to extract the information from.
  6080. * @return The Spherical Polynomial data.
  6081. */
  6082. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6083. /**
  6084. * Converts a cubemap to the according Spherical Polynomial data.
  6085. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6086. *
  6087. * @param cubeInfo The Cube map to extract the information from.
  6088. * @return The Spherical Polynomial data.
  6089. */
  6090. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6091. }
  6092. }
  6093. declare module "babylonjs/Engines/engineStore" {
  6094. import { Nullable } from "babylonjs/types";
  6095. import { Engine } from "babylonjs/Engines/engine";
  6096. import { Scene } from "babylonjs/scene";
  6097. /**
  6098. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6099. * during the life time of the application.
  6100. */
  6101. export class EngineStore {
  6102. /** Gets the list of created engines */
  6103. static Instances: import("babylonjs/Engines/engine").Engine[];
  6104. /**
  6105. * Gets the latest created engine
  6106. */
  6107. static readonly LastCreatedEngine: Nullable<Engine>;
  6108. /**
  6109. * Gets the latest created scene
  6110. */
  6111. static readonly LastCreatedScene: Nullable<Scene>;
  6112. }
  6113. }
  6114. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6115. /**
  6116. * Define options used to create a render target texture
  6117. */
  6118. export class RenderTargetCreationOptions {
  6119. /**
  6120. * Specifies is mipmaps must be generated
  6121. */
  6122. generateMipMaps?: boolean;
  6123. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6124. generateDepthBuffer?: boolean;
  6125. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6126. generateStencilBuffer?: boolean;
  6127. /** Defines texture type (int by default) */
  6128. type?: number;
  6129. /** Defines sampling mode (trilinear by default) */
  6130. samplingMode?: number;
  6131. /** Defines format (RGBA by default) */
  6132. format?: number;
  6133. }
  6134. }
  6135. declare module "babylonjs/States/alphaCullingState" {
  6136. /**
  6137. * @hidden
  6138. **/
  6139. export class _AlphaState {
  6140. private _isAlphaBlendDirty;
  6141. private _isBlendFunctionParametersDirty;
  6142. private _isBlendEquationParametersDirty;
  6143. private _isBlendConstantsDirty;
  6144. private _alphaBlend;
  6145. private _blendFunctionParameters;
  6146. private _blendEquationParameters;
  6147. private _blendConstants;
  6148. /**
  6149. * Initializes the state.
  6150. */
  6151. constructor();
  6152. readonly isDirty: boolean;
  6153. alphaBlend: boolean;
  6154. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6155. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6156. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module "babylonjs/States/depthCullingState" {
  6162. import { Nullable } from "babylonjs/types";
  6163. /**
  6164. * @hidden
  6165. **/
  6166. export class _DepthCullingState {
  6167. private _isDepthTestDirty;
  6168. private _isDepthMaskDirty;
  6169. private _isDepthFuncDirty;
  6170. private _isCullFaceDirty;
  6171. private _isCullDirty;
  6172. private _isZOffsetDirty;
  6173. private _isFrontFaceDirty;
  6174. private _depthTest;
  6175. private _depthMask;
  6176. private _depthFunc;
  6177. private _cull;
  6178. private _cullFace;
  6179. private _zOffset;
  6180. private _frontFace;
  6181. /**
  6182. * Initializes the state.
  6183. */
  6184. constructor();
  6185. readonly isDirty: boolean;
  6186. zOffset: number;
  6187. cullFace: Nullable<number>;
  6188. cull: Nullable<boolean>;
  6189. depthFunc: Nullable<number>;
  6190. depthMask: boolean;
  6191. depthTest: boolean;
  6192. frontFace: Nullable<number>;
  6193. reset(): void;
  6194. apply(gl: WebGLRenderingContext): void;
  6195. }
  6196. }
  6197. declare module "babylonjs/States/stencilState" {
  6198. /**
  6199. * @hidden
  6200. **/
  6201. export class _StencilState {
  6202. /** 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 */
  6203. static readonly ALWAYS: number;
  6204. /** Passed to stencilOperation to specify that stencil value must be kept */
  6205. static readonly KEEP: number;
  6206. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6207. static readonly REPLACE: number;
  6208. private _isStencilTestDirty;
  6209. private _isStencilMaskDirty;
  6210. private _isStencilFuncDirty;
  6211. private _isStencilOpDirty;
  6212. private _stencilTest;
  6213. private _stencilMask;
  6214. private _stencilFunc;
  6215. private _stencilFuncRef;
  6216. private _stencilFuncMask;
  6217. private _stencilOpStencilFail;
  6218. private _stencilOpDepthFail;
  6219. private _stencilOpStencilDepthPass;
  6220. readonly isDirty: boolean;
  6221. stencilFunc: number;
  6222. stencilFuncRef: number;
  6223. stencilFuncMask: number;
  6224. stencilOpStencilFail: number;
  6225. stencilOpDepthFail: number;
  6226. stencilOpStencilDepthPass: number;
  6227. stencilMask: number;
  6228. stencilTest: boolean;
  6229. constructor();
  6230. reset(): void;
  6231. apply(gl: WebGLRenderingContext): void;
  6232. }
  6233. }
  6234. declare module "babylonjs/States/index" {
  6235. export * from "babylonjs/States/alphaCullingState";
  6236. export * from "babylonjs/States/depthCullingState";
  6237. export * from "babylonjs/States/stencilState";
  6238. }
  6239. declare module "babylonjs/Instrumentation/timeToken" {
  6240. import { Nullable } from "babylonjs/types";
  6241. /**
  6242. * @hidden
  6243. **/
  6244. export class _TimeToken {
  6245. _startTimeQuery: Nullable<WebGLQuery>;
  6246. _endTimeQuery: Nullable<WebGLQuery>;
  6247. _timeElapsedQuery: Nullable<WebGLQuery>;
  6248. _timeElapsedQueryEnded: boolean;
  6249. }
  6250. }
  6251. declare module "babylonjs/Materials/Textures/internalTexture" {
  6252. import { Observable } from "babylonjs/Misc/observable";
  6253. import { Nullable, int } from "babylonjs/types";
  6254. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6255. import { Engine } from "babylonjs/Engines/engine";
  6256. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6257. /**
  6258. * Class used to store data associated with WebGL texture data for the engine
  6259. * This class should not be used directly
  6260. */
  6261. export class InternalTexture {
  6262. /** hidden */
  6263. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6264. /**
  6265. * The source of the texture data is unknown
  6266. */
  6267. static DATASOURCE_UNKNOWN: number;
  6268. /**
  6269. * Texture data comes from an URL
  6270. */
  6271. static DATASOURCE_URL: number;
  6272. /**
  6273. * Texture data is only used for temporary storage
  6274. */
  6275. static DATASOURCE_TEMP: number;
  6276. /**
  6277. * Texture data comes from raw data (ArrayBuffer)
  6278. */
  6279. static DATASOURCE_RAW: number;
  6280. /**
  6281. * Texture content is dynamic (video or dynamic texture)
  6282. */
  6283. static DATASOURCE_DYNAMIC: number;
  6284. /**
  6285. * Texture content is generated by rendering to it
  6286. */
  6287. static DATASOURCE_RENDERTARGET: number;
  6288. /**
  6289. * Texture content is part of a multi render target process
  6290. */
  6291. static DATASOURCE_MULTIRENDERTARGET: number;
  6292. /**
  6293. * Texture data comes from a cube data file
  6294. */
  6295. static DATASOURCE_CUBE: number;
  6296. /**
  6297. * Texture data comes from a raw cube data
  6298. */
  6299. static DATASOURCE_CUBERAW: number;
  6300. /**
  6301. * Texture data come from a prefiltered cube data file
  6302. */
  6303. static DATASOURCE_CUBEPREFILTERED: number;
  6304. /**
  6305. * Texture content is raw 3D data
  6306. */
  6307. static DATASOURCE_RAW3D: number;
  6308. /**
  6309. * Texture content is a depth texture
  6310. */
  6311. static DATASOURCE_DEPTHTEXTURE: number;
  6312. /**
  6313. * Texture data comes from a raw cube data encoded with RGBD
  6314. */
  6315. static DATASOURCE_CUBERAW_RGBD: number;
  6316. /**
  6317. * Defines if the texture is ready
  6318. */
  6319. isReady: boolean;
  6320. /**
  6321. * Defines if the texture is a cube texture
  6322. */
  6323. isCube: boolean;
  6324. /**
  6325. * Defines if the texture contains 3D data
  6326. */
  6327. is3D: boolean;
  6328. /**
  6329. * Defines if the texture contains multiview data
  6330. */
  6331. isMultiview: boolean;
  6332. /**
  6333. * Gets the URL used to load this texture
  6334. */
  6335. url: string;
  6336. /**
  6337. * Gets the sampling mode of the texture
  6338. */
  6339. samplingMode: number;
  6340. /**
  6341. * Gets a boolean indicating if the texture needs mipmaps generation
  6342. */
  6343. generateMipMaps: boolean;
  6344. /**
  6345. * Gets the number of samples used by the texture (WebGL2+ only)
  6346. */
  6347. samples: number;
  6348. /**
  6349. * Gets the type of the texture (int, float...)
  6350. */
  6351. type: number;
  6352. /**
  6353. * Gets the format of the texture (RGB, RGBA...)
  6354. */
  6355. format: number;
  6356. /**
  6357. * Observable called when the texture is loaded
  6358. */
  6359. onLoadedObservable: Observable<InternalTexture>;
  6360. /**
  6361. * Gets the width of the texture
  6362. */
  6363. width: number;
  6364. /**
  6365. * Gets the height of the texture
  6366. */
  6367. height: number;
  6368. /**
  6369. * Gets the depth of the texture
  6370. */
  6371. depth: number;
  6372. /**
  6373. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6374. */
  6375. baseWidth: number;
  6376. /**
  6377. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6378. */
  6379. baseHeight: number;
  6380. /**
  6381. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6382. */
  6383. baseDepth: number;
  6384. /**
  6385. * Gets a boolean indicating if the texture is inverted on Y axis
  6386. */
  6387. invertY: boolean;
  6388. /** @hidden */
  6389. _invertVScale: boolean;
  6390. /** @hidden */
  6391. _associatedChannel: number;
  6392. /** @hidden */
  6393. _dataSource: number;
  6394. /** @hidden */
  6395. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6396. /** @hidden */
  6397. _bufferView: Nullable<ArrayBufferView>;
  6398. /** @hidden */
  6399. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6400. /** @hidden */
  6401. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6402. /** @hidden */
  6403. _size: number;
  6404. /** @hidden */
  6405. _extension: string;
  6406. /** @hidden */
  6407. _files: Nullable<string[]>;
  6408. /** @hidden */
  6409. _workingCanvas: Nullable<HTMLCanvasElement>;
  6410. /** @hidden */
  6411. _workingContext: Nullable<CanvasRenderingContext2D>;
  6412. /** @hidden */
  6413. _framebuffer: Nullable<WebGLFramebuffer>;
  6414. /** @hidden */
  6415. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6416. /** @hidden */
  6417. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6418. /** @hidden */
  6419. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6420. /** @hidden */
  6421. _attachments: Nullable<number[]>;
  6422. /** @hidden */
  6423. _cachedCoordinatesMode: Nullable<number>;
  6424. /** @hidden */
  6425. _cachedWrapU: Nullable<number>;
  6426. /** @hidden */
  6427. _cachedWrapV: Nullable<number>;
  6428. /** @hidden */
  6429. _cachedWrapR: Nullable<number>;
  6430. /** @hidden */
  6431. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6432. /** @hidden */
  6433. _isDisabled: boolean;
  6434. /** @hidden */
  6435. _compression: Nullable<string>;
  6436. /** @hidden */
  6437. _generateStencilBuffer: boolean;
  6438. /** @hidden */
  6439. _generateDepthBuffer: boolean;
  6440. /** @hidden */
  6441. _comparisonFunction: number;
  6442. /** @hidden */
  6443. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6444. /** @hidden */
  6445. _lodGenerationScale: number;
  6446. /** @hidden */
  6447. _lodGenerationOffset: number;
  6448. /** @hidden */
  6449. _colorTextureArray: Nullable<WebGLTexture>;
  6450. /** @hidden */
  6451. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6452. /** @hidden */
  6453. _lodTextureHigh: Nullable<BaseTexture>;
  6454. /** @hidden */
  6455. _lodTextureMid: Nullable<BaseTexture>;
  6456. /** @hidden */
  6457. _lodTextureLow: Nullable<BaseTexture>;
  6458. /** @hidden */
  6459. _isRGBD: boolean;
  6460. /** @hidden */
  6461. _webGLTexture: Nullable<WebGLTexture>;
  6462. /** @hidden */
  6463. _references: number;
  6464. private _engine;
  6465. /**
  6466. * Gets the Engine the texture belongs to.
  6467. * @returns The babylon engine
  6468. */
  6469. getEngine(): Engine;
  6470. /**
  6471. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6472. */
  6473. readonly dataSource: number;
  6474. /**
  6475. * Creates a new InternalTexture
  6476. * @param engine defines the engine to use
  6477. * @param dataSource defines the type of data that will be used
  6478. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6479. */
  6480. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6481. /**
  6482. * Increments the number of references (ie. the number of Texture that point to it)
  6483. */
  6484. incrementReferences(): void;
  6485. /**
  6486. * Change the size of the texture (not the size of the content)
  6487. * @param width defines the new width
  6488. * @param height defines the new height
  6489. * @param depth defines the new depth (1 by default)
  6490. */
  6491. updateSize(width: int, height: int, depth?: int): void;
  6492. /** @hidden */
  6493. _rebuild(): void;
  6494. /** @hidden */
  6495. _swapAndDie(target: InternalTexture): void;
  6496. /**
  6497. * Dispose the current allocated resources
  6498. */
  6499. dispose(): void;
  6500. }
  6501. }
  6502. declare module "babylonjs/Animations/easing" {
  6503. /**
  6504. * This represents the main contract an easing function should follow.
  6505. * Easing functions are used throughout the animation system.
  6506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6507. */
  6508. export interface IEasingFunction {
  6509. /**
  6510. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6511. * of the easing function.
  6512. * The link below provides some of the most common examples of easing functions.
  6513. * @see https://easings.net/
  6514. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6515. * @returns the corresponding value on the curve defined by the easing function
  6516. */
  6517. ease(gradient: number): number;
  6518. }
  6519. /**
  6520. * Base class used for every default easing function.
  6521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6522. */
  6523. export class EasingFunction implements IEasingFunction {
  6524. /**
  6525. * Interpolation follows the mathematical formula associated with the easing function.
  6526. */
  6527. static readonly EASINGMODE_EASEIN: number;
  6528. /**
  6529. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6530. */
  6531. static readonly EASINGMODE_EASEOUT: number;
  6532. /**
  6533. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6534. */
  6535. static readonly EASINGMODE_EASEINOUT: number;
  6536. private _easingMode;
  6537. /**
  6538. * Sets the easing mode of the current function.
  6539. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6540. */
  6541. setEasingMode(easingMode: number): void;
  6542. /**
  6543. * Gets the current easing mode.
  6544. * @returns the easing mode
  6545. */
  6546. getEasingMode(): number;
  6547. /**
  6548. * @hidden
  6549. */
  6550. easeInCore(gradient: number): number;
  6551. /**
  6552. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6553. * of the easing function.
  6554. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6555. * @returns the corresponding value on the curve defined by the easing function
  6556. */
  6557. ease(gradient: number): number;
  6558. }
  6559. /**
  6560. * Easing function with a circle shape (see link below).
  6561. * @see https://easings.net/#easeInCirc
  6562. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6563. */
  6564. export class CircleEase extends EasingFunction implements IEasingFunction {
  6565. /** @hidden */
  6566. easeInCore(gradient: number): number;
  6567. }
  6568. /**
  6569. * Easing function with a ease back shape (see link below).
  6570. * @see https://easings.net/#easeInBack
  6571. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6572. */
  6573. export class BackEase extends EasingFunction implements IEasingFunction {
  6574. /** Defines the amplitude of the function */
  6575. amplitude: number;
  6576. /**
  6577. * Instantiates a back ease easing
  6578. * @see https://easings.net/#easeInBack
  6579. * @param amplitude Defines the amplitude of the function
  6580. */
  6581. constructor(
  6582. /** Defines the amplitude of the function */
  6583. amplitude?: number);
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a bouncing shape (see link below).
  6589. * @see https://easings.net/#easeInBounce
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class BounceEase extends EasingFunction implements IEasingFunction {
  6593. /** Defines the number of bounces */
  6594. bounces: number;
  6595. /** Defines the amplitude of the bounce */
  6596. bounciness: number;
  6597. /**
  6598. * Instantiates a bounce easing
  6599. * @see https://easings.net/#easeInBounce
  6600. * @param bounces Defines the number of bounces
  6601. * @param bounciness Defines the amplitude of the bounce
  6602. */
  6603. constructor(
  6604. /** Defines the number of bounces */
  6605. bounces?: number,
  6606. /** Defines the amplitude of the bounce */
  6607. bounciness?: number);
  6608. /** @hidden */
  6609. easeInCore(gradient: number): number;
  6610. }
  6611. /**
  6612. * Easing function with a power of 3 shape (see link below).
  6613. * @see https://easings.net/#easeInCubic
  6614. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6615. */
  6616. export class CubicEase extends EasingFunction implements IEasingFunction {
  6617. /** @hidden */
  6618. easeInCore(gradient: number): number;
  6619. }
  6620. /**
  6621. * Easing function with an elastic shape (see link below).
  6622. * @see https://easings.net/#easeInElastic
  6623. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6624. */
  6625. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6626. /** Defines the number of oscillations*/
  6627. oscillations: number;
  6628. /** Defines the amplitude of the oscillations*/
  6629. springiness: number;
  6630. /**
  6631. * Instantiates an elastic easing function
  6632. * @see https://easings.net/#easeInElastic
  6633. * @param oscillations Defines the number of oscillations
  6634. * @param springiness Defines the amplitude of the oscillations
  6635. */
  6636. constructor(
  6637. /** Defines the number of oscillations*/
  6638. oscillations?: number,
  6639. /** Defines the amplitude of the oscillations*/
  6640. springiness?: number);
  6641. /** @hidden */
  6642. easeInCore(gradient: number): number;
  6643. }
  6644. /**
  6645. * Easing function with an exponential shape (see link below).
  6646. * @see https://easings.net/#easeInExpo
  6647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6648. */
  6649. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6650. /** Defines the exponent of the function */
  6651. exponent: number;
  6652. /**
  6653. * Instantiates an exponential easing function
  6654. * @see https://easings.net/#easeInExpo
  6655. * @param exponent Defines the exponent of the function
  6656. */
  6657. constructor(
  6658. /** Defines the exponent of the function */
  6659. exponent?: number);
  6660. /** @hidden */
  6661. easeInCore(gradient: number): number;
  6662. }
  6663. /**
  6664. * Easing function with a power shape (see link below).
  6665. * @see https://easings.net/#easeInQuad
  6666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6667. */
  6668. export class PowerEase extends EasingFunction implements IEasingFunction {
  6669. /** Defines the power of the function */
  6670. power: number;
  6671. /**
  6672. * Instantiates an power base easing function
  6673. * @see https://easings.net/#easeInQuad
  6674. * @param power Defines the power of the function
  6675. */
  6676. constructor(
  6677. /** Defines the power of the function */
  6678. power?: number);
  6679. /** @hidden */
  6680. easeInCore(gradient: number): number;
  6681. }
  6682. /**
  6683. * Easing function with a power of 2 shape (see link below).
  6684. * @see https://easings.net/#easeInQuad
  6685. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6686. */
  6687. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6688. /** @hidden */
  6689. easeInCore(gradient: number): number;
  6690. }
  6691. /**
  6692. * Easing function with a power of 4 shape (see link below).
  6693. * @see https://easings.net/#easeInQuart
  6694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6695. */
  6696. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6697. /** @hidden */
  6698. easeInCore(gradient: number): number;
  6699. }
  6700. /**
  6701. * Easing function with a power of 5 shape (see link below).
  6702. * @see https://easings.net/#easeInQuint
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6706. /** @hidden */
  6707. easeInCore(gradient: number): number;
  6708. }
  6709. /**
  6710. * Easing function with a sin shape (see link below).
  6711. * @see https://easings.net/#easeInSine
  6712. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6713. */
  6714. export class SineEase extends EasingFunction implements IEasingFunction {
  6715. /** @hidden */
  6716. easeInCore(gradient: number): number;
  6717. }
  6718. /**
  6719. * Easing function with a bezier shape (see link below).
  6720. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6721. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6722. */
  6723. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6724. /** Defines the x component of the start tangent in the bezier curve */
  6725. x1: number;
  6726. /** Defines the y component of the start tangent in the bezier curve */
  6727. y1: number;
  6728. /** Defines the x component of the end tangent in the bezier curve */
  6729. x2: number;
  6730. /** Defines the y component of the end tangent in the bezier curve */
  6731. y2: number;
  6732. /**
  6733. * Instantiates a bezier function
  6734. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6735. * @param x1 Defines the x component of the start tangent in the bezier curve
  6736. * @param y1 Defines the y component of the start tangent in the bezier curve
  6737. * @param x2 Defines the x component of the end tangent in the bezier curve
  6738. * @param y2 Defines the y component of the end tangent in the bezier curve
  6739. */
  6740. constructor(
  6741. /** Defines the x component of the start tangent in the bezier curve */
  6742. x1?: number,
  6743. /** Defines the y component of the start tangent in the bezier curve */
  6744. y1?: number,
  6745. /** Defines the x component of the end tangent in the bezier curve */
  6746. x2?: number,
  6747. /** Defines the y component of the end tangent in the bezier curve */
  6748. y2?: number);
  6749. /** @hidden */
  6750. easeInCore(gradient: number): number;
  6751. }
  6752. }
  6753. declare module "babylonjs/Animations/animationKey" {
  6754. /**
  6755. * Defines an interface which represents an animation key frame
  6756. */
  6757. export interface IAnimationKey {
  6758. /**
  6759. * Frame of the key frame
  6760. */
  6761. frame: number;
  6762. /**
  6763. * Value at the specifies key frame
  6764. */
  6765. value: any;
  6766. /**
  6767. * The input tangent for the cubic hermite spline
  6768. */
  6769. inTangent?: any;
  6770. /**
  6771. * The output tangent for the cubic hermite spline
  6772. */
  6773. outTangent?: any;
  6774. /**
  6775. * The animation interpolation type
  6776. */
  6777. interpolation?: AnimationKeyInterpolation;
  6778. }
  6779. /**
  6780. * Enum for the animation key frame interpolation type
  6781. */
  6782. export enum AnimationKeyInterpolation {
  6783. /**
  6784. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6785. */
  6786. STEP = 1
  6787. }
  6788. }
  6789. declare module "babylonjs/Animations/animationRange" {
  6790. /**
  6791. * Represents the range of an animation
  6792. */
  6793. export class AnimationRange {
  6794. /**The name of the animation range**/
  6795. name: string;
  6796. /**The starting frame of the animation */
  6797. from: number;
  6798. /**The ending frame of the animation*/
  6799. to: number;
  6800. /**
  6801. * Initializes the range of an animation
  6802. * @param name The name of the animation range
  6803. * @param from The starting frame of the animation
  6804. * @param to The ending frame of the animation
  6805. */
  6806. constructor(
  6807. /**The name of the animation range**/
  6808. name: string,
  6809. /**The starting frame of the animation */
  6810. from: number,
  6811. /**The ending frame of the animation*/
  6812. to: number);
  6813. /**
  6814. * Makes a copy of the animation range
  6815. * @returns A copy of the animation range
  6816. */
  6817. clone(): AnimationRange;
  6818. }
  6819. }
  6820. declare module "babylonjs/Animations/animationEvent" {
  6821. /**
  6822. * Composed of a frame, and an action function
  6823. */
  6824. export class AnimationEvent {
  6825. /** The frame for which the event is triggered **/
  6826. frame: number;
  6827. /** The event to perform when triggered **/
  6828. action: (currentFrame: number) => void;
  6829. /** Specifies if the event should be triggered only once**/
  6830. onlyOnce?: boolean | undefined;
  6831. /**
  6832. * Specifies if the animation event is done
  6833. */
  6834. isDone: boolean;
  6835. /**
  6836. * Initializes the animation event
  6837. * @param frame The frame for which the event is triggered
  6838. * @param action The event to perform when triggered
  6839. * @param onlyOnce Specifies if the event should be triggered only once
  6840. */
  6841. constructor(
  6842. /** The frame for which the event is triggered **/
  6843. frame: number,
  6844. /** The event to perform when triggered **/
  6845. action: (currentFrame: number) => void,
  6846. /** Specifies if the event should be triggered only once**/
  6847. onlyOnce?: boolean | undefined);
  6848. /** @hidden */
  6849. _clone(): AnimationEvent;
  6850. }
  6851. }
  6852. declare module "babylonjs/Behaviors/behavior" {
  6853. import { Nullable } from "babylonjs/types";
  6854. /**
  6855. * Interface used to define a behavior
  6856. */
  6857. export interface Behavior<T> {
  6858. /** gets or sets behavior's name */
  6859. name: string;
  6860. /**
  6861. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6862. */
  6863. init(): void;
  6864. /**
  6865. * Called when the behavior is attached to a target
  6866. * @param target defines the target where the behavior is attached to
  6867. */
  6868. attach(target: T): void;
  6869. /**
  6870. * Called when the behavior is detached from its target
  6871. */
  6872. detach(): void;
  6873. }
  6874. /**
  6875. * Interface implemented by classes supporting behaviors
  6876. */
  6877. export interface IBehaviorAware<T> {
  6878. /**
  6879. * Attach a behavior
  6880. * @param behavior defines the behavior to attach
  6881. * @returns the current host
  6882. */
  6883. addBehavior(behavior: Behavior<T>): T;
  6884. /**
  6885. * Remove a behavior from the current object
  6886. * @param behavior defines the behavior to detach
  6887. * @returns the current host
  6888. */
  6889. removeBehavior(behavior: Behavior<T>): T;
  6890. /**
  6891. * Gets a behavior using its name to search
  6892. * @param name defines the name to search
  6893. * @returns the behavior or null if not found
  6894. */
  6895. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6896. }
  6897. }
  6898. declare module "babylonjs/Collisions/intersectionInfo" {
  6899. import { Nullable } from "babylonjs/types";
  6900. /**
  6901. * @hidden
  6902. */
  6903. export class IntersectionInfo {
  6904. bu: Nullable<number>;
  6905. bv: Nullable<number>;
  6906. distance: number;
  6907. faceId: number;
  6908. subMeshId: number;
  6909. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6910. }
  6911. }
  6912. declare module "babylonjs/Culling/boundingSphere" {
  6913. import { DeepImmutable } from "babylonjs/types";
  6914. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6915. /**
  6916. * Class used to store bounding sphere information
  6917. */
  6918. export class BoundingSphere {
  6919. /**
  6920. * Gets the center of the bounding sphere in local space
  6921. */
  6922. readonly center: Vector3;
  6923. /**
  6924. * Radius of the bounding sphere in local space
  6925. */
  6926. radius: number;
  6927. /**
  6928. * Gets the center of the bounding sphere in world space
  6929. */
  6930. readonly centerWorld: Vector3;
  6931. /**
  6932. * Radius of the bounding sphere in world space
  6933. */
  6934. radiusWorld: number;
  6935. /**
  6936. * Gets the minimum vector in local space
  6937. */
  6938. readonly minimum: Vector3;
  6939. /**
  6940. * Gets the maximum vector in local space
  6941. */
  6942. readonly maximum: Vector3;
  6943. private _worldMatrix;
  6944. private static readonly TmpVector3;
  6945. /**
  6946. * Creates a new bounding sphere
  6947. * @param min defines the minimum vector (in local space)
  6948. * @param max defines the maximum vector (in local space)
  6949. * @param worldMatrix defines the new world matrix
  6950. */
  6951. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6952. /**
  6953. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6954. * @param min defines the new minimum vector (in local space)
  6955. * @param max defines the new maximum vector (in local space)
  6956. * @param worldMatrix defines the new world matrix
  6957. */
  6958. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6959. /**
  6960. * Scale the current bounding sphere by applying a scale factor
  6961. * @param factor defines the scale factor to apply
  6962. * @returns the current bounding box
  6963. */
  6964. scale(factor: number): BoundingSphere;
  6965. /**
  6966. * Gets the world matrix of the bounding box
  6967. * @returns a matrix
  6968. */
  6969. getWorldMatrix(): DeepImmutable<Matrix>;
  6970. /** @hidden */
  6971. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6972. /**
  6973. * Tests if the bounding sphere is intersecting the frustum planes
  6974. * @param frustumPlanes defines the frustum planes to test
  6975. * @returns true if there is an intersection
  6976. */
  6977. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6978. /**
  6979. * Tests if the bounding sphere center is in between the frustum planes.
  6980. * Used for optimistic fast inclusion.
  6981. * @param frustumPlanes defines the frustum planes to test
  6982. * @returns true if the sphere center is in between the frustum planes
  6983. */
  6984. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6985. /**
  6986. * Tests if a point is inside the bounding sphere
  6987. * @param point defines the point to test
  6988. * @returns true if the point is inside the bounding sphere
  6989. */
  6990. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6991. /**
  6992. * Checks if two sphere intersct
  6993. * @param sphere0 sphere 0
  6994. * @param sphere1 sphere 1
  6995. * @returns true if the speres intersect
  6996. */
  6997. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6998. }
  6999. }
  7000. declare module "babylonjs/Culling/boundingBox" {
  7001. import { DeepImmutable } from "babylonjs/types";
  7002. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7003. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7004. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7005. /**
  7006. * Class used to store bounding box information
  7007. */
  7008. export class BoundingBox implements ICullable {
  7009. /**
  7010. * Gets the 8 vectors representing the bounding box in local space
  7011. */
  7012. readonly vectors: Vector3[];
  7013. /**
  7014. * Gets the center of the bounding box in local space
  7015. */
  7016. readonly center: Vector3;
  7017. /**
  7018. * Gets the center of the bounding box in world space
  7019. */
  7020. readonly centerWorld: Vector3;
  7021. /**
  7022. * Gets the extend size in local space
  7023. */
  7024. readonly extendSize: Vector3;
  7025. /**
  7026. * Gets the extend size in world space
  7027. */
  7028. readonly extendSizeWorld: Vector3;
  7029. /**
  7030. * Gets the OBB (object bounding box) directions
  7031. */
  7032. readonly directions: Vector3[];
  7033. /**
  7034. * Gets the 8 vectors representing the bounding box in world space
  7035. */
  7036. readonly vectorsWorld: Vector3[];
  7037. /**
  7038. * Gets the minimum vector in world space
  7039. */
  7040. readonly minimumWorld: Vector3;
  7041. /**
  7042. * Gets the maximum vector in world space
  7043. */
  7044. readonly maximumWorld: Vector3;
  7045. /**
  7046. * Gets the minimum vector in local space
  7047. */
  7048. readonly minimum: Vector3;
  7049. /**
  7050. * Gets the maximum vector in local space
  7051. */
  7052. readonly maximum: Vector3;
  7053. private _worldMatrix;
  7054. private static readonly TmpVector3;
  7055. /**
  7056. * @hidden
  7057. */
  7058. _tag: number;
  7059. /**
  7060. * Creates a new bounding box
  7061. * @param min defines the minimum vector (in local space)
  7062. * @param max defines the maximum vector (in local space)
  7063. * @param worldMatrix defines the new world matrix
  7064. */
  7065. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7066. /**
  7067. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7068. * @param min defines the new minimum vector (in local space)
  7069. * @param max defines the new maximum vector (in local space)
  7070. * @param worldMatrix defines the new world matrix
  7071. */
  7072. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7073. /**
  7074. * Scale the current bounding box by applying a scale factor
  7075. * @param factor defines the scale factor to apply
  7076. * @returns the current bounding box
  7077. */
  7078. scale(factor: number): BoundingBox;
  7079. /**
  7080. * Gets the world matrix of the bounding box
  7081. * @returns a matrix
  7082. */
  7083. getWorldMatrix(): DeepImmutable<Matrix>;
  7084. /** @hidden */
  7085. _update(world: DeepImmutable<Matrix>): void;
  7086. /**
  7087. * Tests if the bounding box is intersecting the frustum planes
  7088. * @param frustumPlanes defines the frustum planes to test
  7089. * @returns true if there is an intersection
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7092. /**
  7093. * Tests if the bounding box is entirely inside the frustum planes
  7094. * @param frustumPlanes defines the frustum planes to test
  7095. * @returns true if there is an inclusion
  7096. */
  7097. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7098. /**
  7099. * Tests if a point is inside the bounding box
  7100. * @param point defines the point to test
  7101. * @returns true if the point is inside the bounding box
  7102. */
  7103. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7104. /**
  7105. * Tests if the bounding box intersects with a bounding sphere
  7106. * @param sphere defines the sphere to test
  7107. * @returns true if there is an intersection
  7108. */
  7109. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7110. /**
  7111. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7112. * @param min defines the min vector to use
  7113. * @param max defines the max vector to use
  7114. * @returns true if there is an intersection
  7115. */
  7116. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7117. /**
  7118. * Tests if two bounding boxes are intersections
  7119. * @param box0 defines the first box to test
  7120. * @param box1 defines the second box to test
  7121. * @returns true if there is an intersection
  7122. */
  7123. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7124. /**
  7125. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7126. * @param minPoint defines the minimum vector of the bounding box
  7127. * @param maxPoint defines the maximum vector of the bounding box
  7128. * @param sphereCenter defines the sphere center
  7129. * @param sphereRadius defines the sphere radius
  7130. * @returns true if there is an intersection
  7131. */
  7132. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7133. /**
  7134. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7135. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7136. * @param frustumPlanes defines the frustum planes to test
  7137. * @return true if there is an inclusion
  7138. */
  7139. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7140. /**
  7141. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7142. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7143. * @param frustumPlanes defines the frustum planes to test
  7144. * @return true if there is an intersection
  7145. */
  7146. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. }
  7148. }
  7149. declare module "babylonjs/Collisions/collider" {
  7150. import { Nullable, IndicesArray } from "babylonjs/types";
  7151. import { Vector3, Plane } from "babylonjs/Maths/math";
  7152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7153. /** @hidden */
  7154. export class Collider {
  7155. /** Define if a collision was found */
  7156. collisionFound: boolean;
  7157. /**
  7158. * Define last intersection point in local space
  7159. */
  7160. intersectionPoint: Vector3;
  7161. /**
  7162. * Define last collided mesh
  7163. */
  7164. collidedMesh: Nullable<AbstractMesh>;
  7165. private _collisionPoint;
  7166. private _planeIntersectionPoint;
  7167. private _tempVector;
  7168. private _tempVector2;
  7169. private _tempVector3;
  7170. private _tempVector4;
  7171. private _edge;
  7172. private _baseToVertex;
  7173. private _destinationPoint;
  7174. private _slidePlaneNormal;
  7175. private _displacementVector;
  7176. /** @hidden */
  7177. _radius: Vector3;
  7178. /** @hidden */
  7179. _retry: number;
  7180. private _velocity;
  7181. private _basePoint;
  7182. private _epsilon;
  7183. /** @hidden */
  7184. _velocityWorldLength: number;
  7185. /** @hidden */
  7186. _basePointWorld: Vector3;
  7187. private _velocityWorld;
  7188. private _normalizedVelocity;
  7189. /** @hidden */
  7190. _initialVelocity: Vector3;
  7191. /** @hidden */
  7192. _initialPosition: Vector3;
  7193. private _nearestDistance;
  7194. private _collisionMask;
  7195. collisionMask: number;
  7196. /**
  7197. * Gets the plane normal used to compute the sliding response (in local space)
  7198. */
  7199. readonly slidePlaneNormal: Vector3;
  7200. /** @hidden */
  7201. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7202. /** @hidden */
  7203. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7204. /** @hidden */
  7205. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7206. /** @hidden */
  7207. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7208. /** @hidden */
  7209. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7210. /** @hidden */
  7211. _getResponse(pos: Vector3, vel: Vector3): void;
  7212. }
  7213. }
  7214. declare module "babylonjs/Culling/boundingInfo" {
  7215. import { DeepImmutable } from "babylonjs/types";
  7216. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7217. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7218. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7219. import { Collider } from "babylonjs/Collisions/collider";
  7220. /**
  7221. * Interface for cullable objects
  7222. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7223. */
  7224. export interface ICullable {
  7225. /**
  7226. * Checks if the object or part of the object is in the frustum
  7227. * @param frustumPlanes Camera near/planes
  7228. * @returns true if the object is in frustum otherwise false
  7229. */
  7230. isInFrustum(frustumPlanes: Plane[]): boolean;
  7231. /**
  7232. * Checks if a cullable object (mesh...) is in the camera frustum
  7233. * Unlike isInFrustum this cheks the full bounding box
  7234. * @param frustumPlanes Camera near/planes
  7235. * @returns true if the object is in frustum otherwise false
  7236. */
  7237. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7238. }
  7239. /**
  7240. * Info for a bounding data of a mesh
  7241. */
  7242. export class BoundingInfo implements ICullable {
  7243. /**
  7244. * Bounding box for the mesh
  7245. */
  7246. readonly boundingBox: BoundingBox;
  7247. /**
  7248. * Bounding sphere for the mesh
  7249. */
  7250. readonly boundingSphere: BoundingSphere;
  7251. private _isLocked;
  7252. private static readonly TmpVector3;
  7253. /**
  7254. * Constructs bounding info
  7255. * @param minimum min vector of the bounding box/sphere
  7256. * @param maximum max vector of the bounding box/sphere
  7257. * @param worldMatrix defines the new world matrix
  7258. */
  7259. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7260. /**
  7261. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7262. * @param min defines the new minimum vector (in local space)
  7263. * @param max defines the new maximum vector (in local space)
  7264. * @param worldMatrix defines the new world matrix
  7265. */
  7266. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7267. /**
  7268. * min vector of the bounding box/sphere
  7269. */
  7270. readonly minimum: Vector3;
  7271. /**
  7272. * max vector of the bounding box/sphere
  7273. */
  7274. readonly maximum: Vector3;
  7275. /**
  7276. * If the info is locked and won't be updated to avoid perf overhead
  7277. */
  7278. isLocked: boolean;
  7279. /**
  7280. * Updates the bounding sphere and box
  7281. * @param world world matrix to be used to update
  7282. */
  7283. update(world: DeepImmutable<Matrix>): void;
  7284. /**
  7285. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7286. * @param center New center of the bounding info
  7287. * @param extend New extend of the bounding info
  7288. * @returns the current bounding info
  7289. */
  7290. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7291. /**
  7292. * Scale the current bounding info by applying a scale factor
  7293. * @param factor defines the scale factor to apply
  7294. * @returns the current bounding info
  7295. */
  7296. scale(factor: number): BoundingInfo;
  7297. /**
  7298. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7299. * @param frustumPlanes defines the frustum to test
  7300. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7301. * @returns true if the bounding info is in the frustum planes
  7302. */
  7303. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7304. /**
  7305. * Gets the world distance between the min and max points of the bounding box
  7306. */
  7307. readonly diagonalLength: number;
  7308. /**
  7309. * Checks if a cullable object (mesh...) is in the camera frustum
  7310. * Unlike isInFrustum this cheks the full bounding box
  7311. * @param frustumPlanes Camera near/planes
  7312. * @returns true if the object is in frustum otherwise false
  7313. */
  7314. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7315. /** @hidden */
  7316. _checkCollision(collider: Collider): boolean;
  7317. /**
  7318. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7319. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7320. * @param point the point to check intersection with
  7321. * @returns if the point intersects
  7322. */
  7323. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7324. /**
  7325. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7326. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7327. * @param boundingInfo the bounding info to check intersection with
  7328. * @param precise if the intersection should be done using OBB
  7329. * @returns if the bounding info intersects
  7330. */
  7331. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7332. }
  7333. }
  7334. declare module "babylonjs/Misc/smartArray" {
  7335. /**
  7336. * Defines an array and its length.
  7337. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7338. */
  7339. export interface ISmartArrayLike<T> {
  7340. /**
  7341. * The data of the array.
  7342. */
  7343. data: Array<T>;
  7344. /**
  7345. * The active length of the array.
  7346. */
  7347. length: number;
  7348. }
  7349. /**
  7350. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7351. */
  7352. export class SmartArray<T> implements ISmartArrayLike<T> {
  7353. /**
  7354. * The full set of data from the array.
  7355. */
  7356. data: Array<T>;
  7357. /**
  7358. * The active length of the array.
  7359. */
  7360. length: number;
  7361. protected _id: number;
  7362. /**
  7363. * Instantiates a Smart Array.
  7364. * @param capacity defines the default capacity of the array.
  7365. */
  7366. constructor(capacity: number);
  7367. /**
  7368. * Pushes a value at the end of the active data.
  7369. * @param value defines the object to push in the array.
  7370. */
  7371. push(value: T): void;
  7372. /**
  7373. * Iterates over the active data and apply the lambda to them.
  7374. * @param func defines the action to apply on each value.
  7375. */
  7376. forEach(func: (content: T) => void): void;
  7377. /**
  7378. * Sorts the full sets of data.
  7379. * @param compareFn defines the comparison function to apply.
  7380. */
  7381. sort(compareFn: (a: T, b: T) => number): void;
  7382. /**
  7383. * Resets the active data to an empty array.
  7384. */
  7385. reset(): void;
  7386. /**
  7387. * Releases all the data from the array as well as the array.
  7388. */
  7389. dispose(): void;
  7390. /**
  7391. * Concats the active data with a given array.
  7392. * @param array defines the data to concatenate with.
  7393. */
  7394. concat(array: any): void;
  7395. /**
  7396. * Returns the position of a value in the active data.
  7397. * @param value defines the value to find the index for
  7398. * @returns the index if found in the active data otherwise -1
  7399. */
  7400. indexOf(value: T): number;
  7401. /**
  7402. * Returns whether an element is part of the active data.
  7403. * @param value defines the value to look for
  7404. * @returns true if found in the active data otherwise false
  7405. */
  7406. contains(value: T): boolean;
  7407. private static _GlobalId;
  7408. }
  7409. /**
  7410. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7411. * The data in this array can only be present once
  7412. */
  7413. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7414. private _duplicateId;
  7415. /**
  7416. * Pushes a value at the end of the active data.
  7417. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7418. * @param value defines the object to push in the array.
  7419. */
  7420. push(value: T): void;
  7421. /**
  7422. * Pushes a value at the end of the active data.
  7423. * If the data is already present, it won t be added again
  7424. * @param value defines the object to push in the array.
  7425. * @returns true if added false if it was already present
  7426. */
  7427. pushNoDuplicate(value: T): boolean;
  7428. /**
  7429. * Resets the active data to an empty array.
  7430. */
  7431. reset(): void;
  7432. /**
  7433. * Concats the active data with a given array.
  7434. * This ensures no dupplicate will be present in the result.
  7435. * @param array defines the data to concatenate with.
  7436. */
  7437. concatWithNoDuplicate(array: any): void;
  7438. }
  7439. }
  7440. declare module "babylonjs/Materials/multiMaterial" {
  7441. import { Nullable } from "babylonjs/types";
  7442. import { Scene } from "babylonjs/scene";
  7443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7444. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7446. import { Material } from "babylonjs/Materials/material";
  7447. /**
  7448. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7449. * separate meshes. This can be use to improve performances.
  7450. * @see http://doc.babylonjs.com/how_to/multi_materials
  7451. */
  7452. export class MultiMaterial extends Material {
  7453. private _subMaterials;
  7454. /**
  7455. * Gets or Sets the list of Materials used within the multi material.
  7456. * They need to be ordered according to the submeshes order in the associated mesh
  7457. */
  7458. subMaterials: Nullable<Material>[];
  7459. /**
  7460. * Function used to align with Node.getChildren()
  7461. * @returns the list of Materials used within the multi material
  7462. */
  7463. getChildren(): Nullable<Material>[];
  7464. /**
  7465. * Instantiates a new Multi Material
  7466. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7467. * separate meshes. This can be use to improve performances.
  7468. * @see http://doc.babylonjs.com/how_to/multi_materials
  7469. * @param name Define the name in the scene
  7470. * @param scene Define the scene the material belongs to
  7471. */
  7472. constructor(name: string, scene: Scene);
  7473. private _hookArray;
  7474. /**
  7475. * Get one of the submaterial by its index in the submaterials array
  7476. * @param index The index to look the sub material at
  7477. * @returns The Material if the index has been defined
  7478. */
  7479. getSubMaterial(index: number): Nullable<Material>;
  7480. /**
  7481. * Get the list of active textures for the whole sub materials list.
  7482. * @returns All the textures that will be used during the rendering
  7483. */
  7484. getActiveTextures(): BaseTexture[];
  7485. /**
  7486. * Gets the current class name of the material e.g. "MultiMaterial"
  7487. * Mainly use in serialization.
  7488. * @returns the class name
  7489. */
  7490. getClassName(): string;
  7491. /**
  7492. * Checks if the material is ready to render the requested sub mesh
  7493. * @param mesh Define the mesh the submesh belongs to
  7494. * @param subMesh Define the sub mesh to look readyness for
  7495. * @param useInstances Define whether or not the material is used with instances
  7496. * @returns true if ready, otherwise false
  7497. */
  7498. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7499. /**
  7500. * Clones the current material and its related sub materials
  7501. * @param name Define the name of the newly cloned material
  7502. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7503. * @returns the cloned material
  7504. */
  7505. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7506. /**
  7507. * Serializes the materials into a JSON representation.
  7508. * @returns the JSON representation
  7509. */
  7510. serialize(): any;
  7511. /**
  7512. * Dispose the material and release its associated resources
  7513. * @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)
  7514. * @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)
  7515. * @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)
  7516. */
  7517. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7518. /**
  7519. * Creates a MultiMaterial from parsed MultiMaterial data.
  7520. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7521. * @param scene defines the hosting scene
  7522. * @returns a new MultiMaterial
  7523. */
  7524. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7525. }
  7526. }
  7527. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7528. /**
  7529. * Class used to represent data loading progression
  7530. */
  7531. export class SceneLoaderFlags {
  7532. private static _ForceFullSceneLoadingForIncremental;
  7533. private static _ShowLoadingScreen;
  7534. private static _CleanBoneMatrixWeights;
  7535. private static _loggingLevel;
  7536. /**
  7537. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7538. */
  7539. static ForceFullSceneLoadingForIncremental: boolean;
  7540. /**
  7541. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7542. */
  7543. static ShowLoadingScreen: boolean;
  7544. /**
  7545. * Defines the current logging level (while loading the scene)
  7546. * @ignorenaming
  7547. */
  7548. static loggingLevel: number;
  7549. /**
  7550. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7551. */
  7552. static CleanBoneMatrixWeights: boolean;
  7553. }
  7554. }
  7555. declare module "babylonjs/Meshes/transformNode" {
  7556. import { DeepImmutable } from "babylonjs/types";
  7557. import { Observable } from "babylonjs/Misc/observable";
  7558. import { Nullable } from "babylonjs/types";
  7559. import { Camera } from "babylonjs/Cameras/camera";
  7560. import { Scene } from "babylonjs/scene";
  7561. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7562. import { Node } from "babylonjs/node";
  7563. import { Bone } from "babylonjs/Bones/bone";
  7564. /**
  7565. * 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.
  7566. * @see https://doc.babylonjs.com/how_to/transformnode
  7567. */
  7568. export class TransformNode extends Node {
  7569. /**
  7570. * Object will not rotate to face the camera
  7571. */
  7572. static BILLBOARDMODE_NONE: number;
  7573. /**
  7574. * Object will rotate to face the camera but only on the x axis
  7575. */
  7576. static BILLBOARDMODE_X: number;
  7577. /**
  7578. * Object will rotate to face the camera but only on the y axis
  7579. */
  7580. static BILLBOARDMODE_Y: number;
  7581. /**
  7582. * Object will rotate to face the camera but only on the z axis
  7583. */
  7584. static BILLBOARDMODE_Z: number;
  7585. /**
  7586. * Object will rotate to face the camera
  7587. */
  7588. static BILLBOARDMODE_ALL: number;
  7589. private _forward;
  7590. private _forwardInverted;
  7591. private _up;
  7592. private _right;
  7593. private _rightInverted;
  7594. private _position;
  7595. private _rotation;
  7596. private _rotationQuaternion;
  7597. protected _scaling: Vector3;
  7598. protected _isDirty: boolean;
  7599. private _transformToBoneReferal;
  7600. private _billboardMode;
  7601. /**
  7602. * Gets or sets the billboard mode. Default is 0.
  7603. *
  7604. * | Value | Type | Description |
  7605. * | --- | --- | --- |
  7606. * | 0 | BILLBOARDMODE_NONE | |
  7607. * | 1 | BILLBOARDMODE_X | |
  7608. * | 2 | BILLBOARDMODE_Y | |
  7609. * | 4 | BILLBOARDMODE_Z | |
  7610. * | 7 | BILLBOARDMODE_ALL | |
  7611. *
  7612. */
  7613. billboardMode: number;
  7614. private _preserveParentRotationForBillboard;
  7615. /**
  7616. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7617. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7618. */
  7619. preserveParentRotationForBillboard: boolean;
  7620. /**
  7621. * 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
  7622. */
  7623. scalingDeterminant: number;
  7624. private _infiniteDistance;
  7625. /**
  7626. * Gets or sets the distance of the object to max, often used by skybox
  7627. */
  7628. infiniteDistance: boolean;
  7629. /**
  7630. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7631. * By default the system will update normals to compensate
  7632. */
  7633. ignoreNonUniformScaling: boolean;
  7634. /**
  7635. * 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
  7636. */
  7637. reIntegrateRotationIntoRotationQuaternion: boolean;
  7638. /** @hidden */
  7639. _poseMatrix: Nullable<Matrix>;
  7640. /** @hidden */
  7641. _localMatrix: Matrix;
  7642. private _usePivotMatrix;
  7643. private _absolutePosition;
  7644. private _pivotMatrix;
  7645. private _pivotMatrixInverse;
  7646. protected _postMultiplyPivotMatrix: boolean;
  7647. protected _isWorldMatrixFrozen: boolean;
  7648. /** @hidden */
  7649. _indexInSceneTransformNodesArray: number;
  7650. /**
  7651. * An event triggered after the world matrix is updated
  7652. */
  7653. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7654. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7655. /**
  7656. * Gets a string identifying the name of the class
  7657. * @returns "TransformNode" string
  7658. */
  7659. getClassName(): string;
  7660. /**
  7661. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7662. */
  7663. position: Vector3;
  7664. /**
  7665. * 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)).
  7666. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7667. */
  7668. rotation: Vector3;
  7669. /**
  7670. * 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)).
  7671. */
  7672. scaling: Vector3;
  7673. /**
  7674. * 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).
  7675. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7676. */
  7677. rotationQuaternion: Nullable<Quaternion>;
  7678. /**
  7679. * The forward direction of that transform in world space.
  7680. */
  7681. readonly forward: Vector3;
  7682. /**
  7683. * The up direction of that transform in world space.
  7684. */
  7685. readonly up: Vector3;
  7686. /**
  7687. * The right direction of that transform in world space.
  7688. */
  7689. readonly right: Vector3;
  7690. /**
  7691. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7692. * @param matrix the matrix to copy the pose from
  7693. * @returns this TransformNode.
  7694. */
  7695. updatePoseMatrix(matrix: Matrix): TransformNode;
  7696. /**
  7697. * Returns the mesh Pose matrix.
  7698. * @returns the pose matrix
  7699. */
  7700. getPoseMatrix(): Matrix;
  7701. /** @hidden */
  7702. _isSynchronized(): boolean;
  7703. /** @hidden */
  7704. _initCache(): void;
  7705. /**
  7706. * Flag the transform node as dirty (Forcing it to update everything)
  7707. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7708. * @returns this transform node
  7709. */
  7710. markAsDirty(property: string): TransformNode;
  7711. /**
  7712. * Returns the current mesh absolute position.
  7713. * Returns a Vector3.
  7714. */
  7715. readonly absolutePosition: Vector3;
  7716. /**
  7717. * Sets a new matrix to apply before all other transformation
  7718. * @param matrix defines the transform matrix
  7719. * @returns the current TransformNode
  7720. */
  7721. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7722. /**
  7723. * Sets a new pivot matrix to the current node
  7724. * @param matrix defines the new pivot matrix to use
  7725. * @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
  7726. * @returns the current TransformNode
  7727. */
  7728. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7729. /**
  7730. * Returns the mesh pivot matrix.
  7731. * Default : Identity.
  7732. * @returns the matrix
  7733. */
  7734. getPivotMatrix(): Matrix;
  7735. /**
  7736. * Prevents the World matrix to be computed any longer.
  7737. * @returns the TransformNode.
  7738. */
  7739. freezeWorldMatrix(): TransformNode;
  7740. /**
  7741. * Allows back the World matrix computation.
  7742. * @returns the TransformNode.
  7743. */
  7744. unfreezeWorldMatrix(): this;
  7745. /**
  7746. * True if the World matrix has been frozen.
  7747. */
  7748. readonly isWorldMatrixFrozen: boolean;
  7749. /**
  7750. * Retuns the mesh absolute position in the World.
  7751. * @returns a Vector3.
  7752. */
  7753. getAbsolutePosition(): Vector3;
  7754. /**
  7755. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7756. * @param absolutePosition the absolute position to set
  7757. * @returns the TransformNode.
  7758. */
  7759. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7760. /**
  7761. * Sets the mesh position in its local space.
  7762. * @param vector3 the position to set in localspace
  7763. * @returns the TransformNode.
  7764. */
  7765. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7766. /**
  7767. * Returns the mesh position in the local space from the current World matrix values.
  7768. * @returns a new Vector3.
  7769. */
  7770. getPositionExpressedInLocalSpace(): Vector3;
  7771. /**
  7772. * Translates the mesh along the passed Vector3 in its local space.
  7773. * @param vector3 the distance to translate in localspace
  7774. * @returns the TransformNode.
  7775. */
  7776. locallyTranslate(vector3: Vector3): TransformNode;
  7777. private static _lookAtVectorCache;
  7778. /**
  7779. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7780. * @param targetPoint the position (must be in same space as current mesh) to look at
  7781. * @param yawCor optional yaw (y-axis) correction in radians
  7782. * @param pitchCor optional pitch (x-axis) correction in radians
  7783. * @param rollCor optional roll (z-axis) correction in radians
  7784. * @param space the choosen space of the target
  7785. * @returns the TransformNode.
  7786. */
  7787. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7788. /**
  7789. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7790. * This Vector3 is expressed in the World space.
  7791. * @param localAxis axis to rotate
  7792. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7793. */
  7794. getDirection(localAxis: Vector3): Vector3;
  7795. /**
  7796. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7797. * localAxis is expressed in the mesh local space.
  7798. * result is computed in the Wordl space from the mesh World matrix.
  7799. * @param localAxis axis to rotate
  7800. * @param result the resulting transformnode
  7801. * @returns this TransformNode.
  7802. */
  7803. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7804. /**
  7805. * Sets this transform node rotation to the given local axis.
  7806. * @param localAxis the axis in local space
  7807. * @param yawCor optional yaw (y-axis) correction in radians
  7808. * @param pitchCor optional pitch (x-axis) correction in radians
  7809. * @param rollCor optional roll (z-axis) correction in radians
  7810. * @returns this TransformNode
  7811. */
  7812. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7813. /**
  7814. * Sets a new pivot point to the current node
  7815. * @param point defines the new pivot point to use
  7816. * @param space defines if the point is in world or local space (local by default)
  7817. * @returns the current TransformNode
  7818. */
  7819. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7820. /**
  7821. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7822. * @returns the pivot point
  7823. */
  7824. getPivotPoint(): Vector3;
  7825. /**
  7826. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7827. * @param result the vector3 to store the result
  7828. * @returns this TransformNode.
  7829. */
  7830. getPivotPointToRef(result: Vector3): TransformNode;
  7831. /**
  7832. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7833. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7834. */
  7835. getAbsolutePivotPoint(): Vector3;
  7836. /**
  7837. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7838. * @param result vector3 to store the result
  7839. * @returns this TransformNode.
  7840. */
  7841. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7842. /**
  7843. * Defines the passed node as the parent of the current node.
  7844. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7845. * @see https://doc.babylonjs.com/how_to/parenting
  7846. * @param node the node ot set as the parent
  7847. * @returns this TransformNode.
  7848. */
  7849. setParent(node: Nullable<Node>): TransformNode;
  7850. private _nonUniformScaling;
  7851. /**
  7852. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7853. */
  7854. readonly nonUniformScaling: boolean;
  7855. /** @hidden */
  7856. _updateNonUniformScalingState(value: boolean): boolean;
  7857. /**
  7858. * Attach the current TransformNode to another TransformNode associated with a bone
  7859. * @param bone Bone affecting the TransformNode
  7860. * @param affectedTransformNode TransformNode associated with the bone
  7861. * @returns this object
  7862. */
  7863. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7864. /**
  7865. * Detach the transform node if its associated with a bone
  7866. * @returns this object
  7867. */
  7868. detachFromBone(): TransformNode;
  7869. private static _rotationAxisCache;
  7870. /**
  7871. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7872. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7873. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7874. * The passed axis is also normalized.
  7875. * @param axis the axis to rotate around
  7876. * @param amount the amount to rotate in radians
  7877. * @param space Space to rotate in (Default: local)
  7878. * @returns the TransformNode.
  7879. */
  7880. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7881. /**
  7882. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7883. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7884. * The passed axis is also normalized. .
  7885. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7886. * @param point the point to rotate around
  7887. * @param axis the axis to rotate around
  7888. * @param amount the amount to rotate in radians
  7889. * @returns the TransformNode
  7890. */
  7891. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7892. /**
  7893. * Translates the mesh along the axis vector for the passed distance in the given space.
  7894. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7895. * @param axis the axis to translate in
  7896. * @param distance the distance to translate
  7897. * @param space Space to rotate in (Default: local)
  7898. * @returns the TransformNode.
  7899. */
  7900. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7901. /**
  7902. * Adds a rotation step to the mesh current rotation.
  7903. * x, y, z are Euler angles expressed in radians.
  7904. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7905. * This means this rotation is made in the mesh local space only.
  7906. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7907. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7908. * ```javascript
  7909. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7910. * ```
  7911. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7912. * 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.
  7913. * @param x Rotation to add
  7914. * @param y Rotation to add
  7915. * @param z Rotation to add
  7916. * @returns the TransformNode.
  7917. */
  7918. addRotation(x: number, y: number, z: number): TransformNode;
  7919. /**
  7920. * @hidden
  7921. */
  7922. protected _getEffectiveParent(): Nullable<Node>;
  7923. /**
  7924. * Computes the world matrix of the node
  7925. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7926. * @returns the world matrix
  7927. */
  7928. computeWorldMatrix(force?: boolean): Matrix;
  7929. protected _afterComputeWorldMatrix(): void;
  7930. /**
  7931. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7932. * @param func callback function to add
  7933. *
  7934. * @returns the TransformNode.
  7935. */
  7936. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7937. /**
  7938. * Removes a registered callback function.
  7939. * @param func callback function to remove
  7940. * @returns the TransformNode.
  7941. */
  7942. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7943. /**
  7944. * Gets the position of the current mesh in camera space
  7945. * @param camera defines the camera to use
  7946. * @returns a position
  7947. */
  7948. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7949. /**
  7950. * Returns the distance from the mesh to the active camera
  7951. * @param camera defines the camera to use
  7952. * @returns the distance
  7953. */
  7954. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7955. /**
  7956. * Clone the current transform node
  7957. * @param name Name of the new clone
  7958. * @param newParent New parent for the clone
  7959. * @param doNotCloneChildren Do not clone children hierarchy
  7960. * @returns the new transform node
  7961. */
  7962. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7963. /**
  7964. * Serializes the objects information.
  7965. * @param currentSerializationObject defines the object to serialize in
  7966. * @returns the serialized object
  7967. */
  7968. serialize(currentSerializationObject?: any): any;
  7969. /**
  7970. * Returns a new TransformNode object parsed from the source provided.
  7971. * @param parsedTransformNode is the source.
  7972. * @param scene the scne the object belongs to
  7973. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7974. * @returns a new TransformNode object parsed from the source provided.
  7975. */
  7976. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7977. /**
  7978. * Get all child-transformNodes of this node
  7979. * @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
  7980. * @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
  7981. * @returns an array of TransformNode
  7982. */
  7983. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7984. /**
  7985. * Releases resources associated with this transform node.
  7986. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7987. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7988. */
  7989. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7990. }
  7991. }
  7992. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7993. /**
  7994. * Class used to override all child animations of a given target
  7995. */
  7996. export class AnimationPropertiesOverride {
  7997. /**
  7998. * Gets or sets a value indicating if animation blending must be used
  7999. */
  8000. enableBlending: boolean;
  8001. /**
  8002. * Gets or sets the blending speed to use when enableBlending is true
  8003. */
  8004. blendingSpeed: number;
  8005. /**
  8006. * Gets or sets the default loop mode to use
  8007. */
  8008. loopMode: number;
  8009. }
  8010. }
  8011. declare module "babylonjs/Bones/bone" {
  8012. import { Skeleton } from "babylonjs/Bones/skeleton";
  8013. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8014. import { Nullable } from "babylonjs/types";
  8015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8016. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8017. import { Node } from "babylonjs/node";
  8018. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8019. /**
  8020. * Class used to store bone information
  8021. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8022. */
  8023. export class Bone extends Node {
  8024. /**
  8025. * defines the bone name
  8026. */
  8027. name: string;
  8028. private static _tmpVecs;
  8029. private static _tmpQuat;
  8030. private static _tmpMats;
  8031. /**
  8032. * Gets the list of child bones
  8033. */
  8034. children: Bone[];
  8035. /** Gets the animations associated with this bone */
  8036. animations: import("babylonjs/Animations/animation").Animation[];
  8037. /**
  8038. * Gets or sets bone length
  8039. */
  8040. length: number;
  8041. /**
  8042. * @hidden Internal only
  8043. * Set this value to map this bone to a different index in the transform matrices
  8044. * Set this value to -1 to exclude the bone from the transform matrices
  8045. */
  8046. _index: Nullable<number>;
  8047. private _skeleton;
  8048. private _localMatrix;
  8049. private _restPose;
  8050. private _baseMatrix;
  8051. private _absoluteTransform;
  8052. private _invertedAbsoluteTransform;
  8053. private _parent;
  8054. private _scalingDeterminant;
  8055. private _worldTransform;
  8056. private _localScaling;
  8057. private _localRotation;
  8058. private _localPosition;
  8059. private _needToDecompose;
  8060. private _needToCompose;
  8061. /** @hidden */
  8062. _linkedTransformNode: Nullable<TransformNode>;
  8063. /** @hidden */
  8064. /** @hidden */
  8065. _matrix: Matrix;
  8066. /**
  8067. * Create a new bone
  8068. * @param name defines the bone name
  8069. * @param skeleton defines the parent skeleton
  8070. * @param parentBone defines the parent (can be null if the bone is the root)
  8071. * @param localMatrix defines the local matrix
  8072. * @param restPose defines the rest pose matrix
  8073. * @param baseMatrix defines the base matrix
  8074. * @param index defines index of the bone in the hiearchy
  8075. */
  8076. constructor(
  8077. /**
  8078. * defines the bone name
  8079. */
  8080. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8081. /**
  8082. * Gets the current object class name.
  8083. * @return the class name
  8084. */
  8085. getClassName(): string;
  8086. /**
  8087. * Gets the parent skeleton
  8088. * @returns a skeleton
  8089. */
  8090. getSkeleton(): Skeleton;
  8091. /**
  8092. * Gets parent bone
  8093. * @returns a bone or null if the bone is the root of the bone hierarchy
  8094. */
  8095. getParent(): Nullable<Bone>;
  8096. /**
  8097. * Returns an array containing the root bones
  8098. * @returns an array containing the root bones
  8099. */
  8100. getChildren(): Array<Bone>;
  8101. /**
  8102. * Sets the parent bone
  8103. * @param parent defines the parent (can be null if the bone is the root)
  8104. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8105. */
  8106. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8107. /**
  8108. * Gets the local matrix
  8109. * @returns a matrix
  8110. */
  8111. getLocalMatrix(): Matrix;
  8112. /**
  8113. * Gets the base matrix (initial matrix which remains unchanged)
  8114. * @returns a matrix
  8115. */
  8116. getBaseMatrix(): Matrix;
  8117. /**
  8118. * Gets the rest pose matrix
  8119. * @returns a matrix
  8120. */
  8121. getRestPose(): Matrix;
  8122. /**
  8123. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8124. */
  8125. getWorldMatrix(): Matrix;
  8126. /**
  8127. * Sets the local matrix to rest pose matrix
  8128. */
  8129. returnToRest(): void;
  8130. /**
  8131. * Gets the inverse of the absolute transform matrix.
  8132. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8133. * @returns a matrix
  8134. */
  8135. getInvertedAbsoluteTransform(): Matrix;
  8136. /**
  8137. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8138. * @returns a matrix
  8139. */
  8140. getAbsoluteTransform(): Matrix;
  8141. /**
  8142. * Links with the given transform node.
  8143. * The local matrix of this bone is copied from the transform node every frame.
  8144. * @param transformNode defines the transform node to link to
  8145. */
  8146. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8147. /** Gets or sets current position (in local space) */
  8148. position: Vector3;
  8149. /** Gets or sets current rotation (in local space) */
  8150. rotation: Vector3;
  8151. /** Gets or sets current rotation quaternion (in local space) */
  8152. rotationQuaternion: Quaternion;
  8153. /** Gets or sets current scaling (in local space) */
  8154. scaling: Vector3;
  8155. /**
  8156. * Gets the animation properties override
  8157. */
  8158. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8159. private _decompose;
  8160. private _compose;
  8161. /**
  8162. * Update the base and local matrices
  8163. * @param matrix defines the new base or local matrix
  8164. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8165. * @param updateLocalMatrix defines if the local matrix should be updated
  8166. */
  8167. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8168. /** @hidden */
  8169. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8170. /**
  8171. * Flag the bone as dirty (Forcing it to update everything)
  8172. */
  8173. markAsDirty(): void;
  8174. private _markAsDirtyAndCompose;
  8175. private _markAsDirtyAndDecompose;
  8176. /**
  8177. * Translate the bone in local or world space
  8178. * @param vec The amount to translate the bone
  8179. * @param space The space that the translation is in
  8180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8181. */
  8182. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8183. /**
  8184. * Set the postion of the bone in local or world space
  8185. * @param position The position to set the bone
  8186. * @param space The space that the position is in
  8187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8188. */
  8189. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8190. /**
  8191. * Set the absolute position of the bone (world space)
  8192. * @param position The position to set the bone
  8193. * @param mesh The mesh that this bone is attached to
  8194. */
  8195. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8196. /**
  8197. * Scale the bone on the x, y and z axes (in local space)
  8198. * @param x The amount to scale the bone on the x axis
  8199. * @param y The amount to scale the bone on the y axis
  8200. * @param z The amount to scale the bone on the z axis
  8201. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8202. */
  8203. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8204. /**
  8205. * Set the bone scaling in local space
  8206. * @param scale defines the scaling vector
  8207. */
  8208. setScale(scale: Vector3): void;
  8209. /**
  8210. * Gets the current scaling in local space
  8211. * @returns the current scaling vector
  8212. */
  8213. getScale(): Vector3;
  8214. /**
  8215. * Gets the current scaling in local space and stores it in a target vector
  8216. * @param result defines the target vector
  8217. */
  8218. getScaleToRef(result: Vector3): void;
  8219. /**
  8220. * Set the yaw, pitch, and roll of the bone in local or world space
  8221. * @param yaw The rotation of the bone on the y axis
  8222. * @param pitch The rotation of the bone on the x axis
  8223. * @param roll The rotation of the bone on the z axis
  8224. * @param space The space that the axes of rotation are in
  8225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8226. */
  8227. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8228. /**
  8229. * Add a rotation to the bone on an axis in local or world space
  8230. * @param axis The axis to rotate the bone on
  8231. * @param amount The amount to rotate the bone
  8232. * @param space The space that the axis is in
  8233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8234. */
  8235. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8236. /**
  8237. * Set the rotation of the bone to a particular axis angle in local or world space
  8238. * @param axis The axis to rotate the bone on
  8239. * @param angle The angle that the bone should be rotated to
  8240. * @param space The space that the axis is in
  8241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8242. */
  8243. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8244. /**
  8245. * Set the euler rotation of the bone in local of world space
  8246. * @param rotation The euler rotation that the bone should be set to
  8247. * @param space The space that the rotation is in
  8248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8249. */
  8250. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8251. /**
  8252. * Set the quaternion rotation of the bone in local of world space
  8253. * @param quat The quaternion rotation that the bone should be set to
  8254. * @param space The space that the rotation is in
  8255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8256. */
  8257. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8258. /**
  8259. * Set the rotation matrix of the bone in local of world space
  8260. * @param rotMat The rotation matrix that the bone should be set to
  8261. * @param space The space that the rotation is in
  8262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8263. */
  8264. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8265. private _rotateWithMatrix;
  8266. private _getNegativeRotationToRef;
  8267. /**
  8268. * Get the position of the bone in local or world space
  8269. * @param space The space that the returned position is in
  8270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8271. * @returns The position of the bone
  8272. */
  8273. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8274. /**
  8275. * Copy the position of the bone to a vector3 in local or world space
  8276. * @param space The space that the returned position is in
  8277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8278. * @param result The vector3 to copy the position to
  8279. */
  8280. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8281. /**
  8282. * Get the absolute position of the bone (world space)
  8283. * @param mesh The mesh that this bone is attached to
  8284. * @returns The absolute position of the bone
  8285. */
  8286. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8287. /**
  8288. * Copy the absolute position of the bone (world space) to the result param
  8289. * @param mesh The mesh that this bone is attached to
  8290. * @param result The vector3 to copy the absolute position to
  8291. */
  8292. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8293. /**
  8294. * Compute the absolute transforms of this bone and its children
  8295. */
  8296. computeAbsoluteTransforms(): void;
  8297. /**
  8298. * Get the world direction from an axis that is in the local space of the bone
  8299. * @param localAxis The local direction that is used to compute the world direction
  8300. * @param mesh The mesh that this bone is attached to
  8301. * @returns The world direction
  8302. */
  8303. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8304. /**
  8305. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8306. * @param localAxis The local direction that is used to compute the world direction
  8307. * @param mesh The mesh that this bone is attached to
  8308. * @param result The vector3 that the world direction will be copied to
  8309. */
  8310. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8311. /**
  8312. * Get the euler rotation of the bone in local or world space
  8313. * @param space The space that the rotation should be in
  8314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8315. * @returns The euler rotation
  8316. */
  8317. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8318. /**
  8319. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8320. * @param space The space that the rotation should be in
  8321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8322. * @param result The vector3 that the rotation should be copied to
  8323. */
  8324. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8325. /**
  8326. * Get the quaternion rotation of the bone in either local or world space
  8327. * @param space The space that the rotation should be in
  8328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8329. * @returns The quaternion rotation
  8330. */
  8331. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8332. /**
  8333. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8334. * @param space The space that the rotation should be in
  8335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8336. * @param result The quaternion that the rotation should be copied to
  8337. */
  8338. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8339. /**
  8340. * Get the rotation matrix of the bone in local or world space
  8341. * @param space The space that the rotation should be in
  8342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8343. * @returns The rotation matrix
  8344. */
  8345. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8346. /**
  8347. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8348. * @param space The space that the rotation should be in
  8349. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8350. * @param result The quaternion that the rotation should be copied to
  8351. */
  8352. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8353. /**
  8354. * Get the world position of a point that is in the local space of the bone
  8355. * @param position The local position
  8356. * @param mesh The mesh that this bone is attached to
  8357. * @returns The world position
  8358. */
  8359. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8360. /**
  8361. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8362. * @param position The local position
  8363. * @param mesh The mesh that this bone is attached to
  8364. * @param result The vector3 that the world position should be copied to
  8365. */
  8366. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8367. /**
  8368. * Get the local position of a point that is in world space
  8369. * @param position The world position
  8370. * @param mesh The mesh that this bone is attached to
  8371. * @returns The local position
  8372. */
  8373. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8374. /**
  8375. * Get the local position of a point that is in world space and copy it to the result param
  8376. * @param position The world position
  8377. * @param mesh The mesh that this bone is attached to
  8378. * @param result The vector3 that the local position should be copied to
  8379. */
  8380. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8381. }
  8382. }
  8383. declare module "babylonjs/Misc/iInspectable" {
  8384. /**
  8385. * Enum that determines the text-wrapping mode to use.
  8386. */
  8387. export enum InspectableType {
  8388. /**
  8389. * Checkbox for booleans
  8390. */
  8391. Checkbox = 0,
  8392. /**
  8393. * Sliders for numbers
  8394. */
  8395. Slider = 1,
  8396. /**
  8397. * Vector3
  8398. */
  8399. Vector3 = 2,
  8400. /**
  8401. * Quaternions
  8402. */
  8403. Quaternion = 3,
  8404. /**
  8405. * Color3
  8406. */
  8407. Color3 = 4
  8408. }
  8409. /**
  8410. * Interface used to define custom inspectable properties.
  8411. * This interface is used by the inspector to display custom property grids
  8412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8413. */
  8414. export interface IInspectable {
  8415. /**
  8416. * Gets the label to display
  8417. */
  8418. label: string;
  8419. /**
  8420. * Gets the name of the property to edit
  8421. */
  8422. propertyName: string;
  8423. /**
  8424. * Gets the type of the editor to use
  8425. */
  8426. type: InspectableType;
  8427. /**
  8428. * Gets the minimum value of the property when using in "slider" mode
  8429. */
  8430. min?: number;
  8431. /**
  8432. * Gets the maximum value of the property when using in "slider" mode
  8433. */
  8434. max?: number;
  8435. /**
  8436. * Gets the setp to use when using in "slider" mode
  8437. */
  8438. step?: number;
  8439. }
  8440. }
  8441. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8442. import { Nullable } from "babylonjs/types";
  8443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8444. /**
  8445. * This represents the required contract to create a new type of texture loader.
  8446. */
  8447. export interface IInternalTextureLoader {
  8448. /**
  8449. * Defines wether the loader supports cascade loading the different faces.
  8450. */
  8451. supportCascades: boolean;
  8452. /**
  8453. * This returns if the loader support the current file information.
  8454. * @param extension defines the file extension of the file being loaded
  8455. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8456. * @param fallback defines the fallback internal texture if any
  8457. * @param isBase64 defines whether the texture is encoded as a base64
  8458. * @param isBuffer defines whether the texture data are stored as a buffer
  8459. * @returns true if the loader can load the specified file
  8460. */
  8461. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8462. /**
  8463. * Transform the url before loading if required.
  8464. * @param rootUrl the url of the texture
  8465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8466. * @returns the transformed texture
  8467. */
  8468. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8469. /**
  8470. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8471. * @param rootUrl the url of the texture
  8472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8473. * @returns the fallback texture
  8474. */
  8475. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8476. /**
  8477. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8478. * @param data contains the texture data
  8479. * @param texture defines the BabylonJS internal texture
  8480. * @param createPolynomials will be true if polynomials have been requested
  8481. * @param onLoad defines the callback to trigger once the texture is ready
  8482. * @param onError defines the callback to trigger in case of error
  8483. */
  8484. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8485. /**
  8486. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8487. * @param data contains the texture data
  8488. * @param texture defines the BabylonJS internal texture
  8489. * @param callback defines the method to call once ready to upload
  8490. */
  8491. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8492. }
  8493. }
  8494. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8495. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8496. import { Nullable } from "babylonjs/types";
  8497. import { Scene } from "babylonjs/scene";
  8498. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8499. module "babylonjs/Engines/engine" {
  8500. interface Engine {
  8501. /**
  8502. * Creates a depth stencil cube texture.
  8503. * This is only available in WebGL 2.
  8504. * @param size The size of face edge in the cube texture.
  8505. * @param options The options defining the cube texture.
  8506. * @returns The cube texture
  8507. */
  8508. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8509. /**
  8510. * Creates a cube texture
  8511. * @param rootUrl defines the url where the files to load is located
  8512. * @param scene defines the current scene
  8513. * @param files defines the list of files to load (1 per face)
  8514. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8515. * @param onLoad defines an optional callback raised when the texture is loaded
  8516. * @param onError defines an optional callback raised if there is an issue to load the texture
  8517. * @param format defines the format of the data
  8518. * @param forcedExtension defines the extension to use to pick the right loader
  8519. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8520. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8521. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8522. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8523. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8524. * @returns the cube texture as an InternalTexture
  8525. */
  8526. 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;
  8527. /**
  8528. * Creates a cube texture
  8529. * @param rootUrl defines the url where the files to load is located
  8530. * @param scene defines the current scene
  8531. * @param files defines the list of files to load (1 per face)
  8532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8533. * @param onLoad defines an optional callback raised when the texture is loaded
  8534. * @param onError defines an optional callback raised if there is an issue to load the texture
  8535. * @param format defines the format of the data
  8536. * @param forcedExtension defines the extension to use to pick the right loader
  8537. * @returns the cube texture as an InternalTexture
  8538. */
  8539. 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;
  8540. /**
  8541. * Creates a cube texture
  8542. * @param rootUrl defines the url where the files to load is located
  8543. * @param scene defines the current scene
  8544. * @param files defines the list of files to load (1 per face)
  8545. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8546. * @param onLoad defines an optional callback raised when the texture is loaded
  8547. * @param onError defines an optional callback raised if there is an issue to load the texture
  8548. * @param format defines the format of the data
  8549. * @param forcedExtension defines the extension to use to pick the right loader
  8550. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8551. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8552. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8553. * @returns the cube texture as an InternalTexture
  8554. */
  8555. 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;
  8556. /** @hidden */
  8557. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8558. /** @hidden */
  8559. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8560. /** @hidden */
  8561. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8562. /** @hidden */
  8563. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8564. }
  8565. }
  8566. }
  8567. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8568. import { Nullable } from "babylonjs/types";
  8569. import { Scene } from "babylonjs/scene";
  8570. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8572. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8573. /**
  8574. * Class for creating a cube texture
  8575. */
  8576. export class CubeTexture extends BaseTexture {
  8577. private _delayedOnLoad;
  8578. /**
  8579. * The url of the texture
  8580. */
  8581. url: string;
  8582. /**
  8583. * Gets or sets the center of the bounding box associated with the cube texture.
  8584. * It must define where the camera used to render the texture was set
  8585. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8586. */
  8587. boundingBoxPosition: Vector3;
  8588. private _boundingBoxSize;
  8589. /**
  8590. * Gets or sets the size of the bounding box associated with the cube texture
  8591. * When defined, the cubemap will switch to local mode
  8592. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8593. * @example https://www.babylonjs-playground.com/#RNASML
  8594. */
  8595. /**
  8596. * Returns the bounding box size
  8597. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8598. */
  8599. boundingBoxSize: Vector3;
  8600. protected _rotationY: number;
  8601. /**
  8602. * Sets texture matrix rotation angle around Y axis in radians.
  8603. */
  8604. /**
  8605. * Gets texture matrix rotation angle around Y axis radians.
  8606. */
  8607. rotationY: number;
  8608. /**
  8609. * Are mip maps generated for this texture or not.
  8610. */
  8611. readonly noMipmap: boolean;
  8612. private _noMipmap;
  8613. private _files;
  8614. private _extensions;
  8615. private _textureMatrix;
  8616. private _format;
  8617. private _createPolynomials;
  8618. /** @hidden */
  8619. _prefiltered: boolean;
  8620. /**
  8621. * Creates a cube texture from an array of image urls
  8622. * @param files defines an array of image urls
  8623. * @param scene defines the hosting scene
  8624. * @param noMipmap specifies if mip maps are not used
  8625. * @returns a cube texture
  8626. */
  8627. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8628. /**
  8629. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8630. * @param url defines the url of the prefiltered texture
  8631. * @param scene defines the scene the texture is attached to
  8632. * @param forcedExtension defines the extension of the file if different from the url
  8633. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8634. * @return the prefiltered texture
  8635. */
  8636. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8637. /**
  8638. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8639. * as prefiltered data.
  8640. * @param rootUrl defines the url of the texture or the root name of the six images
  8641. * @param scene defines the scene the texture is attached to
  8642. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8643. * @param noMipmap defines if mipmaps should be created or not
  8644. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8645. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8646. * @param onError defines a callback triggered in case of error during load
  8647. * @param format defines the internal format to use for the texture once loaded
  8648. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8649. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8650. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8651. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8652. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8653. * @return the cube texture
  8654. */
  8655. 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);
  8656. /**
  8657. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8658. */
  8659. readonly isPrefiltered: boolean;
  8660. /**
  8661. * Get the current class name of the texture useful for serialization or dynamic coding.
  8662. * @returns "CubeTexture"
  8663. */
  8664. getClassName(): string;
  8665. /**
  8666. * Update the url (and optional buffer) of this texture if url was null during construction.
  8667. * @param url the url of the texture
  8668. * @param forcedExtension defines the extension to use
  8669. * @param onLoad callback called when the texture is loaded (defaults to null)
  8670. */
  8671. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8672. /**
  8673. * Delays loading of the cube texture
  8674. * @param forcedExtension defines the extension to use
  8675. */
  8676. delayLoad(forcedExtension?: string): void;
  8677. /**
  8678. * Returns the reflection texture matrix
  8679. * @returns the reflection texture matrix
  8680. */
  8681. getReflectionTextureMatrix(): Matrix;
  8682. /**
  8683. * Sets the reflection texture matrix
  8684. * @param value Reflection texture matrix
  8685. */
  8686. setReflectionTextureMatrix(value: Matrix): void;
  8687. /**
  8688. * Parses text to create a cube texture
  8689. * @param parsedTexture define the serialized text to read from
  8690. * @param scene defines the hosting scene
  8691. * @param rootUrl defines the root url of the cube texture
  8692. * @returns a cube texture
  8693. */
  8694. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8695. /**
  8696. * Makes a clone, or deep copy, of the cube texture
  8697. * @returns a new cube texture
  8698. */
  8699. clone(): CubeTexture;
  8700. }
  8701. }
  8702. declare module "babylonjs/Shaders/postprocess.vertex" {
  8703. /** @hidden */
  8704. export var postprocessVertexShader: {
  8705. name: string;
  8706. shader: string;
  8707. };
  8708. }
  8709. declare module "babylonjs/Cameras/targetCamera" {
  8710. import { Nullable } from "babylonjs/types";
  8711. import { Camera } from "babylonjs/Cameras/camera";
  8712. import { Scene } from "babylonjs/scene";
  8713. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8714. /**
  8715. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8716. * This is the base of the follow, arc rotate cameras and Free camera
  8717. * @see http://doc.babylonjs.com/features/cameras
  8718. */
  8719. export class TargetCamera extends Camera {
  8720. private static _RigCamTransformMatrix;
  8721. private static _TargetTransformMatrix;
  8722. private static _TargetFocalPoint;
  8723. /**
  8724. * Define the current direction the camera is moving to
  8725. */
  8726. cameraDirection: Vector3;
  8727. /**
  8728. * Define the current rotation the camera is rotating to
  8729. */
  8730. cameraRotation: Vector2;
  8731. /**
  8732. * When set, the up vector of the camera will be updated by the rotation of the camera
  8733. */
  8734. updateUpVectorFromRotation: boolean;
  8735. private _tmpQuaternion;
  8736. /**
  8737. * Define the current rotation of the camera
  8738. */
  8739. rotation: Vector3;
  8740. /**
  8741. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8742. */
  8743. rotationQuaternion: Quaternion;
  8744. /**
  8745. * Define the current speed of the camera
  8746. */
  8747. speed: number;
  8748. /**
  8749. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8750. * around all axis.
  8751. */
  8752. noRotationConstraint: boolean;
  8753. /**
  8754. * Define the current target of the camera as an object or a position.
  8755. */
  8756. lockedTarget: any;
  8757. /** @hidden */
  8758. _currentTarget: Vector3;
  8759. /** @hidden */
  8760. _initialFocalDistance: number;
  8761. /** @hidden */
  8762. _viewMatrix: Matrix;
  8763. /** @hidden */
  8764. _camMatrix: Matrix;
  8765. /** @hidden */
  8766. _cameraTransformMatrix: Matrix;
  8767. /** @hidden */
  8768. _cameraRotationMatrix: Matrix;
  8769. /** @hidden */
  8770. _referencePoint: Vector3;
  8771. /** @hidden */
  8772. _transformedReferencePoint: Vector3;
  8773. protected _globalCurrentTarget: Vector3;
  8774. protected _globalCurrentUpVector: Vector3;
  8775. /** @hidden */
  8776. _reset: () => void;
  8777. private _defaultUp;
  8778. /**
  8779. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8780. * This is the base of the follow, arc rotate cameras and Free camera
  8781. * @see http://doc.babylonjs.com/features/cameras
  8782. * @param name Defines the name of the camera in the scene
  8783. * @param position Defines the start position of the camera in the scene
  8784. * @param scene Defines the scene the camera belongs to
  8785. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8786. */
  8787. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8788. /**
  8789. * Gets the position in front of the camera at a given distance.
  8790. * @param distance The distance from the camera we want the position to be
  8791. * @returns the position
  8792. */
  8793. getFrontPosition(distance: number): Vector3;
  8794. /** @hidden */
  8795. _getLockedTargetPosition(): Nullable<Vector3>;
  8796. private _storedPosition;
  8797. private _storedRotation;
  8798. private _storedRotationQuaternion;
  8799. /**
  8800. * Store current camera state of the camera (fov, position, rotation, etc..)
  8801. * @returns the camera
  8802. */
  8803. storeState(): Camera;
  8804. /**
  8805. * Restored camera state. You must call storeState() first
  8806. * @returns whether it was successful or not
  8807. * @hidden
  8808. */
  8809. _restoreStateValues(): boolean;
  8810. /** @hidden */
  8811. _initCache(): void;
  8812. /** @hidden */
  8813. _updateCache(ignoreParentClass?: boolean): void;
  8814. /** @hidden */
  8815. _isSynchronizedViewMatrix(): boolean;
  8816. /** @hidden */
  8817. _computeLocalCameraSpeed(): number;
  8818. /**
  8819. * Defines the target the camera should look at.
  8820. * This will automatically adapt alpha beta and radius to fit within the new target.
  8821. * @param target Defines the new target as a Vector or a mesh
  8822. */
  8823. setTarget(target: Vector3): void;
  8824. /**
  8825. * Return the current target position of the camera. This value is expressed in local space.
  8826. * @returns the target position
  8827. */
  8828. getTarget(): Vector3;
  8829. /** @hidden */
  8830. _decideIfNeedsToMove(): boolean;
  8831. /** @hidden */
  8832. _updatePosition(): void;
  8833. /** @hidden */
  8834. _checkInputs(): void;
  8835. protected _updateCameraRotationMatrix(): void;
  8836. /**
  8837. * 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)
  8838. * @returns the current camera
  8839. */
  8840. private _rotateUpVectorWithCameraRotationMatrix;
  8841. private _cachedRotationZ;
  8842. private _cachedQuaternionRotationZ;
  8843. /** @hidden */
  8844. _getViewMatrix(): Matrix;
  8845. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8846. /**
  8847. * @hidden
  8848. */
  8849. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8850. /**
  8851. * @hidden
  8852. */
  8853. _updateRigCameras(): void;
  8854. private _getRigCamPositionAndTarget;
  8855. /**
  8856. * Gets the current object class name.
  8857. * @return the class name
  8858. */
  8859. getClassName(): string;
  8860. }
  8861. }
  8862. declare module "babylonjs/Cameras/cameraInputsManager" {
  8863. import { Nullable } from "babylonjs/types";
  8864. import { Camera } from "babylonjs/Cameras/camera";
  8865. /**
  8866. * @ignore
  8867. * This is a list of all the different input types that are available in the application.
  8868. * Fo instance: ArcRotateCameraGamepadInput...
  8869. */
  8870. export var CameraInputTypes: {};
  8871. /**
  8872. * This is the contract to implement in order to create a new input class.
  8873. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8874. */
  8875. export interface ICameraInput<TCamera extends Camera> {
  8876. /**
  8877. * Defines the camera the input is attached to.
  8878. */
  8879. camera: Nullable<TCamera>;
  8880. /**
  8881. * Gets the class name of the current intput.
  8882. * @returns the class name
  8883. */
  8884. getClassName(): string;
  8885. /**
  8886. * Get the friendly name associated with the input class.
  8887. * @returns the input friendly name
  8888. */
  8889. getSimpleName(): string;
  8890. /**
  8891. * Attach the input controls to a specific dom element to get the input from.
  8892. * @param element Defines the element the controls should be listened from
  8893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8894. */
  8895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8896. /**
  8897. * Detach the current controls from the specified dom element.
  8898. * @param element Defines the element to stop listening the inputs from
  8899. */
  8900. detachControl(element: Nullable<HTMLElement>): void;
  8901. /**
  8902. * Update the current camera state depending on the inputs that have been used this frame.
  8903. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8904. */
  8905. checkInputs?: () => void;
  8906. }
  8907. /**
  8908. * Represents a map of input types to input instance or input index to input instance.
  8909. */
  8910. export interface CameraInputsMap<TCamera extends Camera> {
  8911. /**
  8912. * Accessor to the input by input type.
  8913. */
  8914. [name: string]: ICameraInput<TCamera>;
  8915. /**
  8916. * Accessor to the input by input index.
  8917. */
  8918. [idx: number]: ICameraInput<TCamera>;
  8919. }
  8920. /**
  8921. * This represents the input manager used within a camera.
  8922. * It helps dealing with all the different kind of input attached to a camera.
  8923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8924. */
  8925. export class CameraInputsManager<TCamera extends Camera> {
  8926. /**
  8927. * Defines the list of inputs attahed to the camera.
  8928. */
  8929. attached: CameraInputsMap<TCamera>;
  8930. /**
  8931. * Defines the dom element the camera is collecting inputs from.
  8932. * This is null if the controls have not been attached.
  8933. */
  8934. attachedElement: Nullable<HTMLElement>;
  8935. /**
  8936. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8937. */
  8938. noPreventDefault: boolean;
  8939. /**
  8940. * Defined the camera the input manager belongs to.
  8941. */
  8942. camera: TCamera;
  8943. /**
  8944. * Update the current camera state depending on the inputs that have been used this frame.
  8945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8946. */
  8947. checkInputs: () => void;
  8948. /**
  8949. * Instantiate a new Camera Input Manager.
  8950. * @param camera Defines the camera the input manager blongs to
  8951. */
  8952. constructor(camera: TCamera);
  8953. /**
  8954. * Add an input method to a camera
  8955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8956. * @param input camera input method
  8957. */
  8958. add(input: ICameraInput<TCamera>): void;
  8959. /**
  8960. * Remove a specific input method from a camera
  8961. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8962. * @param inputToRemove camera input method
  8963. */
  8964. remove(inputToRemove: ICameraInput<TCamera>): void;
  8965. /**
  8966. * Remove a specific input type from a camera
  8967. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8968. * @param inputType the type of the input to remove
  8969. */
  8970. removeByType(inputType: string): void;
  8971. private _addCheckInputs;
  8972. /**
  8973. * Attach the input controls to the currently attached dom element to listen the events from.
  8974. * @param input Defines the input to attach
  8975. */
  8976. attachInput(input: ICameraInput<TCamera>): void;
  8977. /**
  8978. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8979. * @param element Defines the dom element to collect the events from
  8980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8981. */
  8982. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8983. /**
  8984. * Detach the current manager inputs controls from a specific dom element.
  8985. * @param element Defines the dom element to collect the events from
  8986. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8987. */
  8988. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8989. /**
  8990. * Rebuild the dynamic inputCheck function from the current list of
  8991. * defined inputs in the manager.
  8992. */
  8993. rebuildInputCheck(): void;
  8994. /**
  8995. * Remove all attached input methods from a camera
  8996. */
  8997. clear(): void;
  8998. /**
  8999. * Serialize the current input manager attached to a camera.
  9000. * This ensures than once parsed,
  9001. * the input associated to the camera will be identical to the current ones
  9002. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9003. */
  9004. serialize(serializedCamera: any): void;
  9005. /**
  9006. * Parses an input manager serialized JSON to restore the previous list of inputs
  9007. * and states associated to a camera.
  9008. * @param parsedCamera Defines the JSON to parse
  9009. */
  9010. parse(parsedCamera: any): void;
  9011. }
  9012. }
  9013. declare module "babylonjs/Events/keyboardEvents" {
  9014. /**
  9015. * Gather the list of keyboard event types as constants.
  9016. */
  9017. export class KeyboardEventTypes {
  9018. /**
  9019. * The keydown event is fired when a key becomes active (pressed).
  9020. */
  9021. static readonly KEYDOWN: number;
  9022. /**
  9023. * The keyup event is fired when a key has been released.
  9024. */
  9025. static readonly KEYUP: number;
  9026. }
  9027. /**
  9028. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9029. */
  9030. export class KeyboardInfo {
  9031. /**
  9032. * Defines the type of event (KeyboardEventTypes)
  9033. */
  9034. type: number;
  9035. /**
  9036. * Defines the related dom event
  9037. */
  9038. event: KeyboardEvent;
  9039. /**
  9040. * Instantiates a new keyboard info.
  9041. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9042. * @param type Defines the type of event (KeyboardEventTypes)
  9043. * @param event Defines the related dom event
  9044. */
  9045. constructor(
  9046. /**
  9047. * Defines the type of event (KeyboardEventTypes)
  9048. */
  9049. type: number,
  9050. /**
  9051. * Defines the related dom event
  9052. */
  9053. event: KeyboardEvent);
  9054. }
  9055. /**
  9056. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9057. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9058. */
  9059. export class KeyboardInfoPre extends KeyboardInfo {
  9060. /**
  9061. * Defines the type of event (KeyboardEventTypes)
  9062. */
  9063. type: number;
  9064. /**
  9065. * Defines the related dom event
  9066. */
  9067. event: KeyboardEvent;
  9068. /**
  9069. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9070. */
  9071. skipOnPointerObservable: boolean;
  9072. /**
  9073. * Instantiates a new keyboard pre info.
  9074. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9075. * @param type Defines the type of event (KeyboardEventTypes)
  9076. * @param event Defines the related dom event
  9077. */
  9078. constructor(
  9079. /**
  9080. * Defines the type of event (KeyboardEventTypes)
  9081. */
  9082. type: number,
  9083. /**
  9084. * Defines the related dom event
  9085. */
  9086. event: KeyboardEvent);
  9087. }
  9088. }
  9089. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9090. import { Nullable } from "babylonjs/types";
  9091. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9092. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9093. /**
  9094. * Manage the keyboard inputs to control the movement of a free camera.
  9095. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9096. */
  9097. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9098. /**
  9099. * Defines the camera the input is attached to.
  9100. */
  9101. camera: FreeCamera;
  9102. /**
  9103. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9104. */
  9105. keysUp: number[];
  9106. /**
  9107. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9108. */
  9109. keysDown: number[];
  9110. /**
  9111. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9112. */
  9113. keysLeft: number[];
  9114. /**
  9115. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9116. */
  9117. keysRight: number[];
  9118. private _keys;
  9119. private _onCanvasBlurObserver;
  9120. private _onKeyboardObserver;
  9121. private _engine;
  9122. private _scene;
  9123. /**
  9124. * Attach the input controls to a specific dom element to get the input from.
  9125. * @param element Defines the element the controls should be listened from
  9126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9127. */
  9128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9129. /**
  9130. * Detach the current controls from the specified dom element.
  9131. * @param element Defines the element to stop listening the inputs from
  9132. */
  9133. detachControl(element: Nullable<HTMLElement>): void;
  9134. /**
  9135. * Update the current camera state depending on the inputs that have been used this frame.
  9136. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9137. */
  9138. checkInputs(): void;
  9139. /**
  9140. * Gets the class name of the current intput.
  9141. * @returns the class name
  9142. */
  9143. getClassName(): string;
  9144. /** @hidden */
  9145. _onLostFocus(): void;
  9146. /**
  9147. * Get the friendly name associated with the input class.
  9148. * @returns the input friendly name
  9149. */
  9150. getSimpleName(): string;
  9151. }
  9152. }
  9153. declare module "babylonjs/Lights/shadowLight" {
  9154. import { Camera } from "babylonjs/Cameras/camera";
  9155. import { Scene } from "babylonjs/scene";
  9156. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9158. import { Light } from "babylonjs/Lights/light";
  9159. /**
  9160. * Interface describing all the common properties and methods a shadow light needs to implement.
  9161. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9162. * as well as binding the different shadow properties to the effects.
  9163. */
  9164. export interface IShadowLight extends Light {
  9165. /**
  9166. * The light id in the scene (used in scene.findLighById for instance)
  9167. */
  9168. id: string;
  9169. /**
  9170. * The position the shdow will be casted from.
  9171. */
  9172. position: Vector3;
  9173. /**
  9174. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9175. */
  9176. direction: Vector3;
  9177. /**
  9178. * The transformed position. Position of the light in world space taking parenting in account.
  9179. */
  9180. transformedPosition: Vector3;
  9181. /**
  9182. * The transformed direction. Direction of the light in world space taking parenting in account.
  9183. */
  9184. transformedDirection: Vector3;
  9185. /**
  9186. * The friendly name of the light in the scene.
  9187. */
  9188. name: string;
  9189. /**
  9190. * Defines the shadow projection clipping minimum z value.
  9191. */
  9192. shadowMinZ: number;
  9193. /**
  9194. * Defines the shadow projection clipping maximum z value.
  9195. */
  9196. shadowMaxZ: number;
  9197. /**
  9198. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9199. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9200. */
  9201. computeTransformedInformation(): boolean;
  9202. /**
  9203. * Gets the scene the light belongs to.
  9204. * @returns The scene
  9205. */
  9206. getScene(): Scene;
  9207. /**
  9208. * Callback defining a custom Projection Matrix Builder.
  9209. * This can be used to override the default projection matrix computation.
  9210. */
  9211. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9212. /**
  9213. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9214. * @param matrix The materix to updated with the projection information
  9215. * @param viewMatrix The transform matrix of the light
  9216. * @param renderList The list of mesh to render in the map
  9217. * @returns The current light
  9218. */
  9219. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9220. /**
  9221. * Gets the current depth scale used in ESM.
  9222. * @returns The scale
  9223. */
  9224. getDepthScale(): number;
  9225. /**
  9226. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9227. * @returns true if a cube texture needs to be use
  9228. */
  9229. needCube(): boolean;
  9230. /**
  9231. * Detects if the projection matrix requires to be recomputed this frame.
  9232. * @returns true if it requires to be recomputed otherwise, false.
  9233. */
  9234. needProjectionMatrixCompute(): boolean;
  9235. /**
  9236. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9237. */
  9238. forceProjectionMatrixCompute(): void;
  9239. /**
  9240. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9241. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9242. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9243. */
  9244. getShadowDirection(faceIndex?: number): Vector3;
  9245. /**
  9246. * Gets the minZ used for shadow according to both the scene and the light.
  9247. * @param activeCamera The camera we are returning the min for
  9248. * @returns the depth min z
  9249. */
  9250. getDepthMinZ(activeCamera: Camera): number;
  9251. /**
  9252. * Gets the maxZ used for shadow according to both the scene and the light.
  9253. * @param activeCamera The camera we are returning the max for
  9254. * @returns the depth max z
  9255. */
  9256. getDepthMaxZ(activeCamera: Camera): number;
  9257. }
  9258. /**
  9259. * Base implementation IShadowLight
  9260. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9261. */
  9262. export abstract class ShadowLight extends Light implements IShadowLight {
  9263. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9264. protected _position: Vector3;
  9265. protected _setPosition(value: Vector3): void;
  9266. /**
  9267. * Sets the position the shadow will be casted from. Also use as the light position for both
  9268. * point and spot lights.
  9269. */
  9270. /**
  9271. * Sets the position the shadow will be casted from. Also use as the light position for both
  9272. * point and spot lights.
  9273. */
  9274. position: Vector3;
  9275. protected _direction: Vector3;
  9276. protected _setDirection(value: Vector3): void;
  9277. /**
  9278. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9279. * Also use as the light direction on spot and directional lights.
  9280. */
  9281. /**
  9282. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9283. * Also use as the light direction on spot and directional lights.
  9284. */
  9285. direction: Vector3;
  9286. private _shadowMinZ;
  9287. /**
  9288. * Gets the shadow projection clipping minimum z value.
  9289. */
  9290. /**
  9291. * Sets the shadow projection clipping minimum z value.
  9292. */
  9293. shadowMinZ: number;
  9294. private _shadowMaxZ;
  9295. /**
  9296. * Sets the shadow projection clipping maximum z value.
  9297. */
  9298. /**
  9299. * Gets the shadow projection clipping maximum z value.
  9300. */
  9301. shadowMaxZ: number;
  9302. /**
  9303. * Callback defining a custom Projection Matrix Builder.
  9304. * This can be used to override the default projection matrix computation.
  9305. */
  9306. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9307. /**
  9308. * The transformed position. Position of the light in world space taking parenting in account.
  9309. */
  9310. transformedPosition: Vector3;
  9311. /**
  9312. * The transformed direction. Direction of the light in world space taking parenting in account.
  9313. */
  9314. transformedDirection: Vector3;
  9315. private _needProjectionMatrixCompute;
  9316. /**
  9317. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9318. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9319. */
  9320. computeTransformedInformation(): boolean;
  9321. /**
  9322. * Return the depth scale used for the shadow map.
  9323. * @returns the depth scale.
  9324. */
  9325. getDepthScale(): number;
  9326. /**
  9327. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9328. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9329. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9330. */
  9331. getShadowDirection(faceIndex?: number): Vector3;
  9332. /**
  9333. * Returns the ShadowLight absolute position in the World.
  9334. * @returns the position vector in world space
  9335. */
  9336. getAbsolutePosition(): Vector3;
  9337. /**
  9338. * Sets the ShadowLight direction toward the passed target.
  9339. * @param target The point to target in local space
  9340. * @returns the updated ShadowLight direction
  9341. */
  9342. setDirectionToTarget(target: Vector3): Vector3;
  9343. /**
  9344. * Returns the light rotation in euler definition.
  9345. * @returns the x y z rotation in local space.
  9346. */
  9347. getRotation(): Vector3;
  9348. /**
  9349. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9350. * @returns true if a cube texture needs to be use
  9351. */
  9352. needCube(): boolean;
  9353. /**
  9354. * Detects if the projection matrix requires to be recomputed this frame.
  9355. * @returns true if it requires to be recomputed otherwise, false.
  9356. */
  9357. needProjectionMatrixCompute(): boolean;
  9358. /**
  9359. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9360. */
  9361. forceProjectionMatrixCompute(): void;
  9362. /** @hidden */
  9363. _initCache(): void;
  9364. /** @hidden */
  9365. _isSynchronized(): boolean;
  9366. /**
  9367. * Computes the world matrix of the node
  9368. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9369. * @returns the world matrix
  9370. */
  9371. computeWorldMatrix(force?: boolean): Matrix;
  9372. /**
  9373. * Gets the minZ used for shadow according to both the scene and the light.
  9374. * @param activeCamera The camera we are returning the min for
  9375. * @returns the depth min z
  9376. */
  9377. getDepthMinZ(activeCamera: Camera): number;
  9378. /**
  9379. * Gets the maxZ used for shadow according to both the scene and the light.
  9380. * @param activeCamera The camera we are returning the max for
  9381. * @returns the depth max z
  9382. */
  9383. getDepthMaxZ(activeCamera: Camera): number;
  9384. /**
  9385. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9386. * @param matrix The materix to updated with the projection information
  9387. * @param viewMatrix The transform matrix of the light
  9388. * @param renderList The list of mesh to render in the map
  9389. * @returns The current light
  9390. */
  9391. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9392. }
  9393. }
  9394. declare module "babylonjs/Materials/materialHelper" {
  9395. import { Nullable } from "babylonjs/types";
  9396. import { Scene } from "babylonjs/scene";
  9397. import { Engine } from "babylonjs/Engines/engine";
  9398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9399. import { Light } from "babylonjs/Lights/light";
  9400. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9401. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9403. /**
  9404. * "Static Class" containing the most commonly used helper while dealing with material for
  9405. * rendering purpose.
  9406. *
  9407. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9408. *
  9409. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9410. */
  9411. export class MaterialHelper {
  9412. /**
  9413. * Bind the current view position to an effect.
  9414. * @param effect The effect to be bound
  9415. * @param scene The scene the eyes position is used from
  9416. */
  9417. static BindEyePosition(effect: Effect, scene: Scene): void;
  9418. /**
  9419. * Helps preparing the defines values about the UVs in used in the effect.
  9420. * UVs are shared as much as we can accross channels in the shaders.
  9421. * @param texture The texture we are preparing the UVs for
  9422. * @param defines The defines to update
  9423. * @param key The channel key "diffuse", "specular"... used in the shader
  9424. */
  9425. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9426. /**
  9427. * Binds a texture matrix value to its corrsponding uniform
  9428. * @param texture The texture to bind the matrix for
  9429. * @param uniformBuffer The uniform buffer receivin the data
  9430. * @param key The channel key "diffuse", "specular"... used in the shader
  9431. */
  9432. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9433. /**
  9434. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9435. * @param mesh defines the current mesh
  9436. * @param scene defines the current scene
  9437. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9438. * @param pointsCloud defines if point cloud rendering has to be turned on
  9439. * @param fogEnabled defines if fog has to be turned on
  9440. * @param alphaTest defines if alpha testing has to be turned on
  9441. * @param defines defines the current list of defines
  9442. */
  9443. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9444. /**
  9445. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9446. * @param scene defines the current scene
  9447. * @param engine defines the current engine
  9448. * @param defines specifies the list of active defines
  9449. * @param useInstances defines if instances have to be turned on
  9450. * @param useClipPlane defines if clip plane have to be turned on
  9451. */
  9452. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9453. /**
  9454. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9455. * @param mesh The mesh containing the geometry data we will draw
  9456. * @param defines The defines to update
  9457. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9458. * @param useBones Precise whether bones should be used or not (override mesh info)
  9459. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9460. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9461. * @returns false if defines are considered not dirty and have not been checked
  9462. */
  9463. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9464. /**
  9465. * Prepares the defines related to multiview
  9466. * @param scene The scene we are intending to draw
  9467. * @param defines The defines to update
  9468. */
  9469. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9470. /**
  9471. * Prepares the defines related to the light information passed in parameter
  9472. * @param scene The scene we are intending to draw
  9473. * @param mesh The mesh the effect is compiling for
  9474. * @param defines The defines to update
  9475. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9476. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9477. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9478. * @returns true if normals will be required for the rest of the effect
  9479. */
  9480. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9481. /**
  9482. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9483. * that won t be acctive due to defines being turned off.
  9484. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9485. * @param samplersList The samplers list
  9486. * @param defines The defines helping in the list generation
  9487. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9488. */
  9489. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9490. /**
  9491. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9492. * @param defines The defines to update while falling back
  9493. * @param fallbacks The authorized effect fallbacks
  9494. * @param maxSimultaneousLights The maximum number of lights allowed
  9495. * @param rank the current rank of the Effect
  9496. * @returns The newly affected rank
  9497. */
  9498. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9499. /**
  9500. * Prepares the list of attributes required for morph targets according to the effect defines.
  9501. * @param attribs The current list of supported attribs
  9502. * @param mesh The mesh to prepare the morph targets attributes for
  9503. * @param defines The current Defines of the effect
  9504. */
  9505. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9506. /**
  9507. * Prepares the list of attributes required for bones according to the effect defines.
  9508. * @param attribs The current list of supported attribs
  9509. * @param mesh The mesh to prepare the bones attributes for
  9510. * @param defines The current Defines of the effect
  9511. * @param fallbacks The current efffect fallback strategy
  9512. */
  9513. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9514. /**
  9515. * Prepares the list of attributes required for instances according to the effect defines.
  9516. * @param attribs The current list of supported attribs
  9517. * @param defines The current Defines of the effect
  9518. */
  9519. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9520. /**
  9521. * Binds the light shadow information to the effect for the given mesh.
  9522. * @param light The light containing the generator
  9523. * @param scene The scene the lights belongs to
  9524. * @param mesh The mesh we are binding the information to render
  9525. * @param lightIndex The light index in the effect used to render the mesh
  9526. * @param effect The effect we are binding the data to
  9527. */
  9528. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9529. /**
  9530. * Binds the light information to the effect.
  9531. * @param light The light containing the generator
  9532. * @param effect The effect we are binding the data to
  9533. * @param lightIndex The light index in the effect used to render
  9534. */
  9535. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9536. /**
  9537. * Binds the lights information from the scene to the effect for the given mesh.
  9538. * @param scene The scene the lights belongs to
  9539. * @param mesh The mesh we are binding the information to render
  9540. * @param effect The effect we are binding the data to
  9541. * @param defines The generated defines for the effect
  9542. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9543. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9544. */
  9545. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9546. private static _tempFogColor;
  9547. /**
  9548. * Binds the fog information from the scene to the effect for the given mesh.
  9549. * @param scene The scene the lights belongs to
  9550. * @param mesh The mesh we are binding the information to render
  9551. * @param effect The effect we are binding the data to
  9552. * @param linearSpace Defines if the fog effect is applied in linear space
  9553. */
  9554. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9555. /**
  9556. * Binds the bones information from the mesh to the effect.
  9557. * @param mesh The mesh we are binding the information to render
  9558. * @param effect The effect we are binding the data to
  9559. */
  9560. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9561. /**
  9562. * Binds the morph targets information from the mesh to the effect.
  9563. * @param abstractMesh The mesh we are binding the information to render
  9564. * @param effect The effect we are binding the data to
  9565. */
  9566. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9567. /**
  9568. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9569. * @param defines The generated defines used in the effect
  9570. * @param effect The effect we are binding the data to
  9571. * @param scene The scene we are willing to render with logarithmic scale for
  9572. */
  9573. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9574. /**
  9575. * Binds the clip plane information from the scene to the effect.
  9576. * @param scene The scene the clip plane information are extracted from
  9577. * @param effect The effect we are binding the data to
  9578. */
  9579. static BindClipPlane(effect: Effect, scene: Scene): void;
  9580. }
  9581. }
  9582. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9583. /** @hidden */
  9584. export var kernelBlurVaryingDeclaration: {
  9585. name: string;
  9586. shader: string;
  9587. };
  9588. }
  9589. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9590. /** @hidden */
  9591. export var kernelBlurFragment: {
  9592. name: string;
  9593. shader: string;
  9594. };
  9595. }
  9596. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9597. /** @hidden */
  9598. export var kernelBlurFragment2: {
  9599. name: string;
  9600. shader: string;
  9601. };
  9602. }
  9603. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9604. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9605. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9606. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9607. /** @hidden */
  9608. export var kernelBlurPixelShader: {
  9609. name: string;
  9610. shader: string;
  9611. };
  9612. }
  9613. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9614. /** @hidden */
  9615. export var kernelBlurVertex: {
  9616. name: string;
  9617. shader: string;
  9618. };
  9619. }
  9620. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9621. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9622. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9623. /** @hidden */
  9624. export var kernelBlurVertexShader: {
  9625. name: string;
  9626. shader: string;
  9627. };
  9628. }
  9629. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9630. import { Vector2 } from "babylonjs/Maths/math";
  9631. import { Nullable } from "babylonjs/types";
  9632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9633. import { Camera } from "babylonjs/Cameras/camera";
  9634. import { Effect } from "babylonjs/Materials/effect";
  9635. import { Engine } from "babylonjs/Engines/engine";
  9636. import "babylonjs/Shaders/kernelBlur.fragment";
  9637. import "babylonjs/Shaders/kernelBlur.vertex";
  9638. /**
  9639. * The Blur Post Process which blurs an image based on a kernel and direction.
  9640. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9641. */
  9642. export class BlurPostProcess extends PostProcess {
  9643. /** The direction in which to blur the image. */
  9644. direction: Vector2;
  9645. private blockCompilation;
  9646. protected _kernel: number;
  9647. protected _idealKernel: number;
  9648. protected _packedFloat: boolean;
  9649. private _staticDefines;
  9650. /**
  9651. * Sets the length in pixels of the blur sample region
  9652. */
  9653. /**
  9654. * Gets the length in pixels of the blur sample region
  9655. */
  9656. kernel: number;
  9657. /**
  9658. * Sets wether or not the blur needs to unpack/repack floats
  9659. */
  9660. /**
  9661. * Gets wether or not the blur is unpacking/repacking floats
  9662. */
  9663. packedFloat: boolean;
  9664. /**
  9665. * Creates a new instance BlurPostProcess
  9666. * @param name The name of the effect.
  9667. * @param direction The direction in which to blur the image.
  9668. * @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.
  9669. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9670. * @param camera The camera to apply the render pass to.
  9671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9672. * @param engine The engine which the post process will be applied. (default: current engine)
  9673. * @param reusable If the post process can be reused on the same frame. (default: false)
  9674. * @param textureType Type of textures used when performing the post process. (default: 0)
  9675. * @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)
  9676. */
  9677. constructor(name: string,
  9678. /** The direction in which to blur the image. */
  9679. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9680. /**
  9681. * Updates the effect with the current post process compile time values and recompiles the shader.
  9682. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9683. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9684. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9685. * @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
  9686. * @param onCompiled Called when the shader has been compiled.
  9687. * @param onError Called if there is an error when compiling a shader.
  9688. */
  9689. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9690. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9691. /**
  9692. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9693. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9694. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9695. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9696. * The gaps between physical kernels are compensated for in the weighting of the samples
  9697. * @param idealKernel Ideal blur kernel.
  9698. * @return Nearest best kernel.
  9699. */
  9700. protected _nearestBestKernel(idealKernel: number): number;
  9701. /**
  9702. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9703. * @param x The point on the Gaussian distribution to sample.
  9704. * @return the value of the Gaussian function at x.
  9705. */
  9706. protected _gaussianWeight(x: number): number;
  9707. /**
  9708. * Generates a string that can be used as a floating point number in GLSL.
  9709. * @param x Value to print.
  9710. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9711. * @return GLSL float string.
  9712. */
  9713. protected _glslFloat(x: number, decimalFigures?: number): string;
  9714. }
  9715. }
  9716. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9717. /** @hidden */
  9718. export var shadowMapPixelShader: {
  9719. name: string;
  9720. shader: string;
  9721. };
  9722. }
  9723. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9724. /** @hidden */
  9725. export var bonesDeclaration: {
  9726. name: string;
  9727. shader: string;
  9728. };
  9729. }
  9730. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9731. /** @hidden */
  9732. export var morphTargetsVertexGlobalDeclaration: {
  9733. name: string;
  9734. shader: string;
  9735. };
  9736. }
  9737. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9738. /** @hidden */
  9739. export var morphTargetsVertexDeclaration: {
  9740. name: string;
  9741. shader: string;
  9742. };
  9743. }
  9744. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9745. /** @hidden */
  9746. export var instancesDeclaration: {
  9747. name: string;
  9748. shader: string;
  9749. };
  9750. }
  9751. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9752. /** @hidden */
  9753. export var helperFunctions: {
  9754. name: string;
  9755. shader: string;
  9756. };
  9757. }
  9758. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9759. /** @hidden */
  9760. export var morphTargetsVertex: {
  9761. name: string;
  9762. shader: string;
  9763. };
  9764. }
  9765. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9766. /** @hidden */
  9767. export var instancesVertex: {
  9768. name: string;
  9769. shader: string;
  9770. };
  9771. }
  9772. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9773. /** @hidden */
  9774. export var bonesVertex: {
  9775. name: string;
  9776. shader: string;
  9777. };
  9778. }
  9779. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9780. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9781. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9782. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9783. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9784. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9785. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9786. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9787. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9788. /** @hidden */
  9789. export var shadowMapVertexShader: {
  9790. name: string;
  9791. shader: string;
  9792. };
  9793. }
  9794. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9795. /** @hidden */
  9796. export var depthBoxBlurPixelShader: {
  9797. name: string;
  9798. shader: string;
  9799. };
  9800. }
  9801. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9802. import { Nullable } from "babylonjs/types";
  9803. import { Scene } from "babylonjs/scene";
  9804. import { Matrix } from "babylonjs/Maths/math";
  9805. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9807. import { Mesh } from "babylonjs/Meshes/mesh";
  9808. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9809. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9810. import { Effect } from "babylonjs/Materials/effect";
  9811. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9812. import "babylonjs/Shaders/shadowMap.fragment";
  9813. import "babylonjs/Shaders/shadowMap.vertex";
  9814. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9815. import { Observable } from "babylonjs/Misc/observable";
  9816. /**
  9817. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9818. */
  9819. export interface ICustomShaderOptions {
  9820. /**
  9821. * Gets or sets the custom shader name to use
  9822. */
  9823. shaderName: string;
  9824. /**
  9825. * The list of attribute names used in the shader
  9826. */
  9827. attributes?: string[];
  9828. /**
  9829. * The list of unifrom names used in the shader
  9830. */
  9831. uniforms?: string[];
  9832. /**
  9833. * The list of sampler names used in the shader
  9834. */
  9835. samplers?: string[];
  9836. /**
  9837. * The list of defines used in the shader
  9838. */
  9839. defines?: string[];
  9840. }
  9841. /**
  9842. * Interface to implement to create a shadow generator compatible with BJS.
  9843. */
  9844. export interface IShadowGenerator {
  9845. /**
  9846. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9847. * @returns The render target texture if present otherwise, null
  9848. */
  9849. getShadowMap(): Nullable<RenderTargetTexture>;
  9850. /**
  9851. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9852. * @returns The render target texture if the shadow map is present otherwise, null
  9853. */
  9854. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9855. /**
  9856. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9857. * @param subMesh The submesh we want to render in the shadow map
  9858. * @param useInstances Defines wether will draw in the map using instances
  9859. * @returns true if ready otherwise, false
  9860. */
  9861. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9862. /**
  9863. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9864. * @param defines Defines of the material we want to update
  9865. * @param lightIndex Index of the light in the enabled light list of the material
  9866. */
  9867. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9868. /**
  9869. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9870. * defined in the generator but impacting the effect).
  9871. * It implies the unifroms available on the materials are the standard BJS ones.
  9872. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9873. * @param effect The effect we are binfing the information for
  9874. */
  9875. bindShadowLight(lightIndex: string, effect: Effect): void;
  9876. /**
  9877. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9878. * (eq to shadow prjection matrix * light transform matrix)
  9879. * @returns The transform matrix used to create the shadow map
  9880. */
  9881. getTransformMatrix(): Matrix;
  9882. /**
  9883. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9884. * Cube and 2D textures for instance.
  9885. */
  9886. recreateShadowMap(): void;
  9887. /**
  9888. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9889. * @param onCompiled Callback triggered at the and of the effects compilation
  9890. * @param options Sets of optional options forcing the compilation with different modes
  9891. */
  9892. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9893. useInstances: boolean;
  9894. }>): void;
  9895. /**
  9896. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9897. * @param options Sets of optional options forcing the compilation with different modes
  9898. * @returns A promise that resolves when the compilation completes
  9899. */
  9900. forceCompilationAsync(options?: Partial<{
  9901. useInstances: boolean;
  9902. }>): Promise<void>;
  9903. /**
  9904. * Serializes the shadow generator setup to a json object.
  9905. * @returns The serialized JSON object
  9906. */
  9907. serialize(): any;
  9908. /**
  9909. * Disposes the Shadow map and related Textures and effects.
  9910. */
  9911. dispose(): void;
  9912. }
  9913. /**
  9914. * Default implementation IShadowGenerator.
  9915. * This is the main object responsible of generating shadows in the framework.
  9916. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9917. */
  9918. export class ShadowGenerator implements IShadowGenerator {
  9919. /**
  9920. * Shadow generator mode None: no filtering applied.
  9921. */
  9922. static readonly FILTER_NONE: number;
  9923. /**
  9924. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9925. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9926. */
  9927. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9928. /**
  9929. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9930. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9931. */
  9932. static readonly FILTER_POISSONSAMPLING: number;
  9933. /**
  9934. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9935. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9936. */
  9937. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9938. /**
  9939. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9940. * edge artifacts on steep falloff.
  9941. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9942. */
  9943. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9944. /**
  9945. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9946. * edge artifacts on steep falloff.
  9947. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9948. */
  9949. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9950. /**
  9951. * Shadow generator mode PCF: Percentage Closer Filtering
  9952. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9953. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9954. */
  9955. static readonly FILTER_PCF: number;
  9956. /**
  9957. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9958. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9959. * Contact Hardening
  9960. */
  9961. static readonly FILTER_PCSS: number;
  9962. /**
  9963. * Reserved for PCF and PCSS
  9964. * Highest Quality.
  9965. *
  9966. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9967. *
  9968. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9969. */
  9970. static readonly QUALITY_HIGH: number;
  9971. /**
  9972. * Reserved for PCF and PCSS
  9973. * Good tradeoff for quality/perf cross devices
  9974. *
  9975. * Execute PCF on a 3*3 kernel.
  9976. *
  9977. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9978. */
  9979. static readonly QUALITY_MEDIUM: number;
  9980. /**
  9981. * Reserved for PCF and PCSS
  9982. * The lowest quality but the fastest.
  9983. *
  9984. * Execute PCF on a 1*1 kernel.
  9985. *
  9986. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9987. */
  9988. static readonly QUALITY_LOW: number;
  9989. /** Gets or sets the custom shader name to use */
  9990. customShaderOptions: ICustomShaderOptions;
  9991. /**
  9992. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9993. */
  9994. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9995. /**
  9996. * Observable triggered before a mesh is rendered in the shadow map.
  9997. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9998. */
  9999. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10000. private _bias;
  10001. /**
  10002. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10003. */
  10004. /**
  10005. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10006. */
  10007. bias: number;
  10008. private _normalBias;
  10009. /**
  10010. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10011. */
  10012. /**
  10013. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10014. */
  10015. normalBias: number;
  10016. private _blurBoxOffset;
  10017. /**
  10018. * Gets the blur box offset: offset applied during the blur pass.
  10019. * Only useful if useKernelBlur = false
  10020. */
  10021. /**
  10022. * Sets the blur box offset: offset applied during the blur pass.
  10023. * Only useful if useKernelBlur = false
  10024. */
  10025. blurBoxOffset: number;
  10026. private _blurScale;
  10027. /**
  10028. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10029. * 2 means half of the size.
  10030. */
  10031. /**
  10032. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10033. * 2 means half of the size.
  10034. */
  10035. blurScale: number;
  10036. private _blurKernel;
  10037. /**
  10038. * Gets the blur kernel: kernel size of the blur pass.
  10039. * Only useful if useKernelBlur = true
  10040. */
  10041. /**
  10042. * Sets the blur kernel: kernel size of the blur pass.
  10043. * Only useful if useKernelBlur = true
  10044. */
  10045. blurKernel: number;
  10046. private _useKernelBlur;
  10047. /**
  10048. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10049. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10050. */
  10051. /**
  10052. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10053. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10054. */
  10055. useKernelBlur: boolean;
  10056. private _depthScale;
  10057. /**
  10058. * Gets the depth scale used in ESM mode.
  10059. */
  10060. /**
  10061. * Sets the depth scale used in ESM mode.
  10062. * This can override the scale stored on the light.
  10063. */
  10064. depthScale: number;
  10065. private _filter;
  10066. /**
  10067. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10068. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10069. */
  10070. /**
  10071. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10072. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10073. */
  10074. filter: number;
  10075. /**
  10076. * Gets if the current filter is set to Poisson Sampling.
  10077. */
  10078. /**
  10079. * Sets the current filter to Poisson Sampling.
  10080. */
  10081. usePoissonSampling: boolean;
  10082. /**
  10083. * Gets if the current filter is set to ESM.
  10084. */
  10085. /**
  10086. * Sets the current filter is to ESM.
  10087. */
  10088. useExponentialShadowMap: boolean;
  10089. /**
  10090. * Gets if the current filter is set to filtered ESM.
  10091. */
  10092. /**
  10093. * Gets if the current filter is set to filtered ESM.
  10094. */
  10095. useBlurExponentialShadowMap: boolean;
  10096. /**
  10097. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10098. * exponential to prevent steep falloff artifacts).
  10099. */
  10100. /**
  10101. * Sets the current filter to "close ESM" (using the inverse of the
  10102. * exponential to prevent steep falloff artifacts).
  10103. */
  10104. useCloseExponentialShadowMap: boolean;
  10105. /**
  10106. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10107. * exponential to prevent steep falloff artifacts).
  10108. */
  10109. /**
  10110. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10111. * exponential to prevent steep falloff artifacts).
  10112. */
  10113. useBlurCloseExponentialShadowMap: boolean;
  10114. /**
  10115. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10116. */
  10117. /**
  10118. * Sets the current filter to "PCF" (percentage closer filtering).
  10119. */
  10120. usePercentageCloserFiltering: boolean;
  10121. private _filteringQuality;
  10122. /**
  10123. * Gets the PCF or PCSS Quality.
  10124. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10125. */
  10126. /**
  10127. * Sets the PCF or PCSS Quality.
  10128. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10129. */
  10130. filteringQuality: number;
  10131. /**
  10132. * Gets if the current filter is set to "PCSS" (contact hardening).
  10133. */
  10134. /**
  10135. * Sets the current filter to "PCSS" (contact hardening).
  10136. */
  10137. useContactHardeningShadow: boolean;
  10138. private _contactHardeningLightSizeUVRatio;
  10139. /**
  10140. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10141. * Using a ratio helps keeping shape stability independently of the map size.
  10142. *
  10143. * It does not account for the light projection as it was having too much
  10144. * instability during the light setup or during light position changes.
  10145. *
  10146. * Only valid if useContactHardeningShadow is true.
  10147. */
  10148. /**
  10149. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10150. * Using a ratio helps keeping shape stability independently of the map size.
  10151. *
  10152. * It does not account for the light projection as it was having too much
  10153. * instability during the light setup or during light position changes.
  10154. *
  10155. * Only valid if useContactHardeningShadow is true.
  10156. */
  10157. contactHardeningLightSizeUVRatio: number;
  10158. private _darkness;
  10159. /**
  10160. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10161. * 0 means strongest and 1 would means no shadow.
  10162. * @returns the darkness.
  10163. */
  10164. getDarkness(): number;
  10165. /**
  10166. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10167. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10168. * @returns the shadow generator allowing fluent coding.
  10169. */
  10170. setDarkness(darkness: number): ShadowGenerator;
  10171. private _transparencyShadow;
  10172. /**
  10173. * Sets the ability to have transparent shadow (boolean).
  10174. * @param transparent True if transparent else False
  10175. * @returns the shadow generator allowing fluent coding
  10176. */
  10177. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10178. private _shadowMap;
  10179. private _shadowMap2;
  10180. /**
  10181. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10182. * @returns The render target texture if present otherwise, null
  10183. */
  10184. getShadowMap(): Nullable<RenderTargetTexture>;
  10185. /**
  10186. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10187. * @returns The render target texture if the shadow map is present otherwise, null
  10188. */
  10189. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10190. /**
  10191. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10192. * @param mesh Mesh to add
  10193. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10194. * @returns the Shadow Generator itself
  10195. */
  10196. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10197. /**
  10198. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10199. * @param mesh Mesh to remove
  10200. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10201. * @returns the Shadow Generator itself
  10202. */
  10203. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10204. /**
  10205. * Controls the extent to which the shadows fade out at the edge of the frustum
  10206. * Used only by directionals and spots
  10207. */
  10208. frustumEdgeFalloff: number;
  10209. private _light;
  10210. /**
  10211. * Returns the associated light object.
  10212. * @returns the light generating the shadow
  10213. */
  10214. getLight(): IShadowLight;
  10215. /**
  10216. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10217. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10218. * It might on the other hand introduce peter panning.
  10219. */
  10220. forceBackFacesOnly: boolean;
  10221. private _scene;
  10222. private _lightDirection;
  10223. private _effect;
  10224. private _viewMatrix;
  10225. private _projectionMatrix;
  10226. private _transformMatrix;
  10227. private _cachedPosition;
  10228. private _cachedDirection;
  10229. private _cachedDefines;
  10230. private _currentRenderID;
  10231. private _boxBlurPostprocess;
  10232. private _kernelBlurXPostprocess;
  10233. private _kernelBlurYPostprocess;
  10234. private _blurPostProcesses;
  10235. private _mapSize;
  10236. private _currentFaceIndex;
  10237. private _currentFaceIndexCache;
  10238. private _textureType;
  10239. private _defaultTextureMatrix;
  10240. /** @hidden */
  10241. static _SceneComponentInitialization: (scene: Scene) => void;
  10242. /**
  10243. * Creates a ShadowGenerator object.
  10244. * A ShadowGenerator is the required tool to use the shadows.
  10245. * Each light casting shadows needs to use its own ShadowGenerator.
  10246. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10247. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10248. * @param light The light object generating the shadows.
  10249. * @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.
  10250. */
  10251. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10252. private _initializeGenerator;
  10253. private _initializeShadowMap;
  10254. private _initializeBlurRTTAndPostProcesses;
  10255. private _renderForShadowMap;
  10256. private _renderSubMeshForShadowMap;
  10257. private _applyFilterValues;
  10258. /**
  10259. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10260. * @param onCompiled Callback triggered at the and of the effects compilation
  10261. * @param options Sets of optional options forcing the compilation with different modes
  10262. */
  10263. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10264. useInstances: boolean;
  10265. }>): void;
  10266. /**
  10267. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10268. * @param options Sets of optional options forcing the compilation with different modes
  10269. * @returns A promise that resolves when the compilation completes
  10270. */
  10271. forceCompilationAsync(options?: Partial<{
  10272. useInstances: boolean;
  10273. }>): Promise<void>;
  10274. /**
  10275. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10276. * @param subMesh The submesh we want to render in the shadow map
  10277. * @param useInstances Defines wether will draw in the map using instances
  10278. * @returns true if ready otherwise, false
  10279. */
  10280. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10281. /**
  10282. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10283. * @param defines Defines of the material we want to update
  10284. * @param lightIndex Index of the light in the enabled light list of the material
  10285. */
  10286. prepareDefines(defines: any, lightIndex: number): void;
  10287. /**
  10288. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10289. * defined in the generator but impacting the effect).
  10290. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10291. * @param effect The effect we are binfing the information for
  10292. */
  10293. bindShadowLight(lightIndex: string, effect: Effect): void;
  10294. /**
  10295. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10296. * (eq to shadow prjection matrix * light transform matrix)
  10297. * @returns The transform matrix used to create the shadow map
  10298. */
  10299. getTransformMatrix(): Matrix;
  10300. /**
  10301. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10302. * Cube and 2D textures for instance.
  10303. */
  10304. recreateShadowMap(): void;
  10305. private _disposeBlurPostProcesses;
  10306. private _disposeRTTandPostProcesses;
  10307. /**
  10308. * Disposes the ShadowGenerator.
  10309. * Returns nothing.
  10310. */
  10311. dispose(): void;
  10312. /**
  10313. * Serializes the shadow generator setup to a json object.
  10314. * @returns The serialized JSON object
  10315. */
  10316. serialize(): any;
  10317. /**
  10318. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10319. * @param parsedShadowGenerator The JSON object to parse
  10320. * @param scene The scene to create the shadow map for
  10321. * @returns The parsed shadow generator
  10322. */
  10323. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10324. }
  10325. }
  10326. declare module "babylonjs/Lights/light" {
  10327. import { Nullable } from "babylonjs/types";
  10328. import { Scene } from "babylonjs/scene";
  10329. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10330. import { Node } from "babylonjs/node";
  10331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10332. import { Effect } from "babylonjs/Materials/effect";
  10333. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10334. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10335. /**
  10336. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10337. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10338. * 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.
  10339. */
  10340. export abstract class Light extends Node {
  10341. /**
  10342. * Falloff Default: light is falling off following the material specification:
  10343. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10344. */
  10345. static readonly FALLOFF_DEFAULT: number;
  10346. /**
  10347. * Falloff Physical: light is falling off following the inverse squared distance law.
  10348. */
  10349. static readonly FALLOFF_PHYSICAL: number;
  10350. /**
  10351. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10352. * to enhance interoperability with other engines.
  10353. */
  10354. static readonly FALLOFF_GLTF: number;
  10355. /**
  10356. * Falloff Standard: light is falling off like in the standard material
  10357. * to enhance interoperability with other materials.
  10358. */
  10359. static readonly FALLOFF_STANDARD: number;
  10360. /**
  10361. * If every light affecting the material is in this lightmapMode,
  10362. * material.lightmapTexture adds or multiplies
  10363. * (depends on material.useLightmapAsShadowmap)
  10364. * after every other light calculations.
  10365. */
  10366. static readonly LIGHTMAP_DEFAULT: number;
  10367. /**
  10368. * material.lightmapTexture as only diffuse lighting from this light
  10369. * adds only specular lighting from this light
  10370. * adds dynamic shadows
  10371. */
  10372. static readonly LIGHTMAP_SPECULAR: number;
  10373. /**
  10374. * material.lightmapTexture as only lighting
  10375. * no light calculation from this light
  10376. * only adds dynamic shadows from this light
  10377. */
  10378. static readonly LIGHTMAP_SHADOWSONLY: number;
  10379. /**
  10380. * Each light type uses the default quantity according to its type:
  10381. * point/spot lights use luminous intensity
  10382. * directional lights use illuminance
  10383. */
  10384. static readonly INTENSITYMODE_AUTOMATIC: number;
  10385. /**
  10386. * lumen (lm)
  10387. */
  10388. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10389. /**
  10390. * candela (lm/sr)
  10391. */
  10392. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10393. /**
  10394. * lux (lm/m^2)
  10395. */
  10396. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10397. /**
  10398. * nit (cd/m^2)
  10399. */
  10400. static readonly INTENSITYMODE_LUMINANCE: number;
  10401. /**
  10402. * Light type const id of the point light.
  10403. */
  10404. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10405. /**
  10406. * Light type const id of the directional light.
  10407. */
  10408. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10409. /**
  10410. * Light type const id of the spot light.
  10411. */
  10412. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10413. /**
  10414. * Light type const id of the hemispheric light.
  10415. */
  10416. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10417. /**
  10418. * Diffuse gives the basic color to an object.
  10419. */
  10420. diffuse: Color3;
  10421. /**
  10422. * Specular produces a highlight color on an object.
  10423. * Note: This is note affecting PBR materials.
  10424. */
  10425. specular: Color3;
  10426. /**
  10427. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10428. * falling off base on range or angle.
  10429. * This can be set to any values in Light.FALLOFF_x.
  10430. *
  10431. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10432. * other types of materials.
  10433. */
  10434. falloffType: number;
  10435. /**
  10436. * Strength of the light.
  10437. * Note: By default it is define in the framework own unit.
  10438. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10439. */
  10440. intensity: number;
  10441. private _range;
  10442. protected _inverseSquaredRange: number;
  10443. /**
  10444. * Defines how far from the source the light is impacting in scene units.
  10445. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10446. */
  10447. /**
  10448. * Defines how far from the source the light is impacting in scene units.
  10449. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10450. */
  10451. range: number;
  10452. /**
  10453. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10454. * of light.
  10455. */
  10456. private _photometricScale;
  10457. private _intensityMode;
  10458. /**
  10459. * Gets the photometric scale used to interpret the intensity.
  10460. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10461. */
  10462. /**
  10463. * Sets the photometric scale used to interpret the intensity.
  10464. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10465. */
  10466. intensityMode: number;
  10467. private _radius;
  10468. /**
  10469. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10470. */
  10471. /**
  10472. * sets the light radius used by PBR Materials to simulate soft area lights.
  10473. */
  10474. radius: number;
  10475. private _renderPriority;
  10476. /**
  10477. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10478. * exceeding the number allowed of the materials.
  10479. */
  10480. renderPriority: number;
  10481. private _shadowEnabled;
  10482. /**
  10483. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10484. * the current shadow generator.
  10485. */
  10486. /**
  10487. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10488. * the current shadow generator.
  10489. */
  10490. shadowEnabled: boolean;
  10491. private _includedOnlyMeshes;
  10492. /**
  10493. * Gets the only meshes impacted by this light.
  10494. */
  10495. /**
  10496. * Sets the only meshes impacted by this light.
  10497. */
  10498. includedOnlyMeshes: AbstractMesh[];
  10499. private _excludedMeshes;
  10500. /**
  10501. * Gets the meshes not impacted by this light.
  10502. */
  10503. /**
  10504. * Sets the meshes not impacted by this light.
  10505. */
  10506. excludedMeshes: AbstractMesh[];
  10507. private _excludeWithLayerMask;
  10508. /**
  10509. * Gets the layer id use to find what meshes are not impacted by the light.
  10510. * Inactive if 0
  10511. */
  10512. /**
  10513. * Sets the layer id use to find what meshes are not impacted by the light.
  10514. * Inactive if 0
  10515. */
  10516. excludeWithLayerMask: number;
  10517. private _includeOnlyWithLayerMask;
  10518. /**
  10519. * Gets the layer id use to find what meshes are impacted by the light.
  10520. * Inactive if 0
  10521. */
  10522. /**
  10523. * Sets the layer id use to find what meshes are impacted by the light.
  10524. * Inactive if 0
  10525. */
  10526. includeOnlyWithLayerMask: number;
  10527. private _lightmapMode;
  10528. /**
  10529. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10530. */
  10531. /**
  10532. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10533. */
  10534. lightmapMode: number;
  10535. /**
  10536. * Shadow generator associted to the light.
  10537. * @hidden Internal use only.
  10538. */
  10539. _shadowGenerator: Nullable<IShadowGenerator>;
  10540. /**
  10541. * @hidden Internal use only.
  10542. */
  10543. _excludedMeshesIds: string[];
  10544. /**
  10545. * @hidden Internal use only.
  10546. */
  10547. _includedOnlyMeshesIds: string[];
  10548. /**
  10549. * The current light unifom buffer.
  10550. * @hidden Internal use only.
  10551. */
  10552. _uniformBuffer: UniformBuffer;
  10553. /**
  10554. * Creates a Light object in the scene.
  10555. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10556. * @param name The firendly name of the light
  10557. * @param scene The scene the light belongs too
  10558. */
  10559. constructor(name: string, scene: Scene);
  10560. protected abstract _buildUniformLayout(): void;
  10561. /**
  10562. * Sets the passed Effect "effect" with the Light information.
  10563. * @param effect The effect to update
  10564. * @param lightIndex The index of the light in the effect to update
  10565. * @returns The light
  10566. */
  10567. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10568. /**
  10569. * Returns the string "Light".
  10570. * @returns the class name
  10571. */
  10572. getClassName(): string;
  10573. /** @hidden */
  10574. readonly _isLight: boolean;
  10575. /**
  10576. * Converts the light information to a readable string for debug purpose.
  10577. * @param fullDetails Supports for multiple levels of logging within scene loading
  10578. * @returns the human readable light info
  10579. */
  10580. toString(fullDetails?: boolean): string;
  10581. /** @hidden */
  10582. protected _syncParentEnabledState(): void;
  10583. /**
  10584. * Set the enabled state of this node.
  10585. * @param value - the new enabled state
  10586. */
  10587. setEnabled(value: boolean): void;
  10588. /**
  10589. * Returns the Light associated shadow generator if any.
  10590. * @return the associated shadow generator.
  10591. */
  10592. getShadowGenerator(): Nullable<IShadowGenerator>;
  10593. /**
  10594. * Returns a Vector3, the absolute light position in the World.
  10595. * @returns the world space position of the light
  10596. */
  10597. getAbsolutePosition(): Vector3;
  10598. /**
  10599. * Specifies if the light will affect the passed mesh.
  10600. * @param mesh The mesh to test against the light
  10601. * @return true the mesh is affected otherwise, false.
  10602. */
  10603. canAffectMesh(mesh: AbstractMesh): boolean;
  10604. /**
  10605. * Sort function to order lights for rendering.
  10606. * @param a First Light object to compare to second.
  10607. * @param b Second Light object to compare first.
  10608. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10609. */
  10610. static CompareLightsPriority(a: Light, b: Light): number;
  10611. /**
  10612. * Releases resources associated with this node.
  10613. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10614. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10615. */
  10616. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10617. /**
  10618. * Returns the light type ID (integer).
  10619. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10620. */
  10621. getTypeID(): number;
  10622. /**
  10623. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10624. * @returns the scaled intensity in intensity mode unit
  10625. */
  10626. getScaledIntensity(): number;
  10627. /**
  10628. * Returns a new Light object, named "name", from the current one.
  10629. * @param name The name of the cloned light
  10630. * @returns the new created light
  10631. */
  10632. clone(name: string): Nullable<Light>;
  10633. /**
  10634. * Serializes the current light into a Serialization object.
  10635. * @returns the serialized object.
  10636. */
  10637. serialize(): any;
  10638. /**
  10639. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10640. * This new light is named "name" and added to the passed scene.
  10641. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10642. * @param name The friendly name of the light
  10643. * @param scene The scene the new light will belong to
  10644. * @returns the constructor function
  10645. */
  10646. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10647. /**
  10648. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10649. * @param parsedLight The JSON representation of the light
  10650. * @param scene The scene to create the parsed light in
  10651. * @returns the created light after parsing
  10652. */
  10653. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10654. private _hookArrayForExcluded;
  10655. private _hookArrayForIncludedOnly;
  10656. private _resyncMeshes;
  10657. /**
  10658. * Forces the meshes to update their light related information in their rendering used effects
  10659. * @hidden Internal Use Only
  10660. */
  10661. _markMeshesAsLightDirty(): void;
  10662. /**
  10663. * Recomputes the cached photometric scale if needed.
  10664. */
  10665. private _computePhotometricScale;
  10666. /**
  10667. * Returns the Photometric Scale according to the light type and intensity mode.
  10668. */
  10669. private _getPhotometricScale;
  10670. /**
  10671. * Reorder the light in the scene according to their defined priority.
  10672. * @hidden Internal Use Only
  10673. */
  10674. _reorderLightsInScene(): void;
  10675. /**
  10676. * Prepares the list of defines specific to the light type.
  10677. * @param defines the list of defines
  10678. * @param lightIndex defines the index of the light for the effect
  10679. */
  10680. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10681. }
  10682. }
  10683. declare module "babylonjs/Actions/action" {
  10684. import { Observable } from "babylonjs/Misc/observable";
  10685. import { Condition } from "babylonjs/Actions/condition";
  10686. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10687. import { ActionManager } from "babylonjs/Actions/actionManager";
  10688. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10689. /**
  10690. * Interface used to define Action
  10691. */
  10692. export interface IAction {
  10693. /**
  10694. * Trigger for the action
  10695. */
  10696. trigger: number;
  10697. /** Options of the trigger */
  10698. triggerOptions: any;
  10699. /**
  10700. * Gets the trigger parameters
  10701. * @returns the trigger parameters
  10702. */
  10703. getTriggerParameter(): any;
  10704. /**
  10705. * Internal only - executes current action event
  10706. * @hidden
  10707. */
  10708. _executeCurrent(evt?: ActionEvent): void;
  10709. /**
  10710. * Serialize placeholder for child classes
  10711. * @param parent of child
  10712. * @returns the serialized object
  10713. */
  10714. serialize(parent: any): any;
  10715. /**
  10716. * Internal only
  10717. * @hidden
  10718. */
  10719. _prepare(): void;
  10720. /**
  10721. * Internal only - manager for action
  10722. * @hidden
  10723. */
  10724. _actionManager: AbstractActionManager;
  10725. }
  10726. /**
  10727. * The action to be carried out following a trigger
  10728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10729. */
  10730. export class Action implements IAction {
  10731. /** the trigger, with or without parameters, for the action */
  10732. triggerOptions: any;
  10733. /**
  10734. * Trigger for the action
  10735. */
  10736. trigger: number;
  10737. /**
  10738. * Internal only - manager for action
  10739. * @hidden
  10740. */
  10741. _actionManager: ActionManager;
  10742. private _nextActiveAction;
  10743. private _child;
  10744. private _condition?;
  10745. private _triggerParameter;
  10746. /**
  10747. * An event triggered prior to action being executed.
  10748. */
  10749. onBeforeExecuteObservable: Observable<Action>;
  10750. /**
  10751. * Creates a new Action
  10752. * @param triggerOptions the trigger, with or without parameters, for the action
  10753. * @param condition an optional determinant of action
  10754. */
  10755. constructor(
  10756. /** the trigger, with or without parameters, for the action */
  10757. triggerOptions: any, condition?: Condition);
  10758. /**
  10759. * Internal only
  10760. * @hidden
  10761. */
  10762. _prepare(): void;
  10763. /**
  10764. * Gets the trigger parameters
  10765. * @returns the trigger parameters
  10766. */
  10767. getTriggerParameter(): any;
  10768. /**
  10769. * Internal only - executes current action event
  10770. * @hidden
  10771. */
  10772. _executeCurrent(evt?: ActionEvent): void;
  10773. /**
  10774. * Execute placeholder for child classes
  10775. * @param evt optional action event
  10776. */
  10777. execute(evt?: ActionEvent): void;
  10778. /**
  10779. * Skips to next active action
  10780. */
  10781. skipToNextActiveAction(): void;
  10782. /**
  10783. * Adds action to chain of actions, may be a DoNothingAction
  10784. * @param action defines the next action to execute
  10785. * @returns The action passed in
  10786. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10787. */
  10788. then(action: Action): Action;
  10789. /**
  10790. * Internal only
  10791. * @hidden
  10792. */
  10793. _getProperty(propertyPath: string): string;
  10794. /**
  10795. * Internal only
  10796. * @hidden
  10797. */
  10798. _getEffectiveTarget(target: any, propertyPath: string): any;
  10799. /**
  10800. * Serialize placeholder for child classes
  10801. * @param parent of child
  10802. * @returns the serialized object
  10803. */
  10804. serialize(parent: any): any;
  10805. /**
  10806. * Internal only called by serialize
  10807. * @hidden
  10808. */
  10809. protected _serialize(serializedAction: any, parent?: any): any;
  10810. /**
  10811. * Internal only
  10812. * @hidden
  10813. */
  10814. static _SerializeValueAsString: (value: any) => string;
  10815. /**
  10816. * Internal only
  10817. * @hidden
  10818. */
  10819. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10820. name: string;
  10821. targetType: string;
  10822. value: string;
  10823. };
  10824. }
  10825. }
  10826. declare module "babylonjs/Actions/condition" {
  10827. import { ActionManager } from "babylonjs/Actions/actionManager";
  10828. /**
  10829. * A Condition applied to an Action
  10830. */
  10831. export class Condition {
  10832. /**
  10833. * Internal only - manager for action
  10834. * @hidden
  10835. */
  10836. _actionManager: ActionManager;
  10837. /**
  10838. * Internal only
  10839. * @hidden
  10840. */
  10841. _evaluationId: number;
  10842. /**
  10843. * Internal only
  10844. * @hidden
  10845. */
  10846. _currentResult: boolean;
  10847. /**
  10848. * Creates a new Condition
  10849. * @param actionManager the manager of the action the condition is applied to
  10850. */
  10851. constructor(actionManager: ActionManager);
  10852. /**
  10853. * Check if the current condition is valid
  10854. * @returns a boolean
  10855. */
  10856. isValid(): boolean;
  10857. /**
  10858. * Internal only
  10859. * @hidden
  10860. */
  10861. _getProperty(propertyPath: string): string;
  10862. /**
  10863. * Internal only
  10864. * @hidden
  10865. */
  10866. _getEffectiveTarget(target: any, propertyPath: string): any;
  10867. /**
  10868. * Serialize placeholder for child classes
  10869. * @returns the serialized object
  10870. */
  10871. serialize(): any;
  10872. /**
  10873. * Internal only
  10874. * @hidden
  10875. */
  10876. protected _serialize(serializedCondition: any): any;
  10877. }
  10878. /**
  10879. * Defines specific conditional operators as extensions of Condition
  10880. */
  10881. export class ValueCondition extends Condition {
  10882. /** path to specify the property of the target the conditional operator uses */
  10883. propertyPath: string;
  10884. /** the value compared by the conditional operator against the current value of the property */
  10885. value: any;
  10886. /** the conditional operator, default ValueCondition.IsEqual */
  10887. operator: number;
  10888. /**
  10889. * Internal only
  10890. * @hidden
  10891. */
  10892. private static _IsEqual;
  10893. /**
  10894. * Internal only
  10895. * @hidden
  10896. */
  10897. private static _IsDifferent;
  10898. /**
  10899. * Internal only
  10900. * @hidden
  10901. */
  10902. private static _IsGreater;
  10903. /**
  10904. * Internal only
  10905. * @hidden
  10906. */
  10907. private static _IsLesser;
  10908. /**
  10909. * returns the number for IsEqual
  10910. */
  10911. static readonly IsEqual: number;
  10912. /**
  10913. * Returns the number for IsDifferent
  10914. */
  10915. static readonly IsDifferent: number;
  10916. /**
  10917. * Returns the number for IsGreater
  10918. */
  10919. static readonly IsGreater: number;
  10920. /**
  10921. * Returns the number for IsLesser
  10922. */
  10923. static readonly IsLesser: number;
  10924. /**
  10925. * Internal only The action manager for the condition
  10926. * @hidden
  10927. */
  10928. _actionManager: ActionManager;
  10929. /**
  10930. * Internal only
  10931. * @hidden
  10932. */
  10933. private _target;
  10934. /**
  10935. * Internal only
  10936. * @hidden
  10937. */
  10938. private _effectiveTarget;
  10939. /**
  10940. * Internal only
  10941. * @hidden
  10942. */
  10943. private _property;
  10944. /**
  10945. * Creates a new ValueCondition
  10946. * @param actionManager manager for the action the condition applies to
  10947. * @param target for the action
  10948. * @param propertyPath path to specify the property of the target the conditional operator uses
  10949. * @param value the value compared by the conditional operator against the current value of the property
  10950. * @param operator the conditional operator, default ValueCondition.IsEqual
  10951. */
  10952. constructor(actionManager: ActionManager, target: any,
  10953. /** path to specify the property of the target the conditional operator uses */
  10954. propertyPath: string,
  10955. /** the value compared by the conditional operator against the current value of the property */
  10956. value: any,
  10957. /** the conditional operator, default ValueCondition.IsEqual */
  10958. operator?: number);
  10959. /**
  10960. * Compares the given value with the property value for the specified conditional operator
  10961. * @returns the result of the comparison
  10962. */
  10963. isValid(): boolean;
  10964. /**
  10965. * Serialize the ValueCondition into a JSON compatible object
  10966. * @returns serialization object
  10967. */
  10968. serialize(): any;
  10969. /**
  10970. * Gets the name of the conditional operator for the ValueCondition
  10971. * @param operator the conditional operator
  10972. * @returns the name
  10973. */
  10974. static GetOperatorName(operator: number): string;
  10975. }
  10976. /**
  10977. * Defines a predicate condition as an extension of Condition
  10978. */
  10979. export class PredicateCondition extends Condition {
  10980. /** defines the predicate function used to validate the condition */
  10981. predicate: () => boolean;
  10982. /**
  10983. * Internal only - manager for action
  10984. * @hidden
  10985. */
  10986. _actionManager: ActionManager;
  10987. /**
  10988. * Creates a new PredicateCondition
  10989. * @param actionManager manager for the action the condition applies to
  10990. * @param predicate defines the predicate function used to validate the condition
  10991. */
  10992. constructor(actionManager: ActionManager,
  10993. /** defines the predicate function used to validate the condition */
  10994. predicate: () => boolean);
  10995. /**
  10996. * @returns the validity of the predicate condition
  10997. */
  10998. isValid(): boolean;
  10999. }
  11000. /**
  11001. * Defines a state condition as an extension of Condition
  11002. */
  11003. export class StateCondition extends Condition {
  11004. /** Value to compare with target state */
  11005. value: string;
  11006. /**
  11007. * Internal only - manager for action
  11008. * @hidden
  11009. */
  11010. _actionManager: ActionManager;
  11011. /**
  11012. * Internal only
  11013. * @hidden
  11014. */
  11015. private _target;
  11016. /**
  11017. * Creates a new StateCondition
  11018. * @param actionManager manager for the action the condition applies to
  11019. * @param target of the condition
  11020. * @param value to compare with target state
  11021. */
  11022. constructor(actionManager: ActionManager, target: any,
  11023. /** Value to compare with target state */
  11024. value: string);
  11025. /**
  11026. * Gets a boolean indicating if the current condition is met
  11027. * @returns the validity of the state
  11028. */
  11029. isValid(): boolean;
  11030. /**
  11031. * Serialize the StateCondition into a JSON compatible object
  11032. * @returns serialization object
  11033. */
  11034. serialize(): any;
  11035. }
  11036. }
  11037. declare module "babylonjs/Actions/directActions" {
  11038. import { Action } from "babylonjs/Actions/action";
  11039. import { Condition } from "babylonjs/Actions/condition";
  11040. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11041. /**
  11042. * This defines an action responsible to toggle a boolean once triggered.
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11044. */
  11045. export class SwitchBooleanAction extends Action {
  11046. /**
  11047. * The path to the boolean property in the target object
  11048. */
  11049. propertyPath: string;
  11050. private _target;
  11051. private _effectiveTarget;
  11052. private _property;
  11053. /**
  11054. * Instantiate the action
  11055. * @param triggerOptions defines the trigger options
  11056. * @param target defines the object containing the boolean
  11057. * @param propertyPath defines the path to the boolean property in the target object
  11058. * @param condition defines the trigger related conditions
  11059. */
  11060. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11061. /** @hidden */
  11062. _prepare(): void;
  11063. /**
  11064. * Execute the action toggle the boolean value.
  11065. */
  11066. execute(): void;
  11067. /**
  11068. * Serializes the actions and its related information.
  11069. * @param parent defines the object to serialize in
  11070. * @returns the serialized object
  11071. */
  11072. serialize(parent: any): any;
  11073. }
  11074. /**
  11075. * This defines an action responsible to set a the state field of the target
  11076. * to a desired value once triggered.
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11078. */
  11079. export class SetStateAction extends Action {
  11080. /**
  11081. * The value to store in the state field.
  11082. */
  11083. value: string;
  11084. private _target;
  11085. /**
  11086. * Instantiate the action
  11087. * @param triggerOptions defines the trigger options
  11088. * @param target defines the object containing the state property
  11089. * @param value defines the value to store in the state field
  11090. * @param condition defines the trigger related conditions
  11091. */
  11092. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11093. /**
  11094. * Execute the action and store the value on the target state property.
  11095. */
  11096. execute(): void;
  11097. /**
  11098. * Serializes the actions and its related information.
  11099. * @param parent defines the object to serialize in
  11100. * @returns the serialized object
  11101. */
  11102. serialize(parent: any): any;
  11103. }
  11104. /**
  11105. * This defines an action responsible to set a property of the target
  11106. * to a desired value once triggered.
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11108. */
  11109. export class SetValueAction extends Action {
  11110. /**
  11111. * The path of the property to set in the target.
  11112. */
  11113. propertyPath: string;
  11114. /**
  11115. * The value to set in the property
  11116. */
  11117. value: any;
  11118. private _target;
  11119. private _effectiveTarget;
  11120. private _property;
  11121. /**
  11122. * Instantiate the action
  11123. * @param triggerOptions defines the trigger options
  11124. * @param target defines the object containing the property
  11125. * @param propertyPath defines the path of the property to set in the target
  11126. * @param value defines the value to set in the property
  11127. * @param condition defines the trigger related conditions
  11128. */
  11129. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11130. /** @hidden */
  11131. _prepare(): void;
  11132. /**
  11133. * Execute the action and set the targetted property to the desired value.
  11134. */
  11135. execute(): void;
  11136. /**
  11137. * Serializes the actions and its related information.
  11138. * @param parent defines the object to serialize in
  11139. * @returns the serialized object
  11140. */
  11141. serialize(parent: any): any;
  11142. }
  11143. /**
  11144. * This defines an action responsible to increment the target value
  11145. * to a desired value once triggered.
  11146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11147. */
  11148. export class IncrementValueAction extends Action {
  11149. /**
  11150. * The path of the property to increment in the target.
  11151. */
  11152. propertyPath: string;
  11153. /**
  11154. * The value we should increment the property by.
  11155. */
  11156. value: any;
  11157. private _target;
  11158. private _effectiveTarget;
  11159. private _property;
  11160. /**
  11161. * Instantiate the action
  11162. * @param triggerOptions defines the trigger options
  11163. * @param target defines the object containing the property
  11164. * @param propertyPath defines the path of the property to increment in the target
  11165. * @param value defines the value value we should increment the property by
  11166. * @param condition defines the trigger related conditions
  11167. */
  11168. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11169. /** @hidden */
  11170. _prepare(): void;
  11171. /**
  11172. * Execute the action and increment the target of the value amount.
  11173. */
  11174. execute(): void;
  11175. /**
  11176. * Serializes the actions and its related information.
  11177. * @param parent defines the object to serialize in
  11178. * @returns the serialized object
  11179. */
  11180. serialize(parent: any): any;
  11181. }
  11182. /**
  11183. * This defines an action responsible to start an animation once triggered.
  11184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11185. */
  11186. export class PlayAnimationAction extends Action {
  11187. /**
  11188. * Where the animation should start (animation frame)
  11189. */
  11190. from: number;
  11191. /**
  11192. * Where the animation should stop (animation frame)
  11193. */
  11194. to: number;
  11195. /**
  11196. * Define if the animation should loop or stop after the first play.
  11197. */
  11198. loop?: boolean;
  11199. private _target;
  11200. /**
  11201. * Instantiate the action
  11202. * @param triggerOptions defines the trigger options
  11203. * @param target defines the target animation or animation name
  11204. * @param from defines from where the animation should start (animation frame)
  11205. * @param end defines where the animation should stop (animation frame)
  11206. * @param loop defines if the animation should loop or stop after the first play
  11207. * @param condition defines the trigger related conditions
  11208. */
  11209. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11210. /** @hidden */
  11211. _prepare(): void;
  11212. /**
  11213. * Execute the action and play the animation.
  11214. */
  11215. execute(): void;
  11216. /**
  11217. * Serializes the actions and its related information.
  11218. * @param parent defines the object to serialize in
  11219. * @returns the serialized object
  11220. */
  11221. serialize(parent: any): any;
  11222. }
  11223. /**
  11224. * This defines an action responsible to stop an animation once triggered.
  11225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11226. */
  11227. export class StopAnimationAction extends Action {
  11228. private _target;
  11229. /**
  11230. * Instantiate the action
  11231. * @param triggerOptions defines the trigger options
  11232. * @param target defines the target animation or animation name
  11233. * @param condition defines the trigger related conditions
  11234. */
  11235. constructor(triggerOptions: any, target: any, condition?: Condition);
  11236. /** @hidden */
  11237. _prepare(): void;
  11238. /**
  11239. * Execute the action and stop the animation.
  11240. */
  11241. execute(): void;
  11242. /**
  11243. * Serializes the actions and its related information.
  11244. * @param parent defines the object to serialize in
  11245. * @returns the serialized object
  11246. */
  11247. serialize(parent: any): any;
  11248. }
  11249. /**
  11250. * This defines an action responsible that does nothing once triggered.
  11251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11252. */
  11253. export class DoNothingAction extends Action {
  11254. /**
  11255. * Instantiate the action
  11256. * @param triggerOptions defines the trigger options
  11257. * @param condition defines the trigger related conditions
  11258. */
  11259. constructor(triggerOptions?: any, condition?: Condition);
  11260. /**
  11261. * Execute the action and do nothing.
  11262. */
  11263. execute(): void;
  11264. /**
  11265. * Serializes the actions and its related information.
  11266. * @param parent defines the object to serialize in
  11267. * @returns the serialized object
  11268. */
  11269. serialize(parent: any): any;
  11270. }
  11271. /**
  11272. * This defines an action responsible to trigger several actions once triggered.
  11273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11274. */
  11275. export class CombineAction extends Action {
  11276. /**
  11277. * The list of aggregated animations to run.
  11278. */
  11279. children: Action[];
  11280. /**
  11281. * Instantiate the action
  11282. * @param triggerOptions defines the trigger options
  11283. * @param children defines the list of aggregated animations to run
  11284. * @param condition defines the trigger related conditions
  11285. */
  11286. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11287. /** @hidden */
  11288. _prepare(): void;
  11289. /**
  11290. * Execute the action and executes all the aggregated actions.
  11291. */
  11292. execute(evt: ActionEvent): void;
  11293. /**
  11294. * Serializes the actions and its related information.
  11295. * @param parent defines the object to serialize in
  11296. * @returns the serialized object
  11297. */
  11298. serialize(parent: any): any;
  11299. }
  11300. /**
  11301. * This defines an action responsible to run code (external event) once triggered.
  11302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11303. */
  11304. export class ExecuteCodeAction extends Action {
  11305. /**
  11306. * The callback function to run.
  11307. */
  11308. func: (evt: ActionEvent) => void;
  11309. /**
  11310. * Instantiate the action
  11311. * @param triggerOptions defines the trigger options
  11312. * @param func defines the callback function to run
  11313. * @param condition defines the trigger related conditions
  11314. */
  11315. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11316. /**
  11317. * Execute the action and run the attached code.
  11318. */
  11319. execute(evt: ActionEvent): void;
  11320. }
  11321. /**
  11322. * This defines an action responsible to set the parent property of the target once triggered.
  11323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11324. */
  11325. export class SetParentAction extends Action {
  11326. private _parent;
  11327. private _target;
  11328. /**
  11329. * Instantiate the action
  11330. * @param triggerOptions defines the trigger options
  11331. * @param target defines the target containing the parent property
  11332. * @param parent defines from where the animation should start (animation frame)
  11333. * @param condition defines the trigger related conditions
  11334. */
  11335. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11336. /** @hidden */
  11337. _prepare(): void;
  11338. /**
  11339. * Execute the action and set the parent property.
  11340. */
  11341. execute(): void;
  11342. /**
  11343. * Serializes the actions and its related information.
  11344. * @param parent defines the object to serialize in
  11345. * @returns the serialized object
  11346. */
  11347. serialize(parent: any): any;
  11348. }
  11349. }
  11350. declare module "babylonjs/Actions/actionManager" {
  11351. import { Nullable } from "babylonjs/types";
  11352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11353. import { Scene } from "babylonjs/scene";
  11354. import { IAction } from "babylonjs/Actions/action";
  11355. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11356. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11357. /**
  11358. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11359. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11361. */
  11362. export class ActionManager extends AbstractActionManager {
  11363. /**
  11364. * Nothing
  11365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11366. */
  11367. static readonly NothingTrigger: number;
  11368. /**
  11369. * On pick
  11370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11371. */
  11372. static readonly OnPickTrigger: number;
  11373. /**
  11374. * On left pick
  11375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11376. */
  11377. static readonly OnLeftPickTrigger: number;
  11378. /**
  11379. * On right pick
  11380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11381. */
  11382. static readonly OnRightPickTrigger: number;
  11383. /**
  11384. * On center pick
  11385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11386. */
  11387. static readonly OnCenterPickTrigger: number;
  11388. /**
  11389. * On pick down
  11390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11391. */
  11392. static readonly OnPickDownTrigger: number;
  11393. /**
  11394. * On double pick
  11395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11396. */
  11397. static readonly OnDoublePickTrigger: number;
  11398. /**
  11399. * On pick up
  11400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11401. */
  11402. static readonly OnPickUpTrigger: number;
  11403. /**
  11404. * On pick out.
  11405. * This trigger will only be raised if you also declared a OnPickDown
  11406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11407. */
  11408. static readonly OnPickOutTrigger: number;
  11409. /**
  11410. * On long press
  11411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11412. */
  11413. static readonly OnLongPressTrigger: number;
  11414. /**
  11415. * On pointer over
  11416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11417. */
  11418. static readonly OnPointerOverTrigger: number;
  11419. /**
  11420. * On pointer out
  11421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11422. */
  11423. static readonly OnPointerOutTrigger: number;
  11424. /**
  11425. * On every frame
  11426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11427. */
  11428. static readonly OnEveryFrameTrigger: number;
  11429. /**
  11430. * On intersection enter
  11431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11432. */
  11433. static readonly OnIntersectionEnterTrigger: number;
  11434. /**
  11435. * On intersection exit
  11436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11437. */
  11438. static readonly OnIntersectionExitTrigger: number;
  11439. /**
  11440. * On key down
  11441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11442. */
  11443. static readonly OnKeyDownTrigger: number;
  11444. /**
  11445. * On key up
  11446. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11447. */
  11448. static readonly OnKeyUpTrigger: number;
  11449. private _scene;
  11450. /**
  11451. * Creates a new action manager
  11452. * @param scene defines the hosting scene
  11453. */
  11454. constructor(scene: Scene);
  11455. /**
  11456. * Releases all associated resources
  11457. */
  11458. dispose(): void;
  11459. /**
  11460. * Gets hosting scene
  11461. * @returns the hosting scene
  11462. */
  11463. getScene(): Scene;
  11464. /**
  11465. * Does this action manager handles actions of any of the given triggers
  11466. * @param triggers defines the triggers to be tested
  11467. * @return a boolean indicating whether one (or more) of the triggers is handled
  11468. */
  11469. hasSpecificTriggers(triggers: number[]): boolean;
  11470. /**
  11471. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11472. * speed.
  11473. * @param triggerA defines the trigger to be tested
  11474. * @param triggerB defines the trigger to be tested
  11475. * @return a boolean indicating whether one (or more) of the triggers is handled
  11476. */
  11477. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11478. /**
  11479. * Does this action manager handles actions of a given trigger
  11480. * @param trigger defines the trigger to be tested
  11481. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11482. * @return whether the trigger is handled
  11483. */
  11484. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11485. /**
  11486. * Does this action manager has pointer triggers
  11487. */
  11488. readonly hasPointerTriggers: boolean;
  11489. /**
  11490. * Does this action manager has pick triggers
  11491. */
  11492. readonly hasPickTriggers: boolean;
  11493. /**
  11494. * Registers an action to this action manager
  11495. * @param action defines the action to be registered
  11496. * @return the action amended (prepared) after registration
  11497. */
  11498. registerAction(action: IAction): Nullable<IAction>;
  11499. /**
  11500. * Unregisters an action to this action manager
  11501. * @param action defines the action to be unregistered
  11502. * @return a boolean indicating whether the action has been unregistered
  11503. */
  11504. unregisterAction(action: IAction): Boolean;
  11505. /**
  11506. * Process a specific trigger
  11507. * @param trigger defines the trigger to process
  11508. * @param evt defines the event details to be processed
  11509. */
  11510. processTrigger(trigger: number, evt?: IActionEvent): void;
  11511. /** @hidden */
  11512. _getEffectiveTarget(target: any, propertyPath: string): any;
  11513. /** @hidden */
  11514. _getProperty(propertyPath: string): string;
  11515. /**
  11516. * Serialize this manager to a JSON object
  11517. * @param name defines the property name to store this manager
  11518. * @returns a JSON representation of this manager
  11519. */
  11520. serialize(name: string): any;
  11521. /**
  11522. * Creates a new ActionManager from a JSON data
  11523. * @param parsedActions defines the JSON data to read from
  11524. * @param object defines the hosting mesh
  11525. * @param scene defines the hosting scene
  11526. */
  11527. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11528. /**
  11529. * Get a trigger name by index
  11530. * @param trigger defines the trigger index
  11531. * @returns a trigger name
  11532. */
  11533. static GetTriggerName(trigger: number): string;
  11534. }
  11535. }
  11536. declare module "babylonjs/Culling/ray" {
  11537. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11538. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11540. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11541. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11542. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11543. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11544. /**
  11545. * Class representing a ray with position and direction
  11546. */
  11547. export class Ray {
  11548. /** origin point */
  11549. origin: Vector3;
  11550. /** direction */
  11551. direction: Vector3;
  11552. /** length of the ray */
  11553. length: number;
  11554. private static readonly TmpVector3;
  11555. private _tmpRay;
  11556. /**
  11557. * Creates a new ray
  11558. * @param origin origin point
  11559. * @param direction direction
  11560. * @param length length of the ray
  11561. */
  11562. constructor(
  11563. /** origin point */
  11564. origin: Vector3,
  11565. /** direction */
  11566. direction: Vector3,
  11567. /** length of the ray */
  11568. length?: number);
  11569. /**
  11570. * Checks if the ray intersects a box
  11571. * @param minimum bound of the box
  11572. * @param maximum bound of the box
  11573. * @param intersectionTreshold extra extend to be added to the box in all direction
  11574. * @returns if the box was hit
  11575. */
  11576. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11577. /**
  11578. * Checks if the ray intersects a box
  11579. * @param box the bounding box to check
  11580. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11581. * @returns if the box was hit
  11582. */
  11583. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11584. /**
  11585. * If the ray hits a sphere
  11586. * @param sphere the bounding sphere to check
  11587. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11588. * @returns true if it hits the sphere
  11589. */
  11590. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11591. /**
  11592. * If the ray hits a triange
  11593. * @param vertex0 triangle vertex
  11594. * @param vertex1 triangle vertex
  11595. * @param vertex2 triangle vertex
  11596. * @returns intersection information if hit
  11597. */
  11598. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11599. /**
  11600. * Checks if ray intersects a plane
  11601. * @param plane the plane to check
  11602. * @returns the distance away it was hit
  11603. */
  11604. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11605. /**
  11606. * Checks if ray intersects a mesh
  11607. * @param mesh the mesh to check
  11608. * @param fastCheck if only the bounding box should checked
  11609. * @returns picking info of the intersecton
  11610. */
  11611. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11612. /**
  11613. * Checks if ray intersects a mesh
  11614. * @param meshes the meshes to check
  11615. * @param fastCheck if only the bounding box should checked
  11616. * @param results array to store result in
  11617. * @returns Array of picking infos
  11618. */
  11619. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11620. private _comparePickingInfo;
  11621. private static smallnum;
  11622. private static rayl;
  11623. /**
  11624. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11625. * @param sega the first point of the segment to test the intersection against
  11626. * @param segb the second point of the segment to test the intersection against
  11627. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11628. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11629. */
  11630. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11631. /**
  11632. * Update the ray from viewport position
  11633. * @param x position
  11634. * @param y y position
  11635. * @param viewportWidth viewport width
  11636. * @param viewportHeight viewport height
  11637. * @param world world matrix
  11638. * @param view view matrix
  11639. * @param projection projection matrix
  11640. * @returns this ray updated
  11641. */
  11642. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11643. /**
  11644. * Creates a ray with origin and direction of 0,0,0
  11645. * @returns the new ray
  11646. */
  11647. static Zero(): Ray;
  11648. /**
  11649. * Creates a new ray from screen space and viewport
  11650. * @param x position
  11651. * @param y y position
  11652. * @param viewportWidth viewport width
  11653. * @param viewportHeight viewport height
  11654. * @param world world matrix
  11655. * @param view view matrix
  11656. * @param projection projection matrix
  11657. * @returns new ray
  11658. */
  11659. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11660. /**
  11661. * 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
  11662. * transformed to the given world matrix.
  11663. * @param origin The origin point
  11664. * @param end The end point
  11665. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11666. * @returns the new ray
  11667. */
  11668. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11669. /**
  11670. * Transforms a ray by a matrix
  11671. * @param ray ray to transform
  11672. * @param matrix matrix to apply
  11673. * @returns the resulting new ray
  11674. */
  11675. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11676. /**
  11677. * Transforms a ray by a matrix
  11678. * @param ray ray to transform
  11679. * @param matrix matrix to apply
  11680. * @param result ray to store result in
  11681. */
  11682. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11683. /**
  11684. * Unproject a ray from screen space to object space
  11685. * @param sourceX defines the screen space x coordinate to use
  11686. * @param sourceY defines the screen space y coordinate to use
  11687. * @param viewportWidth defines the current width of the viewport
  11688. * @param viewportHeight defines the current height of the viewport
  11689. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11690. * @param view defines the view matrix to use
  11691. * @param projection defines the projection matrix to use
  11692. */
  11693. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11694. }
  11695. /**
  11696. * Type used to define predicate used to select faces when a mesh intersection is detected
  11697. */
  11698. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11699. module "babylonjs/scene" {
  11700. interface Scene {
  11701. /** @hidden */
  11702. _tempPickingRay: Nullable<Ray>;
  11703. /** @hidden */
  11704. _cachedRayForTransform: Ray;
  11705. /** @hidden */
  11706. _pickWithRayInverseMatrix: Matrix;
  11707. /** @hidden */
  11708. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11709. /** @hidden */
  11710. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11711. }
  11712. }
  11713. }
  11714. declare module "babylonjs/sceneComponent" {
  11715. import { Scene } from "babylonjs/scene";
  11716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11717. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11718. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11719. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11720. import { Nullable } from "babylonjs/types";
  11721. import { Camera } from "babylonjs/Cameras/camera";
  11722. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11723. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11724. import { AbstractScene } from "babylonjs/abstractScene";
  11725. /**
  11726. * Groups all the scene component constants in one place to ease maintenance.
  11727. * @hidden
  11728. */
  11729. export class SceneComponentConstants {
  11730. static readonly NAME_EFFECTLAYER: string;
  11731. static readonly NAME_LAYER: string;
  11732. static readonly NAME_LENSFLARESYSTEM: string;
  11733. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11734. static readonly NAME_PARTICLESYSTEM: string;
  11735. static readonly NAME_GAMEPAD: string;
  11736. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11737. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11738. static readonly NAME_DEPTHRENDERER: string;
  11739. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11740. static readonly NAME_SPRITE: string;
  11741. static readonly NAME_OUTLINERENDERER: string;
  11742. static readonly NAME_PROCEDURALTEXTURE: string;
  11743. static readonly NAME_SHADOWGENERATOR: string;
  11744. static readonly NAME_OCTREE: string;
  11745. static readonly NAME_PHYSICSENGINE: string;
  11746. static readonly NAME_AUDIO: string;
  11747. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11748. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11749. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11750. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11751. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11752. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11753. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11754. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11755. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11756. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11757. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11758. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11759. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11760. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11761. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11762. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11763. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11764. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11765. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11766. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11767. static readonly STEP_AFTERRENDER_AUDIO: number;
  11768. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11769. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11770. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11771. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11772. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11773. static readonly STEP_POINTERMOVE_SPRITE: number;
  11774. static readonly STEP_POINTERDOWN_SPRITE: number;
  11775. static readonly STEP_POINTERUP_SPRITE: number;
  11776. }
  11777. /**
  11778. * This represents a scene component.
  11779. *
  11780. * This is used to decouple the dependency the scene is having on the different workloads like
  11781. * layers, post processes...
  11782. */
  11783. export interface ISceneComponent {
  11784. /**
  11785. * The name of the component. Each component must have a unique name.
  11786. */
  11787. name: string;
  11788. /**
  11789. * The scene the component belongs to.
  11790. */
  11791. scene: Scene;
  11792. /**
  11793. * Register the component to one instance of a scene.
  11794. */
  11795. register(): void;
  11796. /**
  11797. * Rebuilds the elements related to this component in case of
  11798. * context lost for instance.
  11799. */
  11800. rebuild(): void;
  11801. /**
  11802. * Disposes the component and the associated ressources.
  11803. */
  11804. dispose(): void;
  11805. }
  11806. /**
  11807. * This represents a SERIALIZABLE scene component.
  11808. *
  11809. * This extends Scene Component to add Serialization methods on top.
  11810. */
  11811. export interface ISceneSerializableComponent extends ISceneComponent {
  11812. /**
  11813. * Adds all the element from the container to the scene
  11814. * @param container the container holding the elements
  11815. */
  11816. addFromContainer(container: AbstractScene): void;
  11817. /**
  11818. * Removes all the elements in the container from the scene
  11819. * @param container contains the elements to remove
  11820. * @param dispose if the removed element should be disposed (default: false)
  11821. */
  11822. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11823. /**
  11824. * Serializes the component data to the specified json object
  11825. * @param serializationObject The object to serialize to
  11826. */
  11827. serialize(serializationObject: any): void;
  11828. }
  11829. /**
  11830. * Strong typing of a Mesh related stage step action
  11831. */
  11832. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11833. /**
  11834. * Strong typing of a Evaluate Sub Mesh related stage step action
  11835. */
  11836. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11837. /**
  11838. * Strong typing of a Active Mesh related stage step action
  11839. */
  11840. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11841. /**
  11842. * Strong typing of a Camera related stage step action
  11843. */
  11844. export type CameraStageAction = (camera: Camera) => void;
  11845. /**
  11846. * Strong typing of a Camera Frame buffer related stage step action
  11847. */
  11848. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11849. /**
  11850. * Strong typing of a Render Target related stage step action
  11851. */
  11852. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11853. /**
  11854. * Strong typing of a RenderingGroup related stage step action
  11855. */
  11856. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11857. /**
  11858. * Strong typing of a Mesh Render related stage step action
  11859. */
  11860. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11861. /**
  11862. * Strong typing of a simple stage step action
  11863. */
  11864. export type SimpleStageAction = () => void;
  11865. /**
  11866. * Strong typing of a render target action.
  11867. */
  11868. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11869. /**
  11870. * Strong typing of a pointer move action.
  11871. */
  11872. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11873. /**
  11874. * Strong typing of a pointer up/down action.
  11875. */
  11876. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11877. /**
  11878. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11879. * @hidden
  11880. */
  11881. export class Stage<T extends Function> extends Array<{
  11882. index: number;
  11883. component: ISceneComponent;
  11884. action: T;
  11885. }> {
  11886. /**
  11887. * Hide ctor from the rest of the world.
  11888. * @param items The items to add.
  11889. */
  11890. private constructor();
  11891. /**
  11892. * Creates a new Stage.
  11893. * @returns A new instance of a Stage
  11894. */
  11895. static Create<T extends Function>(): Stage<T>;
  11896. /**
  11897. * Registers a step in an ordered way in the targeted stage.
  11898. * @param index Defines the position to register the step in
  11899. * @param component Defines the component attached to the step
  11900. * @param action Defines the action to launch during the step
  11901. */
  11902. registerStep(index: number, component: ISceneComponent, action: T): void;
  11903. /**
  11904. * Clears all the steps from the stage.
  11905. */
  11906. clear(): void;
  11907. }
  11908. }
  11909. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11910. import { Nullable } from "babylonjs/types";
  11911. import { Observable } from "babylonjs/Misc/observable";
  11912. import { Scene } from "babylonjs/scene";
  11913. import { Sprite } from "babylonjs/Sprites/sprite";
  11914. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11915. import { Ray } from "babylonjs/Culling/ray";
  11916. import { Camera } from "babylonjs/Cameras/camera";
  11917. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11918. import { ISceneComponent } from "babylonjs/sceneComponent";
  11919. module "babylonjs/scene" {
  11920. interface Scene {
  11921. /** @hidden */
  11922. _pointerOverSprite: Nullable<Sprite>;
  11923. /** @hidden */
  11924. _pickedDownSprite: Nullable<Sprite>;
  11925. /** @hidden */
  11926. _tempSpritePickingRay: Nullable<Ray>;
  11927. /**
  11928. * All of the sprite managers added to this scene
  11929. * @see http://doc.babylonjs.com/babylon101/sprites
  11930. */
  11931. spriteManagers: Array<ISpriteManager>;
  11932. /**
  11933. * An event triggered when sprites rendering is about to start
  11934. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11935. */
  11936. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11937. /**
  11938. * An event triggered when sprites rendering is done
  11939. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11940. */
  11941. onAfterSpritesRenderingObservable: Observable<Scene>;
  11942. /** @hidden */
  11943. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11944. /** Launch a ray to try to pick a sprite in the scene
  11945. * @param x position on screen
  11946. * @param y position on screen
  11947. * @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
  11948. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11949. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11950. * @returns a PickingInfo
  11951. */
  11952. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11953. /** Use the given ray to pick a sprite in the scene
  11954. * @param ray The ray (in world space) to use to pick meshes
  11955. * @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
  11956. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11957. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11958. * @returns a PickingInfo
  11959. */
  11960. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11961. /**
  11962. * Force the sprite under the pointer
  11963. * @param sprite defines the sprite to use
  11964. */
  11965. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11966. /**
  11967. * Gets the sprite under the pointer
  11968. * @returns a Sprite or null if no sprite is under the pointer
  11969. */
  11970. getPointerOverSprite(): Nullable<Sprite>;
  11971. }
  11972. }
  11973. /**
  11974. * Defines the sprite scene component responsible to manage sprites
  11975. * in a given scene.
  11976. */
  11977. export class SpriteSceneComponent implements ISceneComponent {
  11978. /**
  11979. * The component name helpfull to identify the component in the list of scene components.
  11980. */
  11981. readonly name: string;
  11982. /**
  11983. * The scene the component belongs to.
  11984. */
  11985. scene: Scene;
  11986. /** @hidden */
  11987. private _spritePredicate;
  11988. /**
  11989. * Creates a new instance of the component for the given scene
  11990. * @param scene Defines the scene to register the component in
  11991. */
  11992. constructor(scene: Scene);
  11993. /**
  11994. * Registers the component in a given scene
  11995. */
  11996. register(): void;
  11997. /**
  11998. * Rebuilds the elements related to this component in case of
  11999. * context lost for instance.
  12000. */
  12001. rebuild(): void;
  12002. /**
  12003. * Disposes the component and the associated ressources.
  12004. */
  12005. dispose(): void;
  12006. private _pickSpriteButKeepRay;
  12007. private _pointerMove;
  12008. private _pointerDown;
  12009. private _pointerUp;
  12010. }
  12011. }
  12012. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12013. /** @hidden */
  12014. export var fogFragmentDeclaration: {
  12015. name: string;
  12016. shader: string;
  12017. };
  12018. }
  12019. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12020. /** @hidden */
  12021. export var fogFragment: {
  12022. name: string;
  12023. shader: string;
  12024. };
  12025. }
  12026. declare module "babylonjs/Shaders/sprites.fragment" {
  12027. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12028. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12029. /** @hidden */
  12030. export var spritesPixelShader: {
  12031. name: string;
  12032. shader: string;
  12033. };
  12034. }
  12035. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12036. /** @hidden */
  12037. export var fogVertexDeclaration: {
  12038. name: string;
  12039. shader: string;
  12040. };
  12041. }
  12042. declare module "babylonjs/Shaders/sprites.vertex" {
  12043. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12044. /** @hidden */
  12045. export var spritesVertexShader: {
  12046. name: string;
  12047. shader: string;
  12048. };
  12049. }
  12050. declare module "babylonjs/Sprites/spriteManager" {
  12051. import { IDisposable, Scene } from "babylonjs/scene";
  12052. import { Nullable } from "babylonjs/types";
  12053. import { Observable } from "babylonjs/Misc/observable";
  12054. import { Sprite } from "babylonjs/Sprites/sprite";
  12055. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12056. import { Camera } from "babylonjs/Cameras/camera";
  12057. import { Texture } from "babylonjs/Materials/Textures/texture";
  12058. import "babylonjs/Shaders/sprites.fragment";
  12059. import "babylonjs/Shaders/sprites.vertex";
  12060. import { Ray } from "babylonjs/Culling/ray";
  12061. /**
  12062. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12063. */
  12064. export interface ISpriteManager extends IDisposable {
  12065. /**
  12066. * Restricts the camera to viewing objects with the same layerMask.
  12067. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12068. */
  12069. layerMask: number;
  12070. /**
  12071. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12072. */
  12073. isPickable: boolean;
  12074. /**
  12075. * Specifies the rendering group id for this mesh (0 by default)
  12076. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12077. */
  12078. renderingGroupId: number;
  12079. /**
  12080. * Defines the list of sprites managed by the manager.
  12081. */
  12082. sprites: Array<Sprite>;
  12083. /**
  12084. * Tests the intersection of a sprite with a specific ray.
  12085. * @param ray The ray we are sending to test the collision
  12086. * @param camera The camera space we are sending rays in
  12087. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12088. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12089. * @returns picking info or null.
  12090. */
  12091. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12092. /**
  12093. * Renders the list of sprites on screen.
  12094. */
  12095. render(): void;
  12096. }
  12097. /**
  12098. * Class used to manage multiple sprites on the same spritesheet
  12099. * @see http://doc.babylonjs.com/babylon101/sprites
  12100. */
  12101. export class SpriteManager implements ISpriteManager {
  12102. /** defines the manager's name */
  12103. name: string;
  12104. /** Gets the list of sprites */
  12105. sprites: Sprite[];
  12106. /** Gets or sets the rendering group id (0 by default) */
  12107. renderingGroupId: number;
  12108. /** Gets or sets camera layer mask */
  12109. layerMask: number;
  12110. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12111. fogEnabled: boolean;
  12112. /** Gets or sets a boolean indicating if the sprites are pickable */
  12113. isPickable: boolean;
  12114. /** Defines the default width of a cell in the spritesheet */
  12115. cellWidth: number;
  12116. /** Defines the default height of a cell in the spritesheet */
  12117. cellHeight: number;
  12118. /**
  12119. * An event triggered when the manager is disposed.
  12120. */
  12121. onDisposeObservable: Observable<SpriteManager>;
  12122. private _onDisposeObserver;
  12123. /**
  12124. * Callback called when the manager is disposed
  12125. */
  12126. onDispose: () => void;
  12127. private _capacity;
  12128. private _spriteTexture;
  12129. private _epsilon;
  12130. private _scene;
  12131. private _vertexData;
  12132. private _buffer;
  12133. private _vertexBuffers;
  12134. private _indexBuffer;
  12135. private _effectBase;
  12136. private _effectFog;
  12137. /**
  12138. * Gets or sets the spritesheet texture
  12139. */
  12140. texture: Texture;
  12141. /**
  12142. * Creates a new sprite manager
  12143. * @param name defines the manager's name
  12144. * @param imgUrl defines the sprite sheet url
  12145. * @param capacity defines the maximum allowed number of sprites
  12146. * @param cellSize defines the size of a sprite cell
  12147. * @param scene defines the hosting scene
  12148. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12149. * @param samplingMode defines the smapling mode to use with spritesheet
  12150. */
  12151. constructor(
  12152. /** defines the manager's name */
  12153. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12154. private _appendSpriteVertex;
  12155. /**
  12156. * Intersects the sprites with a ray
  12157. * @param ray defines the ray to intersect with
  12158. * @param camera defines the current active camera
  12159. * @param predicate defines a predicate used to select candidate sprites
  12160. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12161. * @returns null if no hit or a PickingInfo
  12162. */
  12163. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12164. /**
  12165. * Render all child sprites
  12166. */
  12167. render(): void;
  12168. /**
  12169. * Release associated resources
  12170. */
  12171. dispose(): void;
  12172. }
  12173. }
  12174. declare module "babylonjs/Sprites/sprite" {
  12175. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12176. import { Nullable } from "babylonjs/types";
  12177. import { ActionManager } from "babylonjs/Actions/actionManager";
  12178. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12179. /**
  12180. * Class used to represent a sprite
  12181. * @see http://doc.babylonjs.com/babylon101/sprites
  12182. */
  12183. export class Sprite {
  12184. /** defines the name */
  12185. name: string;
  12186. /** Gets or sets the current world position */
  12187. position: Vector3;
  12188. /** Gets or sets the main color */
  12189. color: Color4;
  12190. /** Gets or sets the width */
  12191. width: number;
  12192. /** Gets or sets the height */
  12193. height: number;
  12194. /** Gets or sets rotation angle */
  12195. angle: number;
  12196. /** Gets or sets the cell index in the sprite sheet */
  12197. cellIndex: number;
  12198. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12199. invertU: number;
  12200. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12201. invertV: number;
  12202. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12203. disposeWhenFinishedAnimating: boolean;
  12204. /** Gets the list of attached animations */
  12205. animations: Animation[];
  12206. /** Gets or sets a boolean indicating if the sprite can be picked */
  12207. isPickable: boolean;
  12208. /**
  12209. * Gets or sets the associated action manager
  12210. */
  12211. actionManager: Nullable<ActionManager>;
  12212. private _animationStarted;
  12213. private _loopAnimation;
  12214. private _fromIndex;
  12215. private _toIndex;
  12216. private _delay;
  12217. private _direction;
  12218. private _manager;
  12219. private _time;
  12220. private _onAnimationEnd;
  12221. /**
  12222. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12223. */
  12224. isVisible: boolean;
  12225. /**
  12226. * Gets or sets the sprite size
  12227. */
  12228. size: number;
  12229. /**
  12230. * Creates a new Sprite
  12231. * @param name defines the name
  12232. * @param manager defines the manager
  12233. */
  12234. constructor(
  12235. /** defines the name */
  12236. name: string, manager: ISpriteManager);
  12237. /**
  12238. * Starts an animation
  12239. * @param from defines the initial key
  12240. * @param to defines the end key
  12241. * @param loop defines if the animation must loop
  12242. * @param delay defines the start delay (in ms)
  12243. * @param onAnimationEnd defines a callback to call when animation ends
  12244. */
  12245. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12246. /** Stops current animation (if any) */
  12247. stopAnimation(): void;
  12248. /** @hidden */
  12249. _animate(deltaTime: number): void;
  12250. /** Release associated resources */
  12251. dispose(): void;
  12252. }
  12253. }
  12254. declare module "babylonjs/Collisions/pickingInfo" {
  12255. import { Nullable } from "babylonjs/types";
  12256. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12258. import { Sprite } from "babylonjs/Sprites/sprite";
  12259. import { Ray } from "babylonjs/Culling/ray";
  12260. /**
  12261. * Information about the result of picking within a scene
  12262. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12263. */
  12264. export class PickingInfo {
  12265. /** @hidden */
  12266. _pickingUnavailable: boolean;
  12267. /**
  12268. * If the pick collided with an object
  12269. */
  12270. hit: boolean;
  12271. /**
  12272. * Distance away where the pick collided
  12273. */
  12274. distance: number;
  12275. /**
  12276. * The location of pick collision
  12277. */
  12278. pickedPoint: Nullable<Vector3>;
  12279. /**
  12280. * The mesh corresponding the the pick collision
  12281. */
  12282. pickedMesh: Nullable<AbstractMesh>;
  12283. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12284. bu: number;
  12285. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12286. bv: number;
  12287. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12288. faceId: number;
  12289. /** Id of the the submesh that was picked */
  12290. subMeshId: number;
  12291. /** If a sprite was picked, this will be the sprite the pick collided with */
  12292. pickedSprite: Nullable<Sprite>;
  12293. /**
  12294. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12295. */
  12296. originMesh: Nullable<AbstractMesh>;
  12297. /**
  12298. * The ray that was used to perform the picking.
  12299. */
  12300. ray: Nullable<Ray>;
  12301. /**
  12302. * Gets the normal correspodning to the face the pick collided with
  12303. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12304. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12305. * @returns The normal correspodning to the face the pick collided with
  12306. */
  12307. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12308. /**
  12309. * Gets the texture coordinates of where the pick occured
  12310. * @returns the vector containing the coordnates of the texture
  12311. */
  12312. getTextureCoordinates(): Nullable<Vector2>;
  12313. }
  12314. }
  12315. declare module "babylonjs/Events/pointerEvents" {
  12316. import { Nullable } from "babylonjs/types";
  12317. import { Vector2 } from "babylonjs/Maths/math";
  12318. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12319. import { Ray } from "babylonjs/Culling/ray";
  12320. /**
  12321. * Gather the list of pointer event types as constants.
  12322. */
  12323. export class PointerEventTypes {
  12324. /**
  12325. * 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.
  12326. */
  12327. static readonly POINTERDOWN: number;
  12328. /**
  12329. * The pointerup event is fired when a pointer is no longer active.
  12330. */
  12331. static readonly POINTERUP: number;
  12332. /**
  12333. * The pointermove event is fired when a pointer changes coordinates.
  12334. */
  12335. static readonly POINTERMOVE: number;
  12336. /**
  12337. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12338. */
  12339. static readonly POINTERWHEEL: number;
  12340. /**
  12341. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12342. */
  12343. static readonly POINTERPICK: number;
  12344. /**
  12345. * The pointertap event is fired when a the object has been touched and released without drag.
  12346. */
  12347. static readonly POINTERTAP: number;
  12348. /**
  12349. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12350. */
  12351. static readonly POINTERDOUBLETAP: number;
  12352. }
  12353. /**
  12354. * Base class of pointer info types.
  12355. */
  12356. export class PointerInfoBase {
  12357. /**
  12358. * Defines the type of event (PointerEventTypes)
  12359. */
  12360. type: number;
  12361. /**
  12362. * Defines the related dom event
  12363. */
  12364. event: PointerEvent | MouseWheelEvent;
  12365. /**
  12366. * Instantiates the base class of pointers info.
  12367. * @param type Defines the type of event (PointerEventTypes)
  12368. * @param event Defines the related dom event
  12369. */
  12370. constructor(
  12371. /**
  12372. * Defines the type of event (PointerEventTypes)
  12373. */
  12374. type: number,
  12375. /**
  12376. * Defines the related dom event
  12377. */
  12378. event: PointerEvent | MouseWheelEvent);
  12379. }
  12380. /**
  12381. * This class is used to store pointer related info for the onPrePointerObservable event.
  12382. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12383. */
  12384. export class PointerInfoPre extends PointerInfoBase {
  12385. /**
  12386. * Ray from a pointer if availible (eg. 6dof controller)
  12387. */
  12388. ray: Nullable<Ray>;
  12389. /**
  12390. * Defines the local position of the pointer on the canvas.
  12391. */
  12392. localPosition: Vector2;
  12393. /**
  12394. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12395. */
  12396. skipOnPointerObservable: boolean;
  12397. /**
  12398. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12399. * @param type Defines the type of event (PointerEventTypes)
  12400. * @param event Defines the related dom event
  12401. * @param localX Defines the local x coordinates of the pointer when the event occured
  12402. * @param localY Defines the local y coordinates of the pointer when the event occured
  12403. */
  12404. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12405. }
  12406. /**
  12407. * This type contains all the data related to a pointer event in Babylon.js.
  12408. * 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.
  12409. */
  12410. export class PointerInfo extends PointerInfoBase {
  12411. /**
  12412. * Defines the picking info associated to the info (if any)\
  12413. */
  12414. pickInfo: Nullable<PickingInfo>;
  12415. /**
  12416. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12417. * @param type Defines the type of event (PointerEventTypes)
  12418. * @param event Defines the related dom event
  12419. * @param pickInfo Defines the picking info associated to the info (if any)\
  12420. */
  12421. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12422. /**
  12423. * Defines the picking info associated to the info (if any)\
  12424. */
  12425. pickInfo: Nullable<PickingInfo>);
  12426. }
  12427. /**
  12428. * Data relating to a touch event on the screen.
  12429. */
  12430. export interface PointerTouch {
  12431. /**
  12432. * X coordinate of touch.
  12433. */
  12434. x: number;
  12435. /**
  12436. * Y coordinate of touch.
  12437. */
  12438. y: number;
  12439. /**
  12440. * Id of touch. Unique for each finger.
  12441. */
  12442. pointerId: number;
  12443. /**
  12444. * Event type passed from DOM.
  12445. */
  12446. type: any;
  12447. }
  12448. }
  12449. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12450. import { Observable } from "babylonjs/Misc/observable";
  12451. import { Nullable } from "babylonjs/types";
  12452. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12453. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12454. /**
  12455. * Manage the mouse inputs to control the movement of a free camera.
  12456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12457. */
  12458. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12459. /**
  12460. * Define if touch is enabled in the mouse input
  12461. */
  12462. touchEnabled: boolean;
  12463. /**
  12464. * Defines the camera the input is attached to.
  12465. */
  12466. camera: FreeCamera;
  12467. /**
  12468. * Defines the buttons associated with the input to handle camera move.
  12469. */
  12470. buttons: number[];
  12471. /**
  12472. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12473. */
  12474. angularSensibility: number;
  12475. private _pointerInput;
  12476. private _onMouseMove;
  12477. private _observer;
  12478. private previousPosition;
  12479. /**
  12480. * Observable for when a pointer move event occurs containing the move offset
  12481. */
  12482. onPointerMovedObservable: Observable<{
  12483. offsetX: number;
  12484. offsetY: number;
  12485. }>;
  12486. /**
  12487. * @hidden
  12488. * If the camera should be rotated automatically based on pointer movement
  12489. */
  12490. _allowCameraRotation: boolean;
  12491. /**
  12492. * Manage the mouse inputs to control the movement of a free camera.
  12493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12494. * @param touchEnabled Defines if touch is enabled or not
  12495. */
  12496. constructor(
  12497. /**
  12498. * Define if touch is enabled in the mouse input
  12499. */
  12500. touchEnabled?: boolean);
  12501. /**
  12502. * Attach the input controls to a specific dom element to get the input from.
  12503. * @param element Defines the element the controls should be listened from
  12504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12505. */
  12506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12507. /**
  12508. * Called on JS contextmenu event.
  12509. * Override this method to provide functionality.
  12510. */
  12511. protected onContextMenu(evt: PointerEvent): void;
  12512. /**
  12513. * Detach the current controls from the specified dom element.
  12514. * @param element Defines the element to stop listening the inputs from
  12515. */
  12516. detachControl(element: Nullable<HTMLElement>): void;
  12517. /**
  12518. * Gets the class name of the current intput.
  12519. * @returns the class name
  12520. */
  12521. getClassName(): string;
  12522. /**
  12523. * Get the friendly name associated with the input class.
  12524. * @returns the input friendly name
  12525. */
  12526. getSimpleName(): string;
  12527. }
  12528. }
  12529. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12530. import { Nullable } from "babylonjs/types";
  12531. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12532. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12533. /**
  12534. * Manage the touch inputs to control the movement of a free camera.
  12535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12536. */
  12537. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12538. /**
  12539. * Defines the camera the input is attached to.
  12540. */
  12541. camera: FreeCamera;
  12542. /**
  12543. * Defines the touch sensibility for rotation.
  12544. * The higher the faster.
  12545. */
  12546. touchAngularSensibility: number;
  12547. /**
  12548. * Defines the touch sensibility for move.
  12549. * The higher the faster.
  12550. */
  12551. touchMoveSensibility: number;
  12552. private _offsetX;
  12553. private _offsetY;
  12554. private _pointerPressed;
  12555. private _pointerInput;
  12556. private _observer;
  12557. private _onLostFocus;
  12558. /**
  12559. * Attach the input controls to a specific dom element to get the input from.
  12560. * @param element Defines the element the controls should be listened from
  12561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12562. */
  12563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12564. /**
  12565. * Detach the current controls from the specified dom element.
  12566. * @param element Defines the element to stop listening the inputs from
  12567. */
  12568. detachControl(element: Nullable<HTMLElement>): void;
  12569. /**
  12570. * Update the current camera state depending on the inputs that have been used this frame.
  12571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12572. */
  12573. checkInputs(): void;
  12574. /**
  12575. * Gets the class name of the current intput.
  12576. * @returns the class name
  12577. */
  12578. getClassName(): string;
  12579. /**
  12580. * Get the friendly name associated with the input class.
  12581. * @returns the input friendly name
  12582. */
  12583. getSimpleName(): string;
  12584. }
  12585. }
  12586. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12587. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12588. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12589. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12590. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12591. import { Nullable } from "babylonjs/types";
  12592. /**
  12593. * Default Inputs manager for the FreeCamera.
  12594. * It groups all the default supported inputs for ease of use.
  12595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12596. */
  12597. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12598. /**
  12599. * @hidden
  12600. */
  12601. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12602. /**
  12603. * @hidden
  12604. */
  12605. _mouseInput: Nullable<FreeCameraMouseInput>;
  12606. /**
  12607. * Instantiates a new FreeCameraInputsManager.
  12608. * @param camera Defines the camera the inputs belong to
  12609. */
  12610. constructor(camera: FreeCamera);
  12611. /**
  12612. * Add keyboard input support to the input manager.
  12613. * @returns the current input manager
  12614. */
  12615. addKeyboard(): FreeCameraInputsManager;
  12616. /**
  12617. * Add mouse input support to the input manager.
  12618. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12619. * @returns the current input manager
  12620. */
  12621. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12622. /**
  12623. * Removes the mouse input support from the manager
  12624. * @returns the current input manager
  12625. */
  12626. removeMouse(): FreeCameraInputsManager;
  12627. /**
  12628. * Add touch input support to the input manager.
  12629. * @returns the current input manager
  12630. */
  12631. addTouch(): FreeCameraInputsManager;
  12632. }
  12633. }
  12634. declare module "babylonjs/Cameras/freeCamera" {
  12635. import { Vector3 } from "babylonjs/Maths/math";
  12636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12637. import { Scene } from "babylonjs/scene";
  12638. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12639. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12640. /**
  12641. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12642. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12643. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12644. */
  12645. export class FreeCamera extends TargetCamera {
  12646. /**
  12647. * Define the collision ellipsoid of the camera.
  12648. * This is helpful to simulate a camera body like the player body around the camera
  12649. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12650. */
  12651. ellipsoid: Vector3;
  12652. /**
  12653. * Define an offset for the position of the ellipsoid around the camera.
  12654. * This can be helpful to determine the center of the body near the gravity center of the body
  12655. * instead of its head.
  12656. */
  12657. ellipsoidOffset: Vector3;
  12658. /**
  12659. * Enable or disable collisions of the camera with the rest of the scene objects.
  12660. */
  12661. checkCollisions: boolean;
  12662. /**
  12663. * Enable or disable gravity on the camera.
  12664. */
  12665. applyGravity: boolean;
  12666. /**
  12667. * Define the input manager associated to the camera.
  12668. */
  12669. inputs: FreeCameraInputsManager;
  12670. /**
  12671. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12672. * Higher values reduce sensitivity.
  12673. */
  12674. /**
  12675. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12676. * Higher values reduce sensitivity.
  12677. */
  12678. angularSensibility: number;
  12679. /**
  12680. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12681. */
  12682. keysUp: number[];
  12683. /**
  12684. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12685. */
  12686. keysDown: number[];
  12687. /**
  12688. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12689. */
  12690. keysLeft: number[];
  12691. /**
  12692. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12693. */
  12694. keysRight: number[];
  12695. /**
  12696. * Event raised when the camera collide with a mesh in the scene.
  12697. */
  12698. onCollide: (collidedMesh: AbstractMesh) => void;
  12699. private _collider;
  12700. private _needMoveForGravity;
  12701. private _oldPosition;
  12702. private _diffPosition;
  12703. private _newPosition;
  12704. /** @hidden */
  12705. _localDirection: Vector3;
  12706. /** @hidden */
  12707. _transformedDirection: Vector3;
  12708. /**
  12709. * Instantiates a Free Camera.
  12710. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12711. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12712. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12713. * @param name Define the name of the camera in the scene
  12714. * @param position Define the start position of the camera in the scene
  12715. * @param scene Define the scene the camera belongs to
  12716. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12717. */
  12718. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12719. /**
  12720. * Attached controls to the current camera.
  12721. * @param element Defines the element the controls should be listened from
  12722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12723. */
  12724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12725. /**
  12726. * Detach the current controls from the camera.
  12727. * The camera will stop reacting to inputs.
  12728. * @param element Defines the element to stop listening the inputs from
  12729. */
  12730. detachControl(element: HTMLElement): void;
  12731. private _collisionMask;
  12732. /**
  12733. * Define a collision mask to limit the list of object the camera can collide with
  12734. */
  12735. collisionMask: number;
  12736. /** @hidden */
  12737. _collideWithWorld(displacement: Vector3): void;
  12738. private _onCollisionPositionChange;
  12739. /** @hidden */
  12740. _checkInputs(): void;
  12741. /** @hidden */
  12742. _decideIfNeedsToMove(): boolean;
  12743. /** @hidden */
  12744. _updatePosition(): void;
  12745. /**
  12746. * Destroy the camera and release the current resources hold by it.
  12747. */
  12748. dispose(): void;
  12749. /**
  12750. * Gets the current object class name.
  12751. * @return the class name
  12752. */
  12753. getClassName(): string;
  12754. }
  12755. }
  12756. declare module "babylonjs/Gamepads/gamepad" {
  12757. import { Observable } from "babylonjs/Misc/observable";
  12758. /**
  12759. * Represents a gamepad control stick position
  12760. */
  12761. export class StickValues {
  12762. /**
  12763. * The x component of the control stick
  12764. */
  12765. x: number;
  12766. /**
  12767. * The y component of the control stick
  12768. */
  12769. y: number;
  12770. /**
  12771. * Initializes the gamepad x and y control stick values
  12772. * @param x The x component of the gamepad control stick value
  12773. * @param y The y component of the gamepad control stick value
  12774. */
  12775. constructor(
  12776. /**
  12777. * The x component of the control stick
  12778. */
  12779. x: number,
  12780. /**
  12781. * The y component of the control stick
  12782. */
  12783. y: number);
  12784. }
  12785. /**
  12786. * An interface which manages callbacks for gamepad button changes
  12787. */
  12788. export interface GamepadButtonChanges {
  12789. /**
  12790. * Called when a gamepad has been changed
  12791. */
  12792. changed: boolean;
  12793. /**
  12794. * Called when a gamepad press event has been triggered
  12795. */
  12796. pressChanged: boolean;
  12797. /**
  12798. * Called when a touch event has been triggered
  12799. */
  12800. touchChanged: boolean;
  12801. /**
  12802. * Called when a value has changed
  12803. */
  12804. valueChanged: boolean;
  12805. }
  12806. /**
  12807. * Represents a gamepad
  12808. */
  12809. export class Gamepad {
  12810. /**
  12811. * The id of the gamepad
  12812. */
  12813. id: string;
  12814. /**
  12815. * The index of the gamepad
  12816. */
  12817. index: number;
  12818. /**
  12819. * The browser gamepad
  12820. */
  12821. browserGamepad: any;
  12822. /**
  12823. * Specifies what type of gamepad this represents
  12824. */
  12825. type: number;
  12826. private _leftStick;
  12827. private _rightStick;
  12828. /** @hidden */
  12829. _isConnected: boolean;
  12830. private _leftStickAxisX;
  12831. private _leftStickAxisY;
  12832. private _rightStickAxisX;
  12833. private _rightStickAxisY;
  12834. /**
  12835. * Triggered when the left control stick has been changed
  12836. */
  12837. private _onleftstickchanged;
  12838. /**
  12839. * Triggered when the right control stick has been changed
  12840. */
  12841. private _onrightstickchanged;
  12842. /**
  12843. * Represents a gamepad controller
  12844. */
  12845. static GAMEPAD: number;
  12846. /**
  12847. * Represents a generic controller
  12848. */
  12849. static GENERIC: number;
  12850. /**
  12851. * Represents an XBox controller
  12852. */
  12853. static XBOX: number;
  12854. /**
  12855. * Represents a pose-enabled controller
  12856. */
  12857. static POSE_ENABLED: number;
  12858. /**
  12859. * Specifies whether the left control stick should be Y-inverted
  12860. */
  12861. protected _invertLeftStickY: boolean;
  12862. /**
  12863. * Specifies if the gamepad has been connected
  12864. */
  12865. readonly isConnected: boolean;
  12866. /**
  12867. * Initializes the gamepad
  12868. * @param id The id of the gamepad
  12869. * @param index The index of the gamepad
  12870. * @param browserGamepad The browser gamepad
  12871. * @param leftStickX The x component of the left joystick
  12872. * @param leftStickY The y component of the left joystick
  12873. * @param rightStickX The x component of the right joystick
  12874. * @param rightStickY The y component of the right joystick
  12875. */
  12876. constructor(
  12877. /**
  12878. * The id of the gamepad
  12879. */
  12880. id: string,
  12881. /**
  12882. * The index of the gamepad
  12883. */
  12884. index: number,
  12885. /**
  12886. * The browser gamepad
  12887. */
  12888. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12889. /**
  12890. * Callback triggered when the left joystick has changed
  12891. * @param callback
  12892. */
  12893. onleftstickchanged(callback: (values: StickValues) => void): void;
  12894. /**
  12895. * Callback triggered when the right joystick has changed
  12896. * @param callback
  12897. */
  12898. onrightstickchanged(callback: (values: StickValues) => void): void;
  12899. /**
  12900. * Gets the left joystick
  12901. */
  12902. /**
  12903. * Sets the left joystick values
  12904. */
  12905. leftStick: StickValues;
  12906. /**
  12907. * Gets the right joystick
  12908. */
  12909. /**
  12910. * Sets the right joystick value
  12911. */
  12912. rightStick: StickValues;
  12913. /**
  12914. * Updates the gamepad joystick positions
  12915. */
  12916. update(): void;
  12917. /**
  12918. * Disposes the gamepad
  12919. */
  12920. dispose(): void;
  12921. }
  12922. /**
  12923. * Represents a generic gamepad
  12924. */
  12925. export class GenericPad extends Gamepad {
  12926. private _buttons;
  12927. private _onbuttondown;
  12928. private _onbuttonup;
  12929. /**
  12930. * Observable triggered when a button has been pressed
  12931. */
  12932. onButtonDownObservable: Observable<number>;
  12933. /**
  12934. * Observable triggered when a button has been released
  12935. */
  12936. onButtonUpObservable: Observable<number>;
  12937. /**
  12938. * Callback triggered when a button has been pressed
  12939. * @param callback Called when a button has been pressed
  12940. */
  12941. onbuttondown(callback: (buttonPressed: number) => void): void;
  12942. /**
  12943. * Callback triggered when a button has been released
  12944. * @param callback Called when a button has been released
  12945. */
  12946. onbuttonup(callback: (buttonReleased: number) => void): void;
  12947. /**
  12948. * Initializes the generic gamepad
  12949. * @param id The id of the generic gamepad
  12950. * @param index The index of the generic gamepad
  12951. * @param browserGamepad The browser gamepad
  12952. */
  12953. constructor(id: string, index: number, browserGamepad: any);
  12954. private _setButtonValue;
  12955. /**
  12956. * Updates the generic gamepad
  12957. */
  12958. update(): void;
  12959. /**
  12960. * Disposes the generic gamepad
  12961. */
  12962. dispose(): void;
  12963. }
  12964. }
  12965. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12966. import { Observable } from "babylonjs/Misc/observable";
  12967. import { Nullable } from "babylonjs/types";
  12968. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12971. import { Ray } from "babylonjs/Culling/ray";
  12972. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12973. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12974. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12975. /**
  12976. * Defines the types of pose enabled controllers that are supported
  12977. */
  12978. export enum PoseEnabledControllerType {
  12979. /**
  12980. * HTC Vive
  12981. */
  12982. VIVE = 0,
  12983. /**
  12984. * Oculus Rift
  12985. */
  12986. OCULUS = 1,
  12987. /**
  12988. * Windows mixed reality
  12989. */
  12990. WINDOWS = 2,
  12991. /**
  12992. * Samsung gear VR
  12993. */
  12994. GEAR_VR = 3,
  12995. /**
  12996. * Google Daydream
  12997. */
  12998. DAYDREAM = 4,
  12999. /**
  13000. * Generic
  13001. */
  13002. GENERIC = 5
  13003. }
  13004. /**
  13005. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13006. */
  13007. export interface MutableGamepadButton {
  13008. /**
  13009. * Value of the button/trigger
  13010. */
  13011. value: number;
  13012. /**
  13013. * If the button/trigger is currently touched
  13014. */
  13015. touched: boolean;
  13016. /**
  13017. * If the button/trigger is currently pressed
  13018. */
  13019. pressed: boolean;
  13020. }
  13021. /**
  13022. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13023. * @hidden
  13024. */
  13025. export interface ExtendedGamepadButton extends GamepadButton {
  13026. /**
  13027. * If the button/trigger is currently pressed
  13028. */
  13029. readonly pressed: boolean;
  13030. /**
  13031. * If the button/trigger is currently touched
  13032. */
  13033. readonly touched: boolean;
  13034. /**
  13035. * Value of the button/trigger
  13036. */
  13037. readonly value: number;
  13038. }
  13039. /** @hidden */
  13040. export interface _GamePadFactory {
  13041. /**
  13042. * Returns wether or not the current gamepad can be created for this type of controller.
  13043. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13044. * @returns true if it can be created, otherwise false
  13045. */
  13046. canCreate(gamepadInfo: any): boolean;
  13047. /**
  13048. * Creates a new instance of the Gamepad.
  13049. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13050. * @returns the new gamepad instance
  13051. */
  13052. create(gamepadInfo: any): Gamepad;
  13053. }
  13054. /**
  13055. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13056. */
  13057. export class PoseEnabledControllerHelper {
  13058. /** @hidden */
  13059. static _ControllerFactories: _GamePadFactory[];
  13060. /** @hidden */
  13061. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13062. /**
  13063. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13064. * @param vrGamepad the gamepad to initialized
  13065. * @returns a vr controller of the type the gamepad identified as
  13066. */
  13067. static InitiateController(vrGamepad: any): Gamepad;
  13068. }
  13069. /**
  13070. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13071. */
  13072. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13073. private _deviceRoomPosition;
  13074. private _deviceRoomRotationQuaternion;
  13075. /**
  13076. * The device position in babylon space
  13077. */
  13078. devicePosition: Vector3;
  13079. /**
  13080. * The device rotation in babylon space
  13081. */
  13082. deviceRotationQuaternion: Quaternion;
  13083. /**
  13084. * The scale factor of the device in babylon space
  13085. */
  13086. deviceScaleFactor: number;
  13087. /**
  13088. * (Likely devicePosition should be used instead) The device position in its room space
  13089. */
  13090. position: Vector3;
  13091. /**
  13092. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13093. */
  13094. rotationQuaternion: Quaternion;
  13095. /**
  13096. * The type of controller (Eg. Windows mixed reality)
  13097. */
  13098. controllerType: PoseEnabledControllerType;
  13099. protected _calculatedPosition: Vector3;
  13100. private _calculatedRotation;
  13101. /**
  13102. * The raw pose from the device
  13103. */
  13104. rawPose: DevicePose;
  13105. private _trackPosition;
  13106. private _maxRotationDistFromHeadset;
  13107. private _draggedRoomRotation;
  13108. /**
  13109. * @hidden
  13110. */
  13111. _disableTrackPosition(fixedPosition: Vector3): void;
  13112. /**
  13113. * Internal, the mesh attached to the controller
  13114. * @hidden
  13115. */
  13116. _mesh: Nullable<AbstractMesh>;
  13117. private _poseControlledCamera;
  13118. private _leftHandSystemQuaternion;
  13119. /**
  13120. * Internal, matrix used to convert room space to babylon space
  13121. * @hidden
  13122. */
  13123. _deviceToWorld: Matrix;
  13124. /**
  13125. * Node to be used when casting a ray from the controller
  13126. * @hidden
  13127. */
  13128. _pointingPoseNode: Nullable<TransformNode>;
  13129. /**
  13130. * Name of the child mesh that can be used to cast a ray from the controller
  13131. */
  13132. static readonly POINTING_POSE: string;
  13133. /**
  13134. * Creates a new PoseEnabledController from a gamepad
  13135. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13136. */
  13137. constructor(browserGamepad: any);
  13138. private _workingMatrix;
  13139. /**
  13140. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13141. */
  13142. update(): void;
  13143. /**
  13144. * Updates only the pose device and mesh without doing any button event checking
  13145. */
  13146. protected _updatePoseAndMesh(): void;
  13147. /**
  13148. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13149. * @param poseData raw pose fromthe device
  13150. */
  13151. updateFromDevice(poseData: DevicePose): void;
  13152. /**
  13153. * @hidden
  13154. */
  13155. _meshAttachedObservable: Observable<AbstractMesh>;
  13156. /**
  13157. * Attaches a mesh to the controller
  13158. * @param mesh the mesh to be attached
  13159. */
  13160. attachToMesh(mesh: AbstractMesh): void;
  13161. /**
  13162. * Attaches the controllers mesh to a camera
  13163. * @param camera the camera the mesh should be attached to
  13164. */
  13165. attachToPoseControlledCamera(camera: TargetCamera): void;
  13166. /**
  13167. * Disposes of the controller
  13168. */
  13169. dispose(): void;
  13170. /**
  13171. * The mesh that is attached to the controller
  13172. */
  13173. readonly mesh: Nullable<AbstractMesh>;
  13174. /**
  13175. * Gets the ray of the controller in the direction the controller is pointing
  13176. * @param length the length the resulting ray should be
  13177. * @returns a ray in the direction the controller is pointing
  13178. */
  13179. getForwardRay(length?: number): Ray;
  13180. }
  13181. }
  13182. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13183. import { Observable } from "babylonjs/Misc/observable";
  13184. import { Scene } from "babylonjs/scene";
  13185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13186. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13187. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13188. /**
  13189. * Defines the WebVRController object that represents controllers tracked in 3D space
  13190. */
  13191. export abstract class WebVRController extends PoseEnabledController {
  13192. /**
  13193. * Internal, the default controller model for the controller
  13194. */
  13195. protected _defaultModel: AbstractMesh;
  13196. /**
  13197. * Fired when the trigger state has changed
  13198. */
  13199. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13200. /**
  13201. * Fired when the main button state has changed
  13202. */
  13203. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13204. /**
  13205. * Fired when the secondary button state has changed
  13206. */
  13207. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13208. /**
  13209. * Fired when the pad state has changed
  13210. */
  13211. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13212. /**
  13213. * Fired when controllers stick values have changed
  13214. */
  13215. onPadValuesChangedObservable: Observable<StickValues>;
  13216. /**
  13217. * Array of button availible on the controller
  13218. */
  13219. protected _buttons: Array<MutableGamepadButton>;
  13220. private _onButtonStateChange;
  13221. /**
  13222. * Fired when a controller button's state has changed
  13223. * @param callback the callback containing the button that was modified
  13224. */
  13225. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13226. /**
  13227. * X and Y axis corrisponding to the controllers joystick
  13228. */
  13229. pad: StickValues;
  13230. /**
  13231. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13232. */
  13233. hand: string;
  13234. /**
  13235. * The default controller model for the controller
  13236. */
  13237. readonly defaultModel: AbstractMesh;
  13238. /**
  13239. * Creates a new WebVRController from a gamepad
  13240. * @param vrGamepad the gamepad that the WebVRController should be created from
  13241. */
  13242. constructor(vrGamepad: any);
  13243. /**
  13244. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13245. */
  13246. update(): void;
  13247. /**
  13248. * Function to be called when a button is modified
  13249. */
  13250. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13251. /**
  13252. * Loads a mesh and attaches it to the controller
  13253. * @param scene the scene the mesh should be added to
  13254. * @param meshLoaded callback for when the mesh has been loaded
  13255. */
  13256. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13257. private _setButtonValue;
  13258. private _changes;
  13259. private _checkChanges;
  13260. /**
  13261. * Disposes of th webVRCOntroller
  13262. */
  13263. dispose(): void;
  13264. }
  13265. }
  13266. declare module "babylonjs/Lights/hemisphericLight" {
  13267. import { Nullable } from "babylonjs/types";
  13268. import { Scene } from "babylonjs/scene";
  13269. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13270. import { Effect } from "babylonjs/Materials/effect";
  13271. import { Light } from "babylonjs/Lights/light";
  13272. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13273. /**
  13274. * The HemisphericLight simulates the ambient environment light,
  13275. * so the passed direction is the light reflection direction, not the incoming direction.
  13276. */
  13277. export class HemisphericLight extends Light {
  13278. /**
  13279. * The groundColor is the light in the opposite direction to the one specified during creation.
  13280. * 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.
  13281. */
  13282. groundColor: Color3;
  13283. /**
  13284. * The light reflection direction, not the incoming direction.
  13285. */
  13286. direction: Vector3;
  13287. /**
  13288. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13289. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13290. * The HemisphericLight can't cast shadows.
  13291. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13292. * @param name The friendly name of the light
  13293. * @param direction The direction of the light reflection
  13294. * @param scene The scene the light belongs to
  13295. */
  13296. constructor(name: string, direction: Vector3, scene: Scene);
  13297. protected _buildUniformLayout(): void;
  13298. /**
  13299. * Returns the string "HemisphericLight".
  13300. * @return The class name
  13301. */
  13302. getClassName(): string;
  13303. /**
  13304. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13305. * Returns the updated direction.
  13306. * @param target The target the direction should point to
  13307. * @return The computed direction
  13308. */
  13309. setDirectionToTarget(target: Vector3): Vector3;
  13310. /**
  13311. * Returns the shadow generator associated to the light.
  13312. * @returns Always null for hemispheric lights because it does not support shadows.
  13313. */
  13314. getShadowGenerator(): Nullable<IShadowGenerator>;
  13315. /**
  13316. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13317. * @param effect The effect to update
  13318. * @param lightIndex The index of the light in the effect to update
  13319. * @returns The hemispheric light
  13320. */
  13321. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13322. /**
  13323. * Computes the world matrix of the node
  13324. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13325. * @param useWasUpdatedFlag defines a reserved property
  13326. * @returns the world matrix
  13327. */
  13328. computeWorldMatrix(): Matrix;
  13329. /**
  13330. * Returns the integer 3.
  13331. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13332. */
  13333. getTypeID(): number;
  13334. /**
  13335. * Prepares the list of defines specific to the light type.
  13336. * @param defines the list of defines
  13337. * @param lightIndex defines the index of the light for the effect
  13338. */
  13339. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13340. }
  13341. }
  13342. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13343. /** @hidden */
  13344. export var vrMultiviewToSingleviewPixelShader: {
  13345. name: string;
  13346. shader: string;
  13347. };
  13348. }
  13349. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13351. import { Scene } from "babylonjs/scene";
  13352. /**
  13353. * Renders to multiple views with a single draw call
  13354. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13355. */
  13356. export class MultiviewRenderTarget extends RenderTargetTexture {
  13357. /**
  13358. * Creates a multiview render target
  13359. * @param scene scene used with the render target
  13360. * @param size the size of the render target (used for each view)
  13361. */
  13362. constructor(scene: Scene, size?: number | {
  13363. width: number;
  13364. height: number;
  13365. } | {
  13366. ratio: number;
  13367. });
  13368. /**
  13369. * @hidden
  13370. * @param faceIndex the face index, if its a cube texture
  13371. */
  13372. _bindFrameBuffer(faceIndex?: number): void;
  13373. /**
  13374. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13375. * @returns the view count
  13376. */
  13377. getViewCount(): number;
  13378. }
  13379. }
  13380. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13381. import { Camera } from "babylonjs/Cameras/camera";
  13382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13383. import { Nullable } from "babylonjs/types";
  13384. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13385. import { Matrix } from "babylonjs/Maths/math";
  13386. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13387. module "babylonjs/Engines/engine" {
  13388. interface Engine {
  13389. /**
  13390. * Creates a new multiview render target
  13391. * @param width defines the width of the texture
  13392. * @param height defines the height of the texture
  13393. * @returns the created multiview texture
  13394. */
  13395. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13396. /**
  13397. * Binds a multiview framebuffer to be drawn to
  13398. * @param multiviewTexture texture to bind
  13399. */
  13400. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13401. }
  13402. }
  13403. module "babylonjs/Cameras/camera" {
  13404. interface Camera {
  13405. /**
  13406. * @hidden
  13407. * 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)
  13408. */
  13409. _useMultiviewToSingleView: boolean;
  13410. /**
  13411. * @hidden
  13412. * 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)
  13413. */
  13414. _multiviewTexture: Nullable<RenderTargetTexture>;
  13415. /**
  13416. * @hidden
  13417. * ensures the multiview texture of the camera exists and has the specified width/height
  13418. * @param width height to set on the multiview texture
  13419. * @param height width to set on the multiview texture
  13420. */
  13421. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13422. }
  13423. }
  13424. module "babylonjs/scene" {
  13425. interface Scene {
  13426. /** @hidden */
  13427. _transformMatrixR: Matrix;
  13428. /** @hidden */
  13429. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13430. /** @hidden */
  13431. _createMultiviewUbo(): void;
  13432. /** @hidden */
  13433. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13434. /** @hidden */
  13435. _renderMultiviewToSingleView(camera: Camera): void;
  13436. }
  13437. }
  13438. }
  13439. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13440. import { Camera } from "babylonjs/Cameras/camera";
  13441. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13442. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13443. import "babylonjs/Engines/Extensions/engine.multiview";
  13444. /**
  13445. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13446. * This will not be used for webXR as it supports displaying texture arrays directly
  13447. */
  13448. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13449. /**
  13450. * Initializes a VRMultiviewToSingleview
  13451. * @param name name of the post process
  13452. * @param camera camera to be applied to
  13453. * @param scaleFactor scaling factor to the size of the output texture
  13454. */
  13455. constructor(name: string, camera: Camera, scaleFactor: number);
  13456. }
  13457. }
  13458. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13459. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13460. import { Nullable } from "babylonjs/types";
  13461. import { Size } from "babylonjs/Maths/math";
  13462. import { Observable } from "babylonjs/Misc/observable";
  13463. module "babylonjs/Engines/engine" {
  13464. /**
  13465. * Defines the interface used by display changed events
  13466. */
  13467. interface IDisplayChangedEventArgs {
  13468. /** Gets the vrDisplay object (if any) */
  13469. vrDisplay: Nullable<any>;
  13470. /** Gets a boolean indicating if webVR is supported */
  13471. vrSupported: boolean;
  13472. }
  13473. interface Engine {
  13474. /** @hidden */
  13475. _vrDisplay: any;
  13476. /** @hidden */
  13477. _vrSupported: boolean;
  13478. /** @hidden */
  13479. _oldSize: Size;
  13480. /** @hidden */
  13481. _oldHardwareScaleFactor: number;
  13482. /** @hidden */
  13483. _vrExclusivePointerMode: boolean;
  13484. /** @hidden */
  13485. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13486. /** @hidden */
  13487. _onVRDisplayPointerRestricted: () => void;
  13488. /** @hidden */
  13489. _onVRDisplayPointerUnrestricted: () => void;
  13490. /** @hidden */
  13491. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13492. /** @hidden */
  13493. _onVrDisplayDisconnect: Nullable<() => void>;
  13494. /** @hidden */
  13495. _onVrDisplayPresentChange: Nullable<() => void>;
  13496. /**
  13497. * Observable signaled when VR display mode changes
  13498. */
  13499. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13500. /**
  13501. * Observable signaled when VR request present is complete
  13502. */
  13503. onVRRequestPresentComplete: Observable<boolean>;
  13504. /**
  13505. * Observable signaled when VR request present starts
  13506. */
  13507. onVRRequestPresentStart: Observable<Engine>;
  13508. /**
  13509. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13510. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13511. */
  13512. isInVRExclusivePointerMode: boolean;
  13513. /**
  13514. * Gets a boolean indicating if a webVR device was detected
  13515. * @returns true if a webVR device was detected
  13516. */
  13517. isVRDevicePresent(): boolean;
  13518. /**
  13519. * Gets the current webVR device
  13520. * @returns the current webVR device (or null)
  13521. */
  13522. getVRDevice(): any;
  13523. /**
  13524. * Initializes a webVR display and starts listening to display change events
  13525. * The onVRDisplayChangedObservable will be notified upon these changes
  13526. * @returns A promise containing a VRDisplay and if vr is supported
  13527. */
  13528. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13529. /** @hidden */
  13530. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13531. /**
  13532. * Call this function to switch to webVR mode
  13533. * Will do nothing if webVR is not supported or if there is no webVR device
  13534. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13535. */
  13536. enableVR(): void;
  13537. /** @hidden */
  13538. _onVRFullScreenTriggered(): void;
  13539. }
  13540. }
  13541. }
  13542. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13543. import { Nullable } from "babylonjs/types";
  13544. import { Observable } from "babylonjs/Misc/observable";
  13545. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13546. import { Scene } from "babylonjs/scene";
  13547. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13548. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13549. import { Node } from "babylonjs/node";
  13550. import { Ray } from "babylonjs/Culling/ray";
  13551. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13552. import "babylonjs/Engines/Extensions/engine.webVR";
  13553. /**
  13554. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13555. * IMPORTANT!! The data is right-hand data.
  13556. * @export
  13557. * @interface DevicePose
  13558. */
  13559. export interface DevicePose {
  13560. /**
  13561. * The position of the device, values in array are [x,y,z].
  13562. */
  13563. readonly position: Nullable<Float32Array>;
  13564. /**
  13565. * The linearVelocity of the device, values in array are [x,y,z].
  13566. */
  13567. readonly linearVelocity: Nullable<Float32Array>;
  13568. /**
  13569. * The linearAcceleration of the device, values in array are [x,y,z].
  13570. */
  13571. readonly linearAcceleration: Nullable<Float32Array>;
  13572. /**
  13573. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13574. */
  13575. readonly orientation: Nullable<Float32Array>;
  13576. /**
  13577. * The angularVelocity of the device, values in array are [x,y,z].
  13578. */
  13579. readonly angularVelocity: Nullable<Float32Array>;
  13580. /**
  13581. * The angularAcceleration of the device, values in array are [x,y,z].
  13582. */
  13583. readonly angularAcceleration: Nullable<Float32Array>;
  13584. }
  13585. /**
  13586. * Interface representing a pose controlled object in Babylon.
  13587. * A pose controlled object has both regular pose values as well as pose values
  13588. * from an external device such as a VR head mounted display
  13589. */
  13590. export interface PoseControlled {
  13591. /**
  13592. * The position of the object in babylon space.
  13593. */
  13594. position: Vector3;
  13595. /**
  13596. * The rotation quaternion of the object in babylon space.
  13597. */
  13598. rotationQuaternion: Quaternion;
  13599. /**
  13600. * The position of the device in babylon space.
  13601. */
  13602. devicePosition?: Vector3;
  13603. /**
  13604. * The rotation quaternion of the device in babylon space.
  13605. */
  13606. deviceRotationQuaternion: Quaternion;
  13607. /**
  13608. * The raw pose coming from the device.
  13609. */
  13610. rawPose: Nullable<DevicePose>;
  13611. /**
  13612. * The scale of the device to be used when translating from device space to babylon space.
  13613. */
  13614. deviceScaleFactor: number;
  13615. /**
  13616. * Updates the poseControlled values based on the input device pose.
  13617. * @param poseData the pose data to update the object with
  13618. */
  13619. updateFromDevice(poseData: DevicePose): void;
  13620. }
  13621. /**
  13622. * Set of options to customize the webVRCamera
  13623. */
  13624. export interface WebVROptions {
  13625. /**
  13626. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13627. */
  13628. trackPosition?: boolean;
  13629. /**
  13630. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13631. */
  13632. positionScale?: number;
  13633. /**
  13634. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13635. */
  13636. displayName?: string;
  13637. /**
  13638. * Should the native controller meshes be initialized. (default: true)
  13639. */
  13640. controllerMeshes?: boolean;
  13641. /**
  13642. * Creating a default HemiLight only on controllers. (default: true)
  13643. */
  13644. defaultLightingOnControllers?: boolean;
  13645. /**
  13646. * If you don't want to use the default VR button of the helper. (default: false)
  13647. */
  13648. useCustomVRButton?: boolean;
  13649. /**
  13650. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13651. */
  13652. customVRButton?: HTMLButtonElement;
  13653. /**
  13654. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13655. */
  13656. rayLength?: number;
  13657. /**
  13658. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13659. */
  13660. defaultHeight?: number;
  13661. /**
  13662. * If multiview should be used if availible (default: false)
  13663. */
  13664. useMultiview?: boolean;
  13665. }
  13666. /**
  13667. * This represents a WebVR camera.
  13668. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13669. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13670. */
  13671. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13672. private webVROptions;
  13673. /**
  13674. * @hidden
  13675. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13676. */
  13677. _vrDevice: any;
  13678. /**
  13679. * The rawPose of the vrDevice.
  13680. */
  13681. rawPose: Nullable<DevicePose>;
  13682. private _onVREnabled;
  13683. private _specsVersion;
  13684. private _attached;
  13685. private _frameData;
  13686. protected _descendants: Array<Node>;
  13687. private _deviceRoomPosition;
  13688. /** @hidden */
  13689. _deviceRoomRotationQuaternion: Quaternion;
  13690. private _standingMatrix;
  13691. /**
  13692. * Represents device position in babylon space.
  13693. */
  13694. devicePosition: Vector3;
  13695. /**
  13696. * Represents device rotation in babylon space.
  13697. */
  13698. deviceRotationQuaternion: Quaternion;
  13699. /**
  13700. * The scale of the device to be used when translating from device space to babylon space.
  13701. */
  13702. deviceScaleFactor: number;
  13703. private _deviceToWorld;
  13704. private _worldToDevice;
  13705. /**
  13706. * References to the webVR controllers for the vrDevice.
  13707. */
  13708. controllers: Array<WebVRController>;
  13709. /**
  13710. * Emits an event when a controller is attached.
  13711. */
  13712. onControllersAttachedObservable: Observable<WebVRController[]>;
  13713. /**
  13714. * Emits an event when a controller's mesh has been loaded;
  13715. */
  13716. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13717. /**
  13718. * Emits an event when the HMD's pose has been updated.
  13719. */
  13720. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13721. private _poseSet;
  13722. /**
  13723. * If the rig cameras be used as parent instead of this camera.
  13724. */
  13725. rigParenting: boolean;
  13726. private _lightOnControllers;
  13727. private _defaultHeight?;
  13728. /**
  13729. * Instantiates a WebVRFreeCamera.
  13730. * @param name The name of the WebVRFreeCamera
  13731. * @param position The starting anchor position for the camera
  13732. * @param scene The scene the camera belongs to
  13733. * @param webVROptions a set of customizable options for the webVRCamera
  13734. */
  13735. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13736. /**
  13737. * Gets the device distance from the ground in meters.
  13738. * @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.
  13739. */
  13740. deviceDistanceToRoomGround(): number;
  13741. /**
  13742. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13743. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13744. */
  13745. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13746. /**
  13747. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13748. * @returns A promise with a boolean set to if the standing matrix is supported.
  13749. */
  13750. useStandingMatrixAsync(): Promise<boolean>;
  13751. /**
  13752. * Disposes the camera
  13753. */
  13754. dispose(): void;
  13755. /**
  13756. * Gets a vrController by name.
  13757. * @param name The name of the controller to retreive
  13758. * @returns the controller matching the name specified or null if not found
  13759. */
  13760. getControllerByName(name: string): Nullable<WebVRController>;
  13761. private _leftController;
  13762. /**
  13763. * The controller corrisponding to the users left hand.
  13764. */
  13765. readonly leftController: Nullable<WebVRController>;
  13766. private _rightController;
  13767. /**
  13768. * The controller corrisponding to the users right hand.
  13769. */
  13770. readonly rightController: Nullable<WebVRController>;
  13771. /**
  13772. * Casts a ray forward from the vrCamera's gaze.
  13773. * @param length Length of the ray (default: 100)
  13774. * @returns the ray corrisponding to the gaze
  13775. */
  13776. getForwardRay(length?: number): Ray;
  13777. /**
  13778. * @hidden
  13779. * Updates the camera based on device's frame data
  13780. */
  13781. _checkInputs(): void;
  13782. /**
  13783. * Updates the poseControlled values based on the input device pose.
  13784. * @param poseData Pose coming from the device
  13785. */
  13786. updateFromDevice(poseData: DevicePose): void;
  13787. private _htmlElementAttached;
  13788. private _detachIfAttached;
  13789. /**
  13790. * WebVR's attach control will start broadcasting frames to the device.
  13791. * Note that in certain browsers (chrome for example) this function must be called
  13792. * within a user-interaction callback. Example:
  13793. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13794. *
  13795. * @param element html element to attach the vrDevice to
  13796. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13797. */
  13798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13799. /**
  13800. * Detaches the camera from the html element and disables VR
  13801. *
  13802. * @param element html element to detach from
  13803. */
  13804. detachControl(element: HTMLElement): void;
  13805. /**
  13806. * @returns the name of this class
  13807. */
  13808. getClassName(): string;
  13809. /**
  13810. * Calls resetPose on the vrDisplay
  13811. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13812. */
  13813. resetToCurrentRotation(): void;
  13814. /**
  13815. * @hidden
  13816. * Updates the rig cameras (left and right eye)
  13817. */
  13818. _updateRigCameras(): void;
  13819. private _workingVector;
  13820. private _oneVector;
  13821. private _workingMatrix;
  13822. private updateCacheCalled;
  13823. private _correctPositionIfNotTrackPosition;
  13824. /**
  13825. * @hidden
  13826. * Updates the cached values of the camera
  13827. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13828. */
  13829. _updateCache(ignoreParentClass?: boolean): void;
  13830. /**
  13831. * @hidden
  13832. * Get current device position in babylon world
  13833. */
  13834. _computeDevicePosition(): void;
  13835. /**
  13836. * Updates the current device position and rotation in the babylon world
  13837. */
  13838. update(): void;
  13839. /**
  13840. * @hidden
  13841. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13842. * @returns an identity matrix
  13843. */
  13844. _getViewMatrix(): Matrix;
  13845. private _tmpMatrix;
  13846. /**
  13847. * This function is called by the two RIG cameras.
  13848. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13849. * @hidden
  13850. */
  13851. _getWebVRViewMatrix(): Matrix;
  13852. /** @hidden */
  13853. _getWebVRProjectionMatrix(): Matrix;
  13854. private _onGamepadConnectedObserver;
  13855. private _onGamepadDisconnectedObserver;
  13856. private _updateCacheWhenTrackingDisabledObserver;
  13857. /**
  13858. * Initializes the controllers and their meshes
  13859. */
  13860. initControllers(): void;
  13861. }
  13862. }
  13863. declare module "babylonjs/PostProcesses/postProcess" {
  13864. import { Nullable } from "babylonjs/types";
  13865. import { SmartArray } from "babylonjs/Misc/smartArray";
  13866. import { Observable } from "babylonjs/Misc/observable";
  13867. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13868. import { Camera } from "babylonjs/Cameras/camera";
  13869. import { Effect } from "babylonjs/Materials/effect";
  13870. import "babylonjs/Shaders/postprocess.vertex";
  13871. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13872. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13873. import { Engine } from "babylonjs/Engines/engine";
  13874. /**
  13875. * Size options for a post process
  13876. */
  13877. export type PostProcessOptions = {
  13878. width: number;
  13879. height: number;
  13880. };
  13881. /**
  13882. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13883. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13884. */
  13885. export class PostProcess {
  13886. /** Name of the PostProcess. */
  13887. name: string;
  13888. /**
  13889. * Gets or sets the unique id of the post process
  13890. */
  13891. uniqueId: number;
  13892. /**
  13893. * Width of the texture to apply the post process on
  13894. */
  13895. width: number;
  13896. /**
  13897. * Height of the texture to apply the post process on
  13898. */
  13899. height: number;
  13900. /**
  13901. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13902. * @hidden
  13903. */
  13904. _outputTexture: Nullable<InternalTexture>;
  13905. /**
  13906. * Sampling mode used by the shader
  13907. * See https://doc.babylonjs.com/classes/3.1/texture
  13908. */
  13909. renderTargetSamplingMode: number;
  13910. /**
  13911. * Clear color to use when screen clearing
  13912. */
  13913. clearColor: Color4;
  13914. /**
  13915. * If the buffer needs to be cleared before applying the post process. (default: true)
  13916. * Should be set to false if shader will overwrite all previous pixels.
  13917. */
  13918. autoClear: boolean;
  13919. /**
  13920. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13921. */
  13922. alphaMode: number;
  13923. /**
  13924. * Sets the setAlphaBlendConstants of the babylon engine
  13925. */
  13926. alphaConstants: Color4;
  13927. /**
  13928. * Animations to be used for the post processing
  13929. */
  13930. animations: import("babylonjs/Animations/animation").Animation[];
  13931. /**
  13932. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13933. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13934. */
  13935. enablePixelPerfectMode: boolean;
  13936. /**
  13937. * Force the postprocess to be applied without taking in account viewport
  13938. */
  13939. forceFullscreenViewport: boolean;
  13940. /**
  13941. * List of inspectable custom properties (used by the Inspector)
  13942. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13943. */
  13944. inspectableCustomProperties: IInspectable[];
  13945. /**
  13946. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13947. *
  13948. * | Value | Type | Description |
  13949. * | ----- | ----------------------------------- | ----------- |
  13950. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13951. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13952. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13953. *
  13954. */
  13955. scaleMode: number;
  13956. /**
  13957. * Force textures to be a power of two (default: false)
  13958. */
  13959. alwaysForcePOT: boolean;
  13960. private _samples;
  13961. /**
  13962. * Number of sample textures (default: 1)
  13963. */
  13964. samples: number;
  13965. /**
  13966. * Modify the scale of the post process to be the same as the viewport (default: false)
  13967. */
  13968. adaptScaleToCurrentViewport: boolean;
  13969. private _camera;
  13970. private _scene;
  13971. private _engine;
  13972. private _options;
  13973. private _reusable;
  13974. private _textureType;
  13975. /**
  13976. * Smart array of input and output textures for the post process.
  13977. * @hidden
  13978. */
  13979. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13980. /**
  13981. * The index in _textures that corresponds to the output texture.
  13982. * @hidden
  13983. */
  13984. _currentRenderTextureInd: number;
  13985. private _effect;
  13986. private _samplers;
  13987. private _fragmentUrl;
  13988. private _vertexUrl;
  13989. private _parameters;
  13990. private _scaleRatio;
  13991. protected _indexParameters: any;
  13992. private _shareOutputWithPostProcess;
  13993. private _texelSize;
  13994. private _forcedOutputTexture;
  13995. /**
  13996. * Returns the fragment url or shader name used in the post process.
  13997. * @returns the fragment url or name in the shader store.
  13998. */
  13999. getEffectName(): string;
  14000. /**
  14001. * An event triggered when the postprocess is activated.
  14002. */
  14003. onActivateObservable: Observable<Camera>;
  14004. private _onActivateObserver;
  14005. /**
  14006. * A function that is added to the onActivateObservable
  14007. */
  14008. onActivate: Nullable<(camera: Camera) => void>;
  14009. /**
  14010. * An event triggered when the postprocess changes its size.
  14011. */
  14012. onSizeChangedObservable: Observable<PostProcess>;
  14013. private _onSizeChangedObserver;
  14014. /**
  14015. * A function that is added to the onSizeChangedObservable
  14016. */
  14017. onSizeChanged: (postProcess: PostProcess) => void;
  14018. /**
  14019. * An event triggered when the postprocess applies its effect.
  14020. */
  14021. onApplyObservable: Observable<Effect>;
  14022. private _onApplyObserver;
  14023. /**
  14024. * A function that is added to the onApplyObservable
  14025. */
  14026. onApply: (effect: Effect) => void;
  14027. /**
  14028. * An event triggered before rendering the postprocess
  14029. */
  14030. onBeforeRenderObservable: Observable<Effect>;
  14031. private _onBeforeRenderObserver;
  14032. /**
  14033. * A function that is added to the onBeforeRenderObservable
  14034. */
  14035. onBeforeRender: (effect: Effect) => void;
  14036. /**
  14037. * An event triggered after rendering the postprocess
  14038. */
  14039. onAfterRenderObservable: Observable<Effect>;
  14040. private _onAfterRenderObserver;
  14041. /**
  14042. * A function that is added to the onAfterRenderObservable
  14043. */
  14044. onAfterRender: (efect: Effect) => void;
  14045. /**
  14046. * 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
  14047. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14048. */
  14049. inputTexture: InternalTexture;
  14050. /**
  14051. * Gets the camera which post process is applied to.
  14052. * @returns The camera the post process is applied to.
  14053. */
  14054. getCamera(): Camera;
  14055. /**
  14056. * Gets the texel size of the postprocess.
  14057. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14058. */
  14059. readonly texelSize: Vector2;
  14060. /**
  14061. * Creates a new instance PostProcess
  14062. * @param name The name of the PostProcess.
  14063. * @param fragmentUrl The url of the fragment shader to be used.
  14064. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14065. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14066. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14067. * @param camera The camera to apply the render pass to.
  14068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14069. * @param engine The engine which the post process will be applied. (default: current engine)
  14070. * @param reusable If the post process can be reused on the same frame. (default: false)
  14071. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14072. * @param textureType Type of textures used when performing the post process. (default: 0)
  14073. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14074. * @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
  14075. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14076. */
  14077. constructor(
  14078. /** Name of the PostProcess. */
  14079. 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);
  14080. /**
  14081. * Gets a string idenfifying the name of the class
  14082. * @returns "PostProcess" string
  14083. */
  14084. getClassName(): string;
  14085. /**
  14086. * Gets the engine which this post process belongs to.
  14087. * @returns The engine the post process was enabled with.
  14088. */
  14089. getEngine(): Engine;
  14090. /**
  14091. * The effect that is created when initializing the post process.
  14092. * @returns The created effect corrisponding the the postprocess.
  14093. */
  14094. getEffect(): Effect;
  14095. /**
  14096. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14097. * @param postProcess The post process to share the output with.
  14098. * @returns This post process.
  14099. */
  14100. shareOutputWith(postProcess: PostProcess): PostProcess;
  14101. /**
  14102. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14103. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14104. */
  14105. useOwnOutput(): void;
  14106. /**
  14107. * Updates the effect with the current post process compile time values and recompiles the shader.
  14108. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14109. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14110. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14111. * @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
  14112. * @param onCompiled Called when the shader has been compiled.
  14113. * @param onError Called if there is an error when compiling a shader.
  14114. */
  14115. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14116. /**
  14117. * The post process is reusable if it can be used multiple times within one frame.
  14118. * @returns If the post process is reusable
  14119. */
  14120. isReusable(): boolean;
  14121. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14122. markTextureDirty(): void;
  14123. /**
  14124. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14125. * 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.
  14126. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14127. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14128. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14129. * @returns The target texture that was bound to be written to.
  14130. */
  14131. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14132. /**
  14133. * If the post process is supported.
  14134. */
  14135. readonly isSupported: boolean;
  14136. /**
  14137. * The aspect ratio of the output texture.
  14138. */
  14139. readonly aspectRatio: number;
  14140. /**
  14141. * Get a value indicating if the post-process is ready to be used
  14142. * @returns true if the post-process is ready (shader is compiled)
  14143. */
  14144. isReady(): boolean;
  14145. /**
  14146. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14147. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14148. */
  14149. apply(): Nullable<Effect>;
  14150. private _disposeTextures;
  14151. /**
  14152. * Disposes the post process.
  14153. * @param camera The camera to dispose the post process on.
  14154. */
  14155. dispose(camera?: Camera): void;
  14156. }
  14157. }
  14158. declare module "babylonjs/PostProcesses/postProcessManager" {
  14159. import { Nullable } from "babylonjs/types";
  14160. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14161. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14162. import { Scene } from "babylonjs/scene";
  14163. /**
  14164. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14165. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14166. */
  14167. export class PostProcessManager {
  14168. private _scene;
  14169. private _indexBuffer;
  14170. private _vertexBuffers;
  14171. /**
  14172. * Creates a new instance PostProcess
  14173. * @param scene The scene that the post process is associated with.
  14174. */
  14175. constructor(scene: Scene);
  14176. private _prepareBuffers;
  14177. private _buildIndexBuffer;
  14178. /**
  14179. * Rebuilds the vertex buffers of the manager.
  14180. * @hidden
  14181. */
  14182. _rebuild(): void;
  14183. /**
  14184. * Prepares a frame to be run through a post process.
  14185. * @param sourceTexture The input texture to the post procesess. (default: null)
  14186. * @param postProcesses An array of post processes to be run. (default: null)
  14187. * @returns True if the post processes were able to be run.
  14188. * @hidden
  14189. */
  14190. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14191. /**
  14192. * Manually render a set of post processes to a texture.
  14193. * @param postProcesses An array of post processes to be run.
  14194. * @param targetTexture The target texture to render to.
  14195. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14196. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14197. * @param lodLevel defines which lod of the texture to render to
  14198. */
  14199. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14200. /**
  14201. * Finalize the result of the output of the postprocesses.
  14202. * @param doNotPresent If true the result will not be displayed to the screen.
  14203. * @param targetTexture The target texture to render to.
  14204. * @param faceIndex The index of the face to bind the target texture to.
  14205. * @param postProcesses The array of post processes to render.
  14206. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14207. * @hidden
  14208. */
  14209. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14210. /**
  14211. * Disposes of the post process manager.
  14212. */
  14213. dispose(): void;
  14214. }
  14215. }
  14216. declare module "babylonjs/Layers/layerSceneComponent" {
  14217. import { Scene } from "babylonjs/scene";
  14218. import { ISceneComponent } from "babylonjs/sceneComponent";
  14219. import { Layer } from "babylonjs/Layers/layer";
  14220. module "babylonjs/abstractScene" {
  14221. interface AbstractScene {
  14222. /**
  14223. * The list of layers (background and foreground) of the scene
  14224. */
  14225. layers: Array<Layer>;
  14226. }
  14227. }
  14228. /**
  14229. * Defines the layer scene component responsible to manage any layers
  14230. * in a given scene.
  14231. */
  14232. export class LayerSceneComponent implements ISceneComponent {
  14233. /**
  14234. * The component name helpfull to identify the component in the list of scene components.
  14235. */
  14236. readonly name: string;
  14237. /**
  14238. * The scene the component belongs to.
  14239. */
  14240. scene: Scene;
  14241. private _engine;
  14242. /**
  14243. * Creates a new instance of the component for the given scene
  14244. * @param scene Defines the scene to register the component in
  14245. */
  14246. constructor(scene: Scene);
  14247. /**
  14248. * Registers the component in a given scene
  14249. */
  14250. register(): void;
  14251. /**
  14252. * Rebuilds the elements related to this component in case of
  14253. * context lost for instance.
  14254. */
  14255. rebuild(): void;
  14256. /**
  14257. * Disposes the component and the associated ressources.
  14258. */
  14259. dispose(): void;
  14260. private _draw;
  14261. private _drawCameraPredicate;
  14262. private _drawCameraBackground;
  14263. private _drawCameraForeground;
  14264. private _drawRenderTargetPredicate;
  14265. private _drawRenderTargetBackground;
  14266. private _drawRenderTargetForeground;
  14267. }
  14268. }
  14269. declare module "babylonjs/Shaders/layer.fragment" {
  14270. /** @hidden */
  14271. export var layerPixelShader: {
  14272. name: string;
  14273. shader: string;
  14274. };
  14275. }
  14276. declare module "babylonjs/Shaders/layer.vertex" {
  14277. /** @hidden */
  14278. export var layerVertexShader: {
  14279. name: string;
  14280. shader: string;
  14281. };
  14282. }
  14283. declare module "babylonjs/Layers/layer" {
  14284. import { Observable } from "babylonjs/Misc/observable";
  14285. import { Nullable } from "babylonjs/types";
  14286. import { Scene } from "babylonjs/scene";
  14287. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14288. import { Texture } from "babylonjs/Materials/Textures/texture";
  14289. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14290. import "babylonjs/Shaders/layer.fragment";
  14291. import "babylonjs/Shaders/layer.vertex";
  14292. /**
  14293. * This represents a full screen 2d layer.
  14294. * This can be useful to display a picture in the background of your scene for instance.
  14295. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14296. */
  14297. export class Layer {
  14298. /**
  14299. * Define the name of the layer.
  14300. */
  14301. name: string;
  14302. /**
  14303. * Define the texture the layer should display.
  14304. */
  14305. texture: Nullable<Texture>;
  14306. /**
  14307. * Is the layer in background or foreground.
  14308. */
  14309. isBackground: boolean;
  14310. /**
  14311. * Define the color of the layer (instead of texture).
  14312. */
  14313. color: Color4;
  14314. /**
  14315. * Define the scale of the layer in order to zoom in out of the texture.
  14316. */
  14317. scale: Vector2;
  14318. /**
  14319. * Define an offset for the layer in order to shift the texture.
  14320. */
  14321. offset: Vector2;
  14322. /**
  14323. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14324. */
  14325. alphaBlendingMode: number;
  14326. /**
  14327. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14328. * Alpha test will not mix with the background color in case of transparency.
  14329. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14330. */
  14331. alphaTest: boolean;
  14332. /**
  14333. * Define a mask to restrict the layer to only some of the scene cameras.
  14334. */
  14335. layerMask: number;
  14336. /**
  14337. * Define the list of render target the layer is visible into.
  14338. */
  14339. renderTargetTextures: RenderTargetTexture[];
  14340. /**
  14341. * Define if the layer is only used in renderTarget or if it also
  14342. * renders in the main frame buffer of the canvas.
  14343. */
  14344. renderOnlyInRenderTargetTextures: boolean;
  14345. private _scene;
  14346. private _vertexBuffers;
  14347. private _indexBuffer;
  14348. private _effect;
  14349. private _alphaTestEffect;
  14350. /**
  14351. * An event triggered when the layer is disposed.
  14352. */
  14353. onDisposeObservable: Observable<Layer>;
  14354. private _onDisposeObserver;
  14355. /**
  14356. * Back compatibility with callback before the onDisposeObservable existed.
  14357. * The set callback will be triggered when the layer has been disposed.
  14358. */
  14359. onDispose: () => void;
  14360. /**
  14361. * An event triggered before rendering the scene
  14362. */
  14363. onBeforeRenderObservable: Observable<Layer>;
  14364. private _onBeforeRenderObserver;
  14365. /**
  14366. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14367. * The set callback will be triggered just before rendering the layer.
  14368. */
  14369. onBeforeRender: () => void;
  14370. /**
  14371. * An event triggered after rendering the scene
  14372. */
  14373. onAfterRenderObservable: Observable<Layer>;
  14374. private _onAfterRenderObserver;
  14375. /**
  14376. * Back compatibility with callback before the onAfterRenderObservable existed.
  14377. * The set callback will be triggered just after rendering the layer.
  14378. */
  14379. onAfterRender: () => void;
  14380. /**
  14381. * Instantiates a new layer.
  14382. * This represents a full screen 2d layer.
  14383. * This can be useful to display a picture in the background of your scene for instance.
  14384. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14385. * @param name Define the name of the layer in the scene
  14386. * @param imgUrl Define the url of the texture to display in the layer
  14387. * @param scene Define the scene the layer belongs to
  14388. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14389. * @param color Defines a color for the layer
  14390. */
  14391. constructor(
  14392. /**
  14393. * Define the name of the layer.
  14394. */
  14395. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14396. private _createIndexBuffer;
  14397. /** @hidden */
  14398. _rebuild(): void;
  14399. /**
  14400. * Renders the layer in the scene.
  14401. */
  14402. render(): void;
  14403. /**
  14404. * Disposes and releases the associated ressources.
  14405. */
  14406. dispose(): void;
  14407. }
  14408. }
  14409. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14410. import { Scene } from "babylonjs/scene";
  14411. import { ISceneComponent } from "babylonjs/sceneComponent";
  14412. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14413. module "babylonjs/abstractScene" {
  14414. interface AbstractScene {
  14415. /**
  14416. * The list of procedural textures added to the scene
  14417. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14418. */
  14419. proceduralTextures: Array<ProceduralTexture>;
  14420. }
  14421. }
  14422. /**
  14423. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14424. * in a given scene.
  14425. */
  14426. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14427. /**
  14428. * The component name helpfull to identify the component in the list of scene components.
  14429. */
  14430. readonly name: string;
  14431. /**
  14432. * The scene the component belongs to.
  14433. */
  14434. scene: Scene;
  14435. /**
  14436. * Creates a new instance of the component for the given scene
  14437. * @param scene Defines the scene to register the component in
  14438. */
  14439. constructor(scene: Scene);
  14440. /**
  14441. * Registers the component in a given scene
  14442. */
  14443. register(): void;
  14444. /**
  14445. * Rebuilds the elements related to this component in case of
  14446. * context lost for instance.
  14447. */
  14448. rebuild(): void;
  14449. /**
  14450. * Disposes the component and the associated ressources.
  14451. */
  14452. dispose(): void;
  14453. private _beforeClear;
  14454. }
  14455. }
  14456. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14457. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14458. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14459. module "babylonjs/Engines/engine" {
  14460. interface Engine {
  14461. /**
  14462. * Creates a new render target cube texture
  14463. * @param size defines the size of the texture
  14464. * @param options defines the options used to create the texture
  14465. * @returns a new render target cube texture stored in an InternalTexture
  14466. */
  14467. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14468. }
  14469. }
  14470. }
  14471. declare module "babylonjs/Shaders/procedural.vertex" {
  14472. /** @hidden */
  14473. export var proceduralVertexShader: {
  14474. name: string;
  14475. shader: string;
  14476. };
  14477. }
  14478. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14479. import { Observable } from "babylonjs/Misc/observable";
  14480. import { Nullable } from "babylonjs/types";
  14481. import { Scene } from "babylonjs/scene";
  14482. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14483. import { Effect } from "babylonjs/Materials/effect";
  14484. import { Texture } from "babylonjs/Materials/Textures/texture";
  14485. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14486. import "babylonjs/Shaders/procedural.vertex";
  14487. /**
  14488. * 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.
  14489. * This is the base class of any Procedural texture and contains most of the shareable code.
  14490. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14491. */
  14492. export class ProceduralTexture extends Texture {
  14493. isCube: boolean;
  14494. /**
  14495. * Define if the texture is enabled or not (disabled texture will not render)
  14496. */
  14497. isEnabled: boolean;
  14498. /**
  14499. * Define if the texture must be cleared before rendering (default is true)
  14500. */
  14501. autoClear: boolean;
  14502. /**
  14503. * Callback called when the texture is generated
  14504. */
  14505. onGenerated: () => void;
  14506. /**
  14507. * Event raised when the texture is generated
  14508. */
  14509. onGeneratedObservable: Observable<ProceduralTexture>;
  14510. /** @hidden */
  14511. _generateMipMaps: boolean;
  14512. /** @hidden **/
  14513. _effect: Effect;
  14514. /** @hidden */
  14515. _textures: {
  14516. [key: string]: Texture;
  14517. };
  14518. private _size;
  14519. private _currentRefreshId;
  14520. private _refreshRate;
  14521. private _vertexBuffers;
  14522. private _indexBuffer;
  14523. private _uniforms;
  14524. private _samplers;
  14525. private _fragment;
  14526. private _floats;
  14527. private _ints;
  14528. private _floatsArrays;
  14529. private _colors3;
  14530. private _colors4;
  14531. private _vectors2;
  14532. private _vectors3;
  14533. private _matrices;
  14534. private _fallbackTexture;
  14535. private _fallbackTextureUsed;
  14536. private _engine;
  14537. private _cachedDefines;
  14538. private _contentUpdateId;
  14539. private _contentData;
  14540. /**
  14541. * Instantiates a new procedural texture.
  14542. * 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.
  14543. * This is the base class of any Procedural texture and contains most of the shareable code.
  14544. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14545. * @param name Define the name of the texture
  14546. * @param size Define the size of the texture to create
  14547. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14548. * @param scene Define the scene the texture belongs to
  14549. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14550. * @param generateMipMaps Define if the texture should creates mip maps or not
  14551. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14552. */
  14553. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14554. /**
  14555. * The effect that is created when initializing the post process.
  14556. * @returns The created effect corrisponding the the postprocess.
  14557. */
  14558. getEffect(): Effect;
  14559. /**
  14560. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14561. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14562. */
  14563. getContent(): Nullable<ArrayBufferView>;
  14564. private _createIndexBuffer;
  14565. /** @hidden */
  14566. _rebuild(): void;
  14567. /**
  14568. * Resets the texture in order to recreate its associated resources.
  14569. * This can be called in case of context loss
  14570. */
  14571. reset(): void;
  14572. protected _getDefines(): string;
  14573. /**
  14574. * Is the texture ready to be used ? (rendered at least once)
  14575. * @returns true if ready, otherwise, false.
  14576. */
  14577. isReady(): boolean;
  14578. /**
  14579. * Resets the refresh counter of the texture and start bak from scratch.
  14580. * Could be useful to regenerate the texture if it is setup to render only once.
  14581. */
  14582. resetRefreshCounter(): void;
  14583. /**
  14584. * Set the fragment shader to use in order to render the texture.
  14585. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14586. */
  14587. setFragment(fragment: any): void;
  14588. /**
  14589. * Define the refresh rate of the texture or the rendering frequency.
  14590. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14591. */
  14592. refreshRate: number;
  14593. /** @hidden */
  14594. _shouldRender(): boolean;
  14595. /**
  14596. * Get the size the texture is rendering at.
  14597. * @returns the size (texture is always squared)
  14598. */
  14599. getRenderSize(): number;
  14600. /**
  14601. * Resize the texture to new value.
  14602. * @param size Define the new size the texture should have
  14603. * @param generateMipMaps Define whether the new texture should create mip maps
  14604. */
  14605. resize(size: number, generateMipMaps: boolean): void;
  14606. private _checkUniform;
  14607. /**
  14608. * Set a texture in the shader program used to render.
  14609. * @param name Define the name of the uniform samplers as defined in the shader
  14610. * @param texture Define the texture to bind to this sampler
  14611. * @return the texture itself allowing "fluent" like uniform updates
  14612. */
  14613. setTexture(name: string, texture: Texture): ProceduralTexture;
  14614. /**
  14615. * Set a float in the shader.
  14616. * @param name Define the name of the uniform as defined in the shader
  14617. * @param value Define the value to give to the uniform
  14618. * @return the texture itself allowing "fluent" like uniform updates
  14619. */
  14620. setFloat(name: string, value: number): ProceduralTexture;
  14621. /**
  14622. * Set a int in the shader.
  14623. * @param name Define the name of the uniform as defined in the shader
  14624. * @param value Define the value to give to the uniform
  14625. * @return the texture itself allowing "fluent" like uniform updates
  14626. */
  14627. setInt(name: string, value: number): ProceduralTexture;
  14628. /**
  14629. * Set an array of floats in the shader.
  14630. * @param name Define the name of the uniform as defined in the shader
  14631. * @param value Define the value to give to the uniform
  14632. * @return the texture itself allowing "fluent" like uniform updates
  14633. */
  14634. setFloats(name: string, value: number[]): ProceduralTexture;
  14635. /**
  14636. * Set a vec3 in the shader from a Color3.
  14637. * @param name Define the name of the uniform as defined in the shader
  14638. * @param value Define the value to give to the uniform
  14639. * @return the texture itself allowing "fluent" like uniform updates
  14640. */
  14641. setColor3(name: string, value: Color3): ProceduralTexture;
  14642. /**
  14643. * Set a vec4 in the shader from a Color4.
  14644. * @param name Define the name of the uniform as defined in the shader
  14645. * @param value Define the value to give to the uniform
  14646. * @return the texture itself allowing "fluent" like uniform updates
  14647. */
  14648. setColor4(name: string, value: Color4): ProceduralTexture;
  14649. /**
  14650. * Set a vec2 in the shader from a Vector2.
  14651. * @param name Define the name of the uniform as defined in the shader
  14652. * @param value Define the value to give to the uniform
  14653. * @return the texture itself allowing "fluent" like uniform updates
  14654. */
  14655. setVector2(name: string, value: Vector2): ProceduralTexture;
  14656. /**
  14657. * Set a vec3 in the shader from a Vector3.
  14658. * @param name Define the name of the uniform as defined in the shader
  14659. * @param value Define the value to give to the uniform
  14660. * @return the texture itself allowing "fluent" like uniform updates
  14661. */
  14662. setVector3(name: string, value: Vector3): ProceduralTexture;
  14663. /**
  14664. * Set a mat4 in the shader from a MAtrix.
  14665. * @param name Define the name of the uniform as defined in the shader
  14666. * @param value Define the value to give to the uniform
  14667. * @return the texture itself allowing "fluent" like uniform updates
  14668. */
  14669. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14670. /**
  14671. * Render the texture to its associated render target.
  14672. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14673. */
  14674. render(useCameraPostProcess?: boolean): void;
  14675. /**
  14676. * Clone the texture.
  14677. * @returns the cloned texture
  14678. */
  14679. clone(): ProceduralTexture;
  14680. /**
  14681. * Dispose the texture and release its asoociated resources.
  14682. */
  14683. dispose(): void;
  14684. }
  14685. }
  14686. declare module "babylonjs/Particles/baseParticleSystem" {
  14687. import { Nullable } from "babylonjs/types";
  14688. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14690. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14691. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14692. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14693. import { Scene } from "babylonjs/scene";
  14694. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14695. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14696. import { Texture } from "babylonjs/Materials/Textures/texture";
  14697. import { Animation } from "babylonjs/Animations/animation";
  14698. /**
  14699. * This represents the base class for particle system in Babylon.
  14700. * 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.
  14701. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14702. * @example https://doc.babylonjs.com/babylon101/particles
  14703. */
  14704. export class BaseParticleSystem {
  14705. /**
  14706. * Source color is added to the destination color without alpha affecting the result
  14707. */
  14708. static BLENDMODE_ONEONE: number;
  14709. /**
  14710. * Blend current color and particle color using particle’s alpha
  14711. */
  14712. static BLENDMODE_STANDARD: number;
  14713. /**
  14714. * Add current color and particle color multiplied by particle’s alpha
  14715. */
  14716. static BLENDMODE_ADD: number;
  14717. /**
  14718. * Multiply current color with particle color
  14719. */
  14720. static BLENDMODE_MULTIPLY: number;
  14721. /**
  14722. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14723. */
  14724. static BLENDMODE_MULTIPLYADD: number;
  14725. /**
  14726. * List of animations used by the particle system.
  14727. */
  14728. animations: Animation[];
  14729. /**
  14730. * The id of the Particle system.
  14731. */
  14732. id: string;
  14733. /**
  14734. * The friendly name of the Particle system.
  14735. */
  14736. name: string;
  14737. /**
  14738. * The rendering group used by the Particle system to chose when to render.
  14739. */
  14740. renderingGroupId: number;
  14741. /**
  14742. * The emitter represents the Mesh or position we are attaching the particle system to.
  14743. */
  14744. emitter: Nullable<AbstractMesh | Vector3>;
  14745. /**
  14746. * The maximum number of particles to emit per frame
  14747. */
  14748. emitRate: number;
  14749. /**
  14750. * If you want to launch only a few particles at once, that can be done, as well.
  14751. */
  14752. manualEmitCount: number;
  14753. /**
  14754. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14755. */
  14756. updateSpeed: number;
  14757. /**
  14758. * The amount of time the particle system is running (depends of the overall update speed).
  14759. */
  14760. targetStopDuration: number;
  14761. /**
  14762. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14763. */
  14764. disposeOnStop: boolean;
  14765. /**
  14766. * Minimum power of emitting particles.
  14767. */
  14768. minEmitPower: number;
  14769. /**
  14770. * Maximum power of emitting particles.
  14771. */
  14772. maxEmitPower: number;
  14773. /**
  14774. * Minimum life time of emitting particles.
  14775. */
  14776. minLifeTime: number;
  14777. /**
  14778. * Maximum life time of emitting particles.
  14779. */
  14780. maxLifeTime: number;
  14781. /**
  14782. * Minimum Size of emitting particles.
  14783. */
  14784. minSize: number;
  14785. /**
  14786. * Maximum Size of emitting particles.
  14787. */
  14788. maxSize: number;
  14789. /**
  14790. * Minimum scale of emitting particles on X axis.
  14791. */
  14792. minScaleX: number;
  14793. /**
  14794. * Maximum scale of emitting particles on X axis.
  14795. */
  14796. maxScaleX: number;
  14797. /**
  14798. * Minimum scale of emitting particles on Y axis.
  14799. */
  14800. minScaleY: number;
  14801. /**
  14802. * Maximum scale of emitting particles on Y axis.
  14803. */
  14804. maxScaleY: number;
  14805. /**
  14806. * Gets or sets the minimal initial rotation in radians.
  14807. */
  14808. minInitialRotation: number;
  14809. /**
  14810. * Gets or sets the maximal initial rotation in radians.
  14811. */
  14812. maxInitialRotation: number;
  14813. /**
  14814. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14815. */
  14816. minAngularSpeed: number;
  14817. /**
  14818. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14819. */
  14820. maxAngularSpeed: number;
  14821. /**
  14822. * The texture used to render each particle. (this can be a spritesheet)
  14823. */
  14824. particleTexture: Nullable<Texture>;
  14825. /**
  14826. * The layer mask we are rendering the particles through.
  14827. */
  14828. layerMask: number;
  14829. /**
  14830. * This can help using your own shader to render the particle system.
  14831. * The according effect will be created
  14832. */
  14833. customShader: any;
  14834. /**
  14835. * By default particle system starts as soon as they are created. This prevents the
  14836. * automatic start to happen and let you decide when to start emitting particles.
  14837. */
  14838. preventAutoStart: boolean;
  14839. private _noiseTexture;
  14840. /**
  14841. * Gets or sets a texture used to add random noise to particle positions
  14842. */
  14843. noiseTexture: Nullable<ProceduralTexture>;
  14844. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14845. noiseStrength: Vector3;
  14846. /**
  14847. * Callback triggered when the particle animation is ending.
  14848. */
  14849. onAnimationEnd: Nullable<() => void>;
  14850. /**
  14851. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14852. */
  14853. blendMode: number;
  14854. /**
  14855. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14856. * to override the particles.
  14857. */
  14858. forceDepthWrite: boolean;
  14859. /** 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 */
  14860. preWarmCycles: number;
  14861. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14862. preWarmStepOffset: number;
  14863. /**
  14864. * 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)
  14865. */
  14866. spriteCellChangeSpeed: number;
  14867. /**
  14868. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14869. */
  14870. startSpriteCellID: number;
  14871. /**
  14872. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14873. */
  14874. endSpriteCellID: number;
  14875. /**
  14876. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14877. */
  14878. spriteCellWidth: number;
  14879. /**
  14880. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14881. */
  14882. spriteCellHeight: number;
  14883. /**
  14884. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14885. */
  14886. spriteRandomStartCell: boolean;
  14887. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14888. translationPivot: Vector2;
  14889. /** @hidden */
  14890. protected _isAnimationSheetEnabled: boolean;
  14891. /**
  14892. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14893. */
  14894. beginAnimationOnStart: boolean;
  14895. /**
  14896. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14897. */
  14898. beginAnimationFrom: number;
  14899. /**
  14900. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14901. */
  14902. beginAnimationTo: number;
  14903. /**
  14904. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14905. */
  14906. beginAnimationLoop: boolean;
  14907. /**
  14908. * Gets or sets a world offset applied to all particles
  14909. */
  14910. worldOffset: Vector3;
  14911. /**
  14912. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14913. */
  14914. isAnimationSheetEnabled: boolean;
  14915. /**
  14916. * Get hosting scene
  14917. * @returns the scene
  14918. */
  14919. getScene(): Scene;
  14920. /**
  14921. * You can use gravity if you want to give an orientation to your particles.
  14922. */
  14923. gravity: Vector3;
  14924. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14925. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14926. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14927. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14928. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14929. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14930. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14931. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14932. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14933. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14934. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14935. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14936. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14937. /**
  14938. * Defines the delay in milliseconds before starting the system (0 by default)
  14939. */
  14940. startDelay: number;
  14941. /**
  14942. * Gets the current list of drag gradients.
  14943. * You must use addDragGradient and removeDragGradient to udpate this list
  14944. * @returns the list of drag gradients
  14945. */
  14946. getDragGradients(): Nullable<Array<FactorGradient>>;
  14947. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14948. limitVelocityDamping: number;
  14949. /**
  14950. * Gets the current list of limit velocity gradients.
  14951. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14952. * @returns the list of limit velocity gradients
  14953. */
  14954. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14955. /**
  14956. * Gets the current list of color gradients.
  14957. * You must use addColorGradient and removeColorGradient to udpate this list
  14958. * @returns the list of color gradients
  14959. */
  14960. getColorGradients(): Nullable<Array<ColorGradient>>;
  14961. /**
  14962. * Gets the current list of size gradients.
  14963. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14964. * @returns the list of size gradients
  14965. */
  14966. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14967. /**
  14968. * Gets the current list of color remap gradients.
  14969. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14970. * @returns the list of color remap gradients
  14971. */
  14972. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14973. /**
  14974. * Gets the current list of alpha remap gradients.
  14975. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14976. * @returns the list of alpha remap gradients
  14977. */
  14978. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14979. /**
  14980. * Gets the current list of life time gradients.
  14981. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14982. * @returns the list of life time gradients
  14983. */
  14984. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14985. /**
  14986. * Gets the current list of angular speed gradients.
  14987. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14988. * @returns the list of angular speed gradients
  14989. */
  14990. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14991. /**
  14992. * Gets the current list of velocity gradients.
  14993. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14994. * @returns the list of velocity gradients
  14995. */
  14996. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14997. /**
  14998. * Gets the current list of start size gradients.
  14999. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15000. * @returns the list of start size gradients
  15001. */
  15002. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15003. /**
  15004. * Gets the current list of emit rate gradients.
  15005. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15006. * @returns the list of emit rate gradients
  15007. */
  15008. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15009. /**
  15010. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15011. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15012. */
  15013. direction1: Vector3;
  15014. /**
  15015. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15016. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15017. */
  15018. direction2: Vector3;
  15019. /**
  15020. * 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.
  15021. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15022. */
  15023. minEmitBox: Vector3;
  15024. /**
  15025. * 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.
  15026. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15027. */
  15028. maxEmitBox: Vector3;
  15029. /**
  15030. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15031. */
  15032. color1: Color4;
  15033. /**
  15034. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15035. */
  15036. color2: Color4;
  15037. /**
  15038. * Color the particle will have at the end of its lifetime
  15039. */
  15040. colorDead: Color4;
  15041. /**
  15042. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15043. */
  15044. textureMask: Color4;
  15045. /**
  15046. * The particle emitter type defines the emitter used by the particle system.
  15047. * It can be for example box, sphere, or cone...
  15048. */
  15049. particleEmitterType: IParticleEmitterType;
  15050. /** @hidden */
  15051. _isSubEmitter: boolean;
  15052. /**
  15053. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15054. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15055. */
  15056. billboardMode: number;
  15057. protected _isBillboardBased: boolean;
  15058. /**
  15059. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15060. */
  15061. isBillboardBased: boolean;
  15062. /**
  15063. * The scene the particle system belongs to.
  15064. */
  15065. protected _scene: Scene;
  15066. /**
  15067. * Local cache of defines for image processing.
  15068. */
  15069. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15070. /**
  15071. * Default configuration related to image processing available in the standard Material.
  15072. */
  15073. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15074. /**
  15075. * Gets the image processing configuration used either in this material.
  15076. */
  15077. /**
  15078. * Sets the Default image processing configuration used either in the this material.
  15079. *
  15080. * If sets to null, the scene one is in use.
  15081. */
  15082. imageProcessingConfiguration: ImageProcessingConfiguration;
  15083. /**
  15084. * Attaches a new image processing configuration to the Standard Material.
  15085. * @param configuration
  15086. */
  15087. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15088. /** @hidden */
  15089. protected _reset(): void;
  15090. /** @hidden */
  15091. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15092. /**
  15093. * Instantiates a particle system.
  15094. * 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.
  15095. * @param name The name of the particle system
  15096. */
  15097. constructor(name: string);
  15098. /**
  15099. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15100. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15101. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15102. * @returns the emitter
  15103. */
  15104. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15105. /**
  15106. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15107. * @param radius The radius of the hemisphere to emit from
  15108. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15109. * @returns the emitter
  15110. */
  15111. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15112. /**
  15113. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15114. * @param radius The radius of the sphere to emit from
  15115. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15116. * @returns the emitter
  15117. */
  15118. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15119. /**
  15120. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15121. * @param radius The radius of the sphere to emit from
  15122. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15123. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15124. * @returns the emitter
  15125. */
  15126. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15127. /**
  15128. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15129. * @param radius The radius of the emission cylinder
  15130. * @param height The height of the emission cylinder
  15131. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15132. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15133. * @returns the emitter
  15134. */
  15135. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15136. /**
  15137. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15138. * @param radius The radius of the cylinder to emit from
  15139. * @param height The height of the emission cylinder
  15140. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15143. * @returns the emitter
  15144. */
  15145. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15146. /**
  15147. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15148. * @param radius The radius of the cone to emit from
  15149. * @param angle The base angle of the cone
  15150. * @returns the emitter
  15151. */
  15152. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15153. /**
  15154. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15155. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15156. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15157. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15158. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15159. * @returns the emitter
  15160. */
  15161. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15162. }
  15163. }
  15164. declare module "babylonjs/Particles/subEmitter" {
  15165. import { Scene } from "babylonjs/scene";
  15166. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15167. /**
  15168. * Type of sub emitter
  15169. */
  15170. export enum SubEmitterType {
  15171. /**
  15172. * Attached to the particle over it's lifetime
  15173. */
  15174. ATTACHED = 0,
  15175. /**
  15176. * Created when the particle dies
  15177. */
  15178. END = 1
  15179. }
  15180. /**
  15181. * Sub emitter class used to emit particles from an existing particle
  15182. */
  15183. export class SubEmitter {
  15184. /**
  15185. * the particle system to be used by the sub emitter
  15186. */
  15187. particleSystem: ParticleSystem;
  15188. /**
  15189. * Type of the submitter (Default: END)
  15190. */
  15191. type: SubEmitterType;
  15192. /**
  15193. * 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)
  15194. * Note: This only is supported when using an emitter of type Mesh
  15195. */
  15196. inheritDirection: boolean;
  15197. /**
  15198. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15199. */
  15200. inheritedVelocityAmount: number;
  15201. /**
  15202. * Creates a sub emitter
  15203. * @param particleSystem the particle system to be used by the sub emitter
  15204. */
  15205. constructor(
  15206. /**
  15207. * the particle system to be used by the sub emitter
  15208. */
  15209. particleSystem: ParticleSystem);
  15210. /**
  15211. * Clones the sub emitter
  15212. * @returns the cloned sub emitter
  15213. */
  15214. clone(): SubEmitter;
  15215. /**
  15216. * Serialize current object to a JSON object
  15217. * @returns the serialized object
  15218. */
  15219. serialize(): any;
  15220. /** @hidden */
  15221. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15222. /**
  15223. * Creates a new SubEmitter from a serialized JSON version
  15224. * @param serializationObject defines the JSON object to read from
  15225. * @param scene defines the hosting scene
  15226. * @param rootUrl defines the rootUrl for data loading
  15227. * @returns a new SubEmitter
  15228. */
  15229. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15230. /** Release associated resources */
  15231. dispose(): void;
  15232. }
  15233. }
  15234. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15235. /** @hidden */
  15236. export var clipPlaneFragmentDeclaration: {
  15237. name: string;
  15238. shader: string;
  15239. };
  15240. }
  15241. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15242. /** @hidden */
  15243. export var imageProcessingDeclaration: {
  15244. name: string;
  15245. shader: string;
  15246. };
  15247. }
  15248. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15249. /** @hidden */
  15250. export var imageProcessingFunctions: {
  15251. name: string;
  15252. shader: string;
  15253. };
  15254. }
  15255. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15256. /** @hidden */
  15257. export var clipPlaneFragment: {
  15258. name: string;
  15259. shader: string;
  15260. };
  15261. }
  15262. declare module "babylonjs/Shaders/particles.fragment" {
  15263. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15264. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15265. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15266. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15267. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15268. /** @hidden */
  15269. export var particlesPixelShader: {
  15270. name: string;
  15271. shader: string;
  15272. };
  15273. }
  15274. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15275. /** @hidden */
  15276. export var clipPlaneVertexDeclaration: {
  15277. name: string;
  15278. shader: string;
  15279. };
  15280. }
  15281. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15282. /** @hidden */
  15283. export var clipPlaneVertex: {
  15284. name: string;
  15285. shader: string;
  15286. };
  15287. }
  15288. declare module "babylonjs/Shaders/particles.vertex" {
  15289. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15290. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15291. /** @hidden */
  15292. export var particlesVertexShader: {
  15293. name: string;
  15294. shader: string;
  15295. };
  15296. }
  15297. declare module "babylonjs/Particles/particleSystem" {
  15298. import { Nullable } from "babylonjs/types";
  15299. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15300. import { Observable } from "babylonjs/Misc/observable";
  15301. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15302. import { Effect } from "babylonjs/Materials/effect";
  15303. import { Scene, IDisposable } from "babylonjs/scene";
  15304. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15305. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15306. import { Particle } from "babylonjs/Particles/particle";
  15307. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15308. import "babylonjs/Shaders/particles.fragment";
  15309. import "babylonjs/Shaders/particles.vertex";
  15310. /**
  15311. * This represents a particle system in Babylon.
  15312. * 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.
  15313. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15314. * @example https://doc.babylonjs.com/babylon101/particles
  15315. */
  15316. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15317. /**
  15318. * Billboard mode will only apply to Y axis
  15319. */
  15320. static readonly BILLBOARDMODE_Y: number;
  15321. /**
  15322. * Billboard mode will apply to all axes
  15323. */
  15324. static readonly BILLBOARDMODE_ALL: number;
  15325. /**
  15326. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15327. */
  15328. static readonly BILLBOARDMODE_STRETCHED: number;
  15329. /**
  15330. * This function can be defined to provide custom update for active particles.
  15331. * This function will be called instead of regular update (age, position, color, etc.).
  15332. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15333. */
  15334. updateFunction: (particles: Particle[]) => void;
  15335. private _emitterWorldMatrix;
  15336. /**
  15337. * This function can be defined to specify initial direction for every new particle.
  15338. * It by default use the emitterType defined function
  15339. */
  15340. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15341. /**
  15342. * This function can be defined to specify initial position for every new particle.
  15343. * It by default use the emitterType defined function
  15344. */
  15345. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15346. /**
  15347. * @hidden
  15348. */
  15349. _inheritedVelocityOffset: Vector3;
  15350. /**
  15351. * An event triggered when the system is disposed
  15352. */
  15353. onDisposeObservable: Observable<ParticleSystem>;
  15354. private _onDisposeObserver;
  15355. /**
  15356. * Sets a callback that will be triggered when the system is disposed
  15357. */
  15358. onDispose: () => void;
  15359. private _particles;
  15360. private _epsilon;
  15361. private _capacity;
  15362. private _stockParticles;
  15363. private _newPartsExcess;
  15364. private _vertexData;
  15365. private _vertexBuffer;
  15366. private _vertexBuffers;
  15367. private _spriteBuffer;
  15368. private _indexBuffer;
  15369. private _effect;
  15370. private _customEffect;
  15371. private _cachedDefines;
  15372. private _scaledColorStep;
  15373. private _colorDiff;
  15374. private _scaledDirection;
  15375. private _scaledGravity;
  15376. private _currentRenderId;
  15377. private _alive;
  15378. private _useInstancing;
  15379. private _started;
  15380. private _stopped;
  15381. private _actualFrame;
  15382. private _scaledUpdateSpeed;
  15383. private _vertexBufferSize;
  15384. /** @hidden */
  15385. _currentEmitRateGradient: Nullable<FactorGradient>;
  15386. /** @hidden */
  15387. _currentEmitRate1: number;
  15388. /** @hidden */
  15389. _currentEmitRate2: number;
  15390. /** @hidden */
  15391. _currentStartSizeGradient: Nullable<FactorGradient>;
  15392. /** @hidden */
  15393. _currentStartSize1: number;
  15394. /** @hidden */
  15395. _currentStartSize2: number;
  15396. private readonly _rawTextureWidth;
  15397. private _rampGradientsTexture;
  15398. private _useRampGradients;
  15399. /** Gets or sets a boolean indicating that ramp gradients must be used
  15400. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15401. */
  15402. useRampGradients: boolean;
  15403. /**
  15404. * 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.
  15405. * 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: [])
  15406. */
  15407. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15408. private _subEmitters;
  15409. /**
  15410. * @hidden
  15411. * If the particle systems emitter should be disposed when the particle system is disposed
  15412. */
  15413. _disposeEmitterOnDispose: boolean;
  15414. /**
  15415. * The current active Sub-systems, this property is used by the root particle system only.
  15416. */
  15417. activeSubSystems: Array<ParticleSystem>;
  15418. private _rootParticleSystem;
  15419. /**
  15420. * Gets the current list of active particles
  15421. */
  15422. readonly particles: Particle[];
  15423. /**
  15424. * Returns the string "ParticleSystem"
  15425. * @returns a string containing the class name
  15426. */
  15427. getClassName(): string;
  15428. /**
  15429. * Instantiates a particle system.
  15430. * 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.
  15431. * @param name The name of the particle system
  15432. * @param capacity The max number of particles alive at the same time
  15433. * @param scene The scene the particle system belongs to
  15434. * @param customEffect a custom effect used to change the way particles are rendered by default
  15435. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15436. * @param epsilon Offset used to render the particles
  15437. */
  15438. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15439. private _addFactorGradient;
  15440. private _removeFactorGradient;
  15441. /**
  15442. * Adds a new life time gradient
  15443. * @param gradient defines the gradient to use (between 0 and 1)
  15444. * @param factor defines the life time factor to affect to the specified gradient
  15445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15446. * @returns the current particle system
  15447. */
  15448. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15449. /**
  15450. * Remove a specific life time gradient
  15451. * @param gradient defines the gradient to remove
  15452. * @returns the current particle system
  15453. */
  15454. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15455. /**
  15456. * Adds a new size gradient
  15457. * @param gradient defines the gradient to use (between 0 and 1)
  15458. * @param factor defines the size factor to affect to the specified gradient
  15459. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15460. * @returns the current particle system
  15461. */
  15462. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15463. /**
  15464. * Remove a specific size gradient
  15465. * @param gradient defines the gradient to remove
  15466. * @returns the current particle system
  15467. */
  15468. removeSizeGradient(gradient: number): IParticleSystem;
  15469. /**
  15470. * Adds a new color remap gradient
  15471. * @param gradient defines the gradient to use (between 0 and 1)
  15472. * @param min defines the color remap minimal range
  15473. * @param max defines the color remap maximal range
  15474. * @returns the current particle system
  15475. */
  15476. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15477. /**
  15478. * Remove a specific color remap gradient
  15479. * @param gradient defines the gradient to remove
  15480. * @returns the current particle system
  15481. */
  15482. removeColorRemapGradient(gradient: number): IParticleSystem;
  15483. /**
  15484. * Adds a new alpha remap gradient
  15485. * @param gradient defines the gradient to use (between 0 and 1)
  15486. * @param min defines the alpha remap minimal range
  15487. * @param max defines the alpha remap maximal range
  15488. * @returns the current particle system
  15489. */
  15490. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15491. /**
  15492. * Remove a specific alpha remap gradient
  15493. * @param gradient defines the gradient to remove
  15494. * @returns the current particle system
  15495. */
  15496. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15497. /**
  15498. * Adds a new angular speed gradient
  15499. * @param gradient defines the gradient to use (between 0 and 1)
  15500. * @param factor defines the angular speed to affect to the specified gradient
  15501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15502. * @returns the current particle system
  15503. */
  15504. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15505. /**
  15506. * Remove a specific angular speed gradient
  15507. * @param gradient defines the gradient to remove
  15508. * @returns the current particle system
  15509. */
  15510. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15511. /**
  15512. * Adds a new velocity gradient
  15513. * @param gradient defines the gradient to use (between 0 and 1)
  15514. * @param factor defines the velocity to affect to the specified gradient
  15515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15516. * @returns the current particle system
  15517. */
  15518. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15519. /**
  15520. * Remove a specific velocity gradient
  15521. * @param gradient defines the gradient to remove
  15522. * @returns the current particle system
  15523. */
  15524. removeVelocityGradient(gradient: number): IParticleSystem;
  15525. /**
  15526. * Adds a new limit velocity gradient
  15527. * @param gradient defines the gradient to use (between 0 and 1)
  15528. * @param factor defines the limit velocity value to affect to the specified gradient
  15529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15530. * @returns the current particle system
  15531. */
  15532. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15533. /**
  15534. * Remove a specific limit velocity gradient
  15535. * @param gradient defines the gradient to remove
  15536. * @returns the current particle system
  15537. */
  15538. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15539. /**
  15540. * Adds a new drag gradient
  15541. * @param gradient defines the gradient to use (between 0 and 1)
  15542. * @param factor defines the drag value to affect to the specified gradient
  15543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15544. * @returns the current particle system
  15545. */
  15546. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15547. /**
  15548. * Remove a specific drag gradient
  15549. * @param gradient defines the gradient to remove
  15550. * @returns the current particle system
  15551. */
  15552. removeDragGradient(gradient: number): IParticleSystem;
  15553. /**
  15554. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15555. * @param gradient defines the gradient to use (between 0 and 1)
  15556. * @param factor defines the emit rate value to affect to the specified gradient
  15557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15558. * @returns the current particle system
  15559. */
  15560. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15561. /**
  15562. * Remove a specific emit rate gradient
  15563. * @param gradient defines the gradient to remove
  15564. * @returns the current particle system
  15565. */
  15566. removeEmitRateGradient(gradient: number): IParticleSystem;
  15567. /**
  15568. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15569. * @param gradient defines the gradient to use (between 0 and 1)
  15570. * @param factor defines the start size value to affect to the specified gradient
  15571. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15572. * @returns the current particle system
  15573. */
  15574. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15575. /**
  15576. * Remove a specific start size gradient
  15577. * @param gradient defines the gradient to remove
  15578. * @returns the current particle system
  15579. */
  15580. removeStartSizeGradient(gradient: number): IParticleSystem;
  15581. private _createRampGradientTexture;
  15582. /**
  15583. * Gets the current list of ramp gradients.
  15584. * You must use addRampGradient and removeRampGradient to udpate this list
  15585. * @returns the list of ramp gradients
  15586. */
  15587. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15588. /**
  15589. * Adds a new ramp gradient used to remap particle colors
  15590. * @param gradient defines the gradient to use (between 0 and 1)
  15591. * @param color defines the color to affect to the specified gradient
  15592. * @returns the current particle system
  15593. */
  15594. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15595. /**
  15596. * Remove a specific ramp gradient
  15597. * @param gradient defines the gradient to remove
  15598. * @returns the current particle system
  15599. */
  15600. removeRampGradient(gradient: number): ParticleSystem;
  15601. /**
  15602. * Adds a new color gradient
  15603. * @param gradient defines the gradient to use (between 0 and 1)
  15604. * @param color1 defines the color to affect to the specified gradient
  15605. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15606. * @returns this particle system
  15607. */
  15608. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15609. /**
  15610. * Remove a specific color gradient
  15611. * @param gradient defines the gradient to remove
  15612. * @returns this particle system
  15613. */
  15614. removeColorGradient(gradient: number): IParticleSystem;
  15615. private _fetchR;
  15616. protected _reset(): void;
  15617. private _resetEffect;
  15618. private _createVertexBuffers;
  15619. private _createIndexBuffer;
  15620. /**
  15621. * Gets the maximum number of particles active at the same time.
  15622. * @returns The max number of active particles.
  15623. */
  15624. getCapacity(): number;
  15625. /**
  15626. * Gets whether there are still active particles in the system.
  15627. * @returns True if it is alive, otherwise false.
  15628. */
  15629. isAlive(): boolean;
  15630. /**
  15631. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15632. * @returns True if it has been started, otherwise false.
  15633. */
  15634. isStarted(): boolean;
  15635. private _prepareSubEmitterInternalArray;
  15636. /**
  15637. * Starts the particle system and begins to emit
  15638. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15639. */
  15640. start(delay?: number): void;
  15641. /**
  15642. * Stops the particle system.
  15643. * @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.
  15644. */
  15645. stop(stopSubEmitters?: boolean): void;
  15646. /**
  15647. * Remove all active particles
  15648. */
  15649. reset(): void;
  15650. /**
  15651. * @hidden (for internal use only)
  15652. */
  15653. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15654. /**
  15655. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15656. * Its lifetime will start back at 0.
  15657. */
  15658. recycleParticle: (particle: Particle) => void;
  15659. private _stopSubEmitters;
  15660. private _createParticle;
  15661. private _removeFromRoot;
  15662. private _emitFromParticle;
  15663. private _update;
  15664. /** @hidden */
  15665. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15666. /** @hidden */
  15667. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15668. /** @hidden */
  15669. private _getEffect;
  15670. /**
  15671. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15672. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15673. */
  15674. animate(preWarmOnly?: boolean): void;
  15675. private _appendParticleVertices;
  15676. /**
  15677. * Rebuilds the particle system.
  15678. */
  15679. rebuild(): void;
  15680. /**
  15681. * Is this system ready to be used/rendered
  15682. * @return true if the system is ready
  15683. */
  15684. isReady(): boolean;
  15685. private _render;
  15686. /**
  15687. * Renders the particle system in its current state.
  15688. * @returns the current number of particles
  15689. */
  15690. render(): number;
  15691. /**
  15692. * Disposes the particle system and free the associated resources
  15693. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15694. */
  15695. dispose(disposeTexture?: boolean): void;
  15696. /**
  15697. * Clones the particle system.
  15698. * @param name The name of the cloned object
  15699. * @param newEmitter The new emitter to use
  15700. * @returns the cloned particle system
  15701. */
  15702. clone(name: string, newEmitter: any): ParticleSystem;
  15703. /**
  15704. * Serializes the particle system to a JSON object.
  15705. * @returns the JSON object
  15706. */
  15707. serialize(): any;
  15708. /** @hidden */
  15709. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15710. /** @hidden */
  15711. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15712. /**
  15713. * Parses a JSON object to create a particle system.
  15714. * @param parsedParticleSystem The JSON object to parse
  15715. * @param scene The scene to create the particle system in
  15716. * @param rootUrl The root url to use to load external dependencies like texture
  15717. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15718. * @returns the Parsed particle system
  15719. */
  15720. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15721. }
  15722. }
  15723. declare module "babylonjs/Particles/particle" {
  15724. import { Nullable } from "babylonjs/types";
  15725. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15726. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15727. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15728. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15729. /**
  15730. * A particle represents one of the element emitted by a particle system.
  15731. * This is mainly define by its coordinates, direction, velocity and age.
  15732. */
  15733. export class Particle {
  15734. /**
  15735. * The particle system the particle belongs to.
  15736. */
  15737. particleSystem: ParticleSystem;
  15738. private static _Count;
  15739. /**
  15740. * Unique ID of the particle
  15741. */
  15742. id: number;
  15743. /**
  15744. * The world position of the particle in the scene.
  15745. */
  15746. position: Vector3;
  15747. /**
  15748. * The world direction of the particle in the scene.
  15749. */
  15750. direction: Vector3;
  15751. /**
  15752. * The color of the particle.
  15753. */
  15754. color: Color4;
  15755. /**
  15756. * The color change of the particle per step.
  15757. */
  15758. colorStep: Color4;
  15759. /**
  15760. * Defines how long will the life of the particle be.
  15761. */
  15762. lifeTime: number;
  15763. /**
  15764. * The current age of the particle.
  15765. */
  15766. age: number;
  15767. /**
  15768. * The current size of the particle.
  15769. */
  15770. size: number;
  15771. /**
  15772. * The current scale of the particle.
  15773. */
  15774. scale: Vector2;
  15775. /**
  15776. * The current angle of the particle.
  15777. */
  15778. angle: number;
  15779. /**
  15780. * Defines how fast is the angle changing.
  15781. */
  15782. angularSpeed: number;
  15783. /**
  15784. * Defines the cell index used by the particle to be rendered from a sprite.
  15785. */
  15786. cellIndex: number;
  15787. /**
  15788. * The information required to support color remapping
  15789. */
  15790. remapData: Vector4;
  15791. /** @hidden */
  15792. _randomCellOffset?: number;
  15793. /** @hidden */
  15794. _initialDirection: Nullable<Vector3>;
  15795. /** @hidden */
  15796. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15797. /** @hidden */
  15798. _initialStartSpriteCellID: number;
  15799. /** @hidden */
  15800. _initialEndSpriteCellID: number;
  15801. /** @hidden */
  15802. _currentColorGradient: Nullable<ColorGradient>;
  15803. /** @hidden */
  15804. _currentColor1: Color4;
  15805. /** @hidden */
  15806. _currentColor2: Color4;
  15807. /** @hidden */
  15808. _currentSizeGradient: Nullable<FactorGradient>;
  15809. /** @hidden */
  15810. _currentSize1: number;
  15811. /** @hidden */
  15812. _currentSize2: number;
  15813. /** @hidden */
  15814. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15815. /** @hidden */
  15816. _currentAngularSpeed1: number;
  15817. /** @hidden */
  15818. _currentAngularSpeed2: number;
  15819. /** @hidden */
  15820. _currentVelocityGradient: Nullable<FactorGradient>;
  15821. /** @hidden */
  15822. _currentVelocity1: number;
  15823. /** @hidden */
  15824. _currentVelocity2: number;
  15825. /** @hidden */
  15826. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15827. /** @hidden */
  15828. _currentLimitVelocity1: number;
  15829. /** @hidden */
  15830. _currentLimitVelocity2: number;
  15831. /** @hidden */
  15832. _currentDragGradient: Nullable<FactorGradient>;
  15833. /** @hidden */
  15834. _currentDrag1: number;
  15835. /** @hidden */
  15836. _currentDrag2: number;
  15837. /** @hidden */
  15838. _randomNoiseCoordinates1: Vector3;
  15839. /** @hidden */
  15840. _randomNoiseCoordinates2: Vector3;
  15841. /**
  15842. * Creates a new instance Particle
  15843. * @param particleSystem the particle system the particle belongs to
  15844. */
  15845. constructor(
  15846. /**
  15847. * The particle system the particle belongs to.
  15848. */
  15849. particleSystem: ParticleSystem);
  15850. private updateCellInfoFromSystem;
  15851. /**
  15852. * Defines how the sprite cell index is updated for the particle
  15853. */
  15854. updateCellIndex(): void;
  15855. /** @hidden */
  15856. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15857. /** @hidden */
  15858. _inheritParticleInfoToSubEmitters(): void;
  15859. /** @hidden */
  15860. _reset(): void;
  15861. /**
  15862. * Copy the properties of particle to another one.
  15863. * @param other the particle to copy the information to.
  15864. */
  15865. copyTo(other: Particle): void;
  15866. }
  15867. }
  15868. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15869. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15870. import { Effect } from "babylonjs/Materials/effect";
  15871. import { Particle } from "babylonjs/Particles/particle";
  15872. /**
  15873. * Particle emitter represents a volume emitting particles.
  15874. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15875. */
  15876. export interface IParticleEmitterType {
  15877. /**
  15878. * Called by the particle System when the direction is computed for the created particle.
  15879. * @param worldMatrix is the world matrix of the particle system
  15880. * @param directionToUpdate is the direction vector to update with the result
  15881. * @param particle is the particle we are computed the direction for
  15882. */
  15883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15884. /**
  15885. * Called by the particle System when the position is computed for the created particle.
  15886. * @param worldMatrix is the world matrix of the particle system
  15887. * @param positionToUpdate is the position vector to update with the result
  15888. * @param particle is the particle we are computed the position for
  15889. */
  15890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15891. /**
  15892. * Clones the current emitter and returns a copy of it
  15893. * @returns the new emitter
  15894. */
  15895. clone(): IParticleEmitterType;
  15896. /**
  15897. * Called by the GPUParticleSystem to setup the update shader
  15898. * @param effect defines the update shader
  15899. */
  15900. applyToShader(effect: Effect): void;
  15901. /**
  15902. * Returns a string to use to update the GPU particles update shader
  15903. * @returns the effect defines string
  15904. */
  15905. getEffectDefines(): string;
  15906. /**
  15907. * Returns a string representing the class name
  15908. * @returns a string containing the class name
  15909. */
  15910. getClassName(): string;
  15911. /**
  15912. * Serializes the particle system to a JSON object.
  15913. * @returns the JSON object
  15914. */
  15915. serialize(): any;
  15916. /**
  15917. * Parse properties from a JSON object
  15918. * @param serializationObject defines the JSON object
  15919. */
  15920. parse(serializationObject: any): void;
  15921. }
  15922. }
  15923. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15924. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15925. import { Effect } from "babylonjs/Materials/effect";
  15926. import { Particle } from "babylonjs/Particles/particle";
  15927. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15928. /**
  15929. * Particle emitter emitting particles from the inside of a box.
  15930. * It emits the particles randomly between 2 given directions.
  15931. */
  15932. export class BoxParticleEmitter implements IParticleEmitterType {
  15933. /**
  15934. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15935. */
  15936. direction1: Vector3;
  15937. /**
  15938. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15939. */
  15940. direction2: Vector3;
  15941. /**
  15942. * 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.
  15943. */
  15944. minEmitBox: Vector3;
  15945. /**
  15946. * 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.
  15947. */
  15948. maxEmitBox: Vector3;
  15949. /**
  15950. * Creates a new instance BoxParticleEmitter
  15951. */
  15952. constructor();
  15953. /**
  15954. * Called by the particle System when the direction is computed for the created particle.
  15955. * @param worldMatrix is the world matrix of the particle system
  15956. * @param directionToUpdate is the direction vector to update with the result
  15957. * @param particle is the particle we are computed the direction for
  15958. */
  15959. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15960. /**
  15961. * Called by the particle System when the position is computed for the created particle.
  15962. * @param worldMatrix is the world matrix of the particle system
  15963. * @param positionToUpdate is the position vector to update with the result
  15964. * @param particle is the particle we are computed the position for
  15965. */
  15966. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15967. /**
  15968. * Clones the current emitter and returns a copy of it
  15969. * @returns the new emitter
  15970. */
  15971. clone(): BoxParticleEmitter;
  15972. /**
  15973. * Called by the GPUParticleSystem to setup the update shader
  15974. * @param effect defines the update shader
  15975. */
  15976. applyToShader(effect: Effect): void;
  15977. /**
  15978. * Returns a string to use to update the GPU particles update shader
  15979. * @returns a string containng the defines string
  15980. */
  15981. getEffectDefines(): string;
  15982. /**
  15983. * Returns the string "BoxParticleEmitter"
  15984. * @returns a string containing the class name
  15985. */
  15986. getClassName(): string;
  15987. /**
  15988. * Serializes the particle system to a JSON object.
  15989. * @returns the JSON object
  15990. */
  15991. serialize(): any;
  15992. /**
  15993. * Parse properties from a JSON object
  15994. * @param serializationObject defines the JSON object
  15995. */
  15996. parse(serializationObject: any): void;
  15997. }
  15998. }
  15999. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16000. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16001. import { Effect } from "babylonjs/Materials/effect";
  16002. import { Particle } from "babylonjs/Particles/particle";
  16003. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16004. /**
  16005. * Particle emitter emitting particles from the inside of a cone.
  16006. * It emits the particles alongside the cone volume from the base to the particle.
  16007. * The emission direction might be randomized.
  16008. */
  16009. export class ConeParticleEmitter implements IParticleEmitterType {
  16010. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16011. directionRandomizer: number;
  16012. private _radius;
  16013. private _angle;
  16014. private _height;
  16015. /**
  16016. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16017. */
  16018. radiusRange: number;
  16019. /**
  16020. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16021. */
  16022. heightRange: number;
  16023. /**
  16024. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16025. */
  16026. emitFromSpawnPointOnly: boolean;
  16027. /**
  16028. * Gets or sets the radius of the emission cone
  16029. */
  16030. radius: number;
  16031. /**
  16032. * Gets or sets the angle of the emission cone
  16033. */
  16034. angle: number;
  16035. private _buildHeight;
  16036. /**
  16037. * Creates a new instance ConeParticleEmitter
  16038. * @param radius the radius of the emission cone (1 by default)
  16039. * @param angle the cone base angle (PI by default)
  16040. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16041. */
  16042. constructor(radius?: number, angle?: number,
  16043. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16044. directionRandomizer?: number);
  16045. /**
  16046. * Called by the particle System when the direction is computed for the created particle.
  16047. * @param worldMatrix is the world matrix of the particle system
  16048. * @param directionToUpdate is the direction vector to update with the result
  16049. * @param particle is the particle we are computed the direction for
  16050. */
  16051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16052. /**
  16053. * Called by the particle System when the position is computed for the created particle.
  16054. * @param worldMatrix is the world matrix of the particle system
  16055. * @param positionToUpdate is the position vector to update with the result
  16056. * @param particle is the particle we are computed the position for
  16057. */
  16058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16059. /**
  16060. * Clones the current emitter and returns a copy of it
  16061. * @returns the new emitter
  16062. */
  16063. clone(): ConeParticleEmitter;
  16064. /**
  16065. * Called by the GPUParticleSystem to setup the update shader
  16066. * @param effect defines the update shader
  16067. */
  16068. applyToShader(effect: Effect): void;
  16069. /**
  16070. * Returns a string to use to update the GPU particles update shader
  16071. * @returns a string containng the defines string
  16072. */
  16073. getEffectDefines(): string;
  16074. /**
  16075. * Returns the string "ConeParticleEmitter"
  16076. * @returns a string containing the class name
  16077. */
  16078. getClassName(): string;
  16079. /**
  16080. * Serializes the particle system to a JSON object.
  16081. * @returns the JSON object
  16082. */
  16083. serialize(): any;
  16084. /**
  16085. * Parse properties from a JSON object
  16086. * @param serializationObject defines the JSON object
  16087. */
  16088. parse(serializationObject: any): void;
  16089. }
  16090. }
  16091. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16092. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16093. import { Effect } from "babylonjs/Materials/effect";
  16094. import { Particle } from "babylonjs/Particles/particle";
  16095. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16096. /**
  16097. * Particle emitter emitting particles from the inside of a cylinder.
  16098. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16099. */
  16100. export class CylinderParticleEmitter implements IParticleEmitterType {
  16101. /**
  16102. * The radius of the emission cylinder.
  16103. */
  16104. radius: number;
  16105. /**
  16106. * The height of the emission cylinder.
  16107. */
  16108. height: number;
  16109. /**
  16110. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16111. */
  16112. radiusRange: number;
  16113. /**
  16114. * How much to randomize the particle direction [0-1].
  16115. */
  16116. directionRandomizer: number;
  16117. /**
  16118. * Creates a new instance CylinderParticleEmitter
  16119. * @param radius the radius of the emission cylinder (1 by default)
  16120. * @param height the height of the emission cylinder (1 by default)
  16121. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16122. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16123. */
  16124. constructor(
  16125. /**
  16126. * The radius of the emission cylinder.
  16127. */
  16128. radius?: number,
  16129. /**
  16130. * The height of the emission cylinder.
  16131. */
  16132. height?: number,
  16133. /**
  16134. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16135. */
  16136. radiusRange?: number,
  16137. /**
  16138. * How much to randomize the particle direction [0-1].
  16139. */
  16140. directionRandomizer?: number);
  16141. /**
  16142. * Called by the particle System when the direction is computed for the created particle.
  16143. * @param worldMatrix is the world matrix of the particle system
  16144. * @param directionToUpdate is the direction vector to update with the result
  16145. * @param particle is the particle we are computed the direction for
  16146. */
  16147. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16148. /**
  16149. * Called by the particle System when the position is computed for the created particle.
  16150. * @param worldMatrix is the world matrix of the particle system
  16151. * @param positionToUpdate is the position vector to update with the result
  16152. * @param particle is the particle we are computed the position for
  16153. */
  16154. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16155. /**
  16156. * Clones the current emitter and returns a copy of it
  16157. * @returns the new emitter
  16158. */
  16159. clone(): CylinderParticleEmitter;
  16160. /**
  16161. * Called by the GPUParticleSystem to setup the update shader
  16162. * @param effect defines the update shader
  16163. */
  16164. applyToShader(effect: Effect): void;
  16165. /**
  16166. * Returns a string to use to update the GPU particles update shader
  16167. * @returns a string containng the defines string
  16168. */
  16169. getEffectDefines(): string;
  16170. /**
  16171. * Returns the string "CylinderParticleEmitter"
  16172. * @returns a string containing the class name
  16173. */
  16174. getClassName(): string;
  16175. /**
  16176. * Serializes the particle system to a JSON object.
  16177. * @returns the JSON object
  16178. */
  16179. serialize(): any;
  16180. /**
  16181. * Parse properties from a JSON object
  16182. * @param serializationObject defines the JSON object
  16183. */
  16184. parse(serializationObject: any): void;
  16185. }
  16186. /**
  16187. * Particle emitter emitting particles from the inside of a cylinder.
  16188. * It emits the particles randomly between two vectors.
  16189. */
  16190. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16191. /**
  16192. * The min limit of the emission direction.
  16193. */
  16194. direction1: Vector3;
  16195. /**
  16196. * The max limit of the emission direction.
  16197. */
  16198. direction2: Vector3;
  16199. /**
  16200. * Creates a new instance CylinderDirectedParticleEmitter
  16201. * @param radius the radius of the emission cylinder (1 by default)
  16202. * @param height the height of the emission cylinder (1 by default)
  16203. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16204. * @param direction1 the min limit of the emission direction (up vector by default)
  16205. * @param direction2 the max limit of the emission direction (up vector by default)
  16206. */
  16207. constructor(radius?: number, height?: number, radiusRange?: number,
  16208. /**
  16209. * The min limit of the emission direction.
  16210. */
  16211. direction1?: Vector3,
  16212. /**
  16213. * The max limit of the emission direction.
  16214. */
  16215. direction2?: Vector3);
  16216. /**
  16217. * Called by the particle System when the direction is computed for the created particle.
  16218. * @param worldMatrix is the world matrix of the particle system
  16219. * @param directionToUpdate is the direction vector to update with the result
  16220. * @param particle is the particle we are computed the direction for
  16221. */
  16222. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16223. /**
  16224. * Clones the current emitter and returns a copy of it
  16225. * @returns the new emitter
  16226. */
  16227. clone(): CylinderDirectedParticleEmitter;
  16228. /**
  16229. * Called by the GPUParticleSystem to setup the update shader
  16230. * @param effect defines the update shader
  16231. */
  16232. applyToShader(effect: Effect): void;
  16233. /**
  16234. * Returns a string to use to update the GPU particles update shader
  16235. * @returns a string containng the defines string
  16236. */
  16237. getEffectDefines(): string;
  16238. /**
  16239. * Returns the string "CylinderDirectedParticleEmitter"
  16240. * @returns a string containing the class name
  16241. */
  16242. getClassName(): string;
  16243. /**
  16244. * Serializes the particle system to a JSON object.
  16245. * @returns the JSON object
  16246. */
  16247. serialize(): any;
  16248. /**
  16249. * Parse properties from a JSON object
  16250. * @param serializationObject defines the JSON object
  16251. */
  16252. parse(serializationObject: any): void;
  16253. }
  16254. }
  16255. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16256. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16257. import { Effect } from "babylonjs/Materials/effect";
  16258. import { Particle } from "babylonjs/Particles/particle";
  16259. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16260. /**
  16261. * Particle emitter emitting particles from the inside of a hemisphere.
  16262. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16263. */
  16264. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16265. /**
  16266. * The radius of the emission hemisphere.
  16267. */
  16268. radius: number;
  16269. /**
  16270. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16271. */
  16272. radiusRange: number;
  16273. /**
  16274. * How much to randomize the particle direction [0-1].
  16275. */
  16276. directionRandomizer: number;
  16277. /**
  16278. * Creates a new instance HemisphericParticleEmitter
  16279. * @param radius the radius of the emission hemisphere (1 by default)
  16280. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16281. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16282. */
  16283. constructor(
  16284. /**
  16285. * The radius of the emission hemisphere.
  16286. */
  16287. radius?: number,
  16288. /**
  16289. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16290. */
  16291. radiusRange?: number,
  16292. /**
  16293. * How much to randomize the particle direction [0-1].
  16294. */
  16295. directionRandomizer?: number);
  16296. /**
  16297. * Called by the particle System when the direction is computed for the created particle.
  16298. * @param worldMatrix is the world matrix of the particle system
  16299. * @param directionToUpdate is the direction vector to update with the result
  16300. * @param particle is the particle we are computed the direction for
  16301. */
  16302. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16303. /**
  16304. * Called by the particle System when the position is computed for the created particle.
  16305. * @param worldMatrix is the world matrix of the particle system
  16306. * @param positionToUpdate is the position vector to update with the result
  16307. * @param particle is the particle we are computed the position for
  16308. */
  16309. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16310. /**
  16311. * Clones the current emitter and returns a copy of it
  16312. * @returns the new emitter
  16313. */
  16314. clone(): HemisphericParticleEmitter;
  16315. /**
  16316. * Called by the GPUParticleSystem to setup the update shader
  16317. * @param effect defines the update shader
  16318. */
  16319. applyToShader(effect: Effect): void;
  16320. /**
  16321. * Returns a string to use to update the GPU particles update shader
  16322. * @returns a string containng the defines string
  16323. */
  16324. getEffectDefines(): string;
  16325. /**
  16326. * Returns the string "HemisphericParticleEmitter"
  16327. * @returns a string containing the class name
  16328. */
  16329. getClassName(): string;
  16330. /**
  16331. * Serializes the particle system to a JSON object.
  16332. * @returns the JSON object
  16333. */
  16334. serialize(): any;
  16335. /**
  16336. * Parse properties from a JSON object
  16337. * @param serializationObject defines the JSON object
  16338. */
  16339. parse(serializationObject: any): void;
  16340. }
  16341. }
  16342. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16343. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16344. import { Effect } from "babylonjs/Materials/effect";
  16345. import { Particle } from "babylonjs/Particles/particle";
  16346. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16347. /**
  16348. * Particle emitter emitting particles from a point.
  16349. * It emits the particles randomly between 2 given directions.
  16350. */
  16351. export class PointParticleEmitter implements IParticleEmitterType {
  16352. /**
  16353. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16354. */
  16355. direction1: Vector3;
  16356. /**
  16357. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16358. */
  16359. direction2: Vector3;
  16360. /**
  16361. * Creates a new instance PointParticleEmitter
  16362. */
  16363. constructor();
  16364. /**
  16365. * Called by the particle System when the direction is computed for the created particle.
  16366. * @param worldMatrix is the world matrix of the particle system
  16367. * @param directionToUpdate is the direction vector to update with the result
  16368. * @param particle is the particle we are computed the direction for
  16369. */
  16370. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16371. /**
  16372. * Called by the particle System when the position is computed for the created particle.
  16373. * @param worldMatrix is the world matrix of the particle system
  16374. * @param positionToUpdate is the position vector to update with the result
  16375. * @param particle is the particle we are computed the position for
  16376. */
  16377. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16378. /**
  16379. * Clones the current emitter and returns a copy of it
  16380. * @returns the new emitter
  16381. */
  16382. clone(): PointParticleEmitter;
  16383. /**
  16384. * Called by the GPUParticleSystem to setup the update shader
  16385. * @param effect defines the update shader
  16386. */
  16387. applyToShader(effect: Effect): void;
  16388. /**
  16389. * Returns a string to use to update the GPU particles update shader
  16390. * @returns a string containng the defines string
  16391. */
  16392. getEffectDefines(): string;
  16393. /**
  16394. * Returns the string "PointParticleEmitter"
  16395. * @returns a string containing the class name
  16396. */
  16397. getClassName(): string;
  16398. /**
  16399. * Serializes the particle system to a JSON object.
  16400. * @returns the JSON object
  16401. */
  16402. serialize(): any;
  16403. /**
  16404. * Parse properties from a JSON object
  16405. * @param serializationObject defines the JSON object
  16406. */
  16407. parse(serializationObject: any): void;
  16408. }
  16409. }
  16410. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16411. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16412. import { Effect } from "babylonjs/Materials/effect";
  16413. import { Particle } from "babylonjs/Particles/particle";
  16414. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16415. /**
  16416. * Particle emitter emitting particles from the inside of a sphere.
  16417. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16418. */
  16419. export class SphereParticleEmitter implements IParticleEmitterType {
  16420. /**
  16421. * The radius of the emission sphere.
  16422. */
  16423. radius: number;
  16424. /**
  16425. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16426. */
  16427. radiusRange: number;
  16428. /**
  16429. * How much to randomize the particle direction [0-1].
  16430. */
  16431. directionRandomizer: number;
  16432. /**
  16433. * Creates a new instance SphereParticleEmitter
  16434. * @param radius the radius of the emission sphere (1 by default)
  16435. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16436. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16437. */
  16438. constructor(
  16439. /**
  16440. * The radius of the emission sphere.
  16441. */
  16442. radius?: number,
  16443. /**
  16444. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16445. */
  16446. radiusRange?: number,
  16447. /**
  16448. * How much to randomize the particle direction [0-1].
  16449. */
  16450. directionRandomizer?: number);
  16451. /**
  16452. * Called by the particle System when the direction is computed for the created particle.
  16453. * @param worldMatrix is the world matrix of the particle system
  16454. * @param directionToUpdate is the direction vector to update with the result
  16455. * @param particle is the particle we are computed the direction for
  16456. */
  16457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16458. /**
  16459. * Called by the particle System when the position is computed for the created particle.
  16460. * @param worldMatrix is the world matrix of the particle system
  16461. * @param positionToUpdate is the position vector to update with the result
  16462. * @param particle is the particle we are computed the position for
  16463. */
  16464. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16465. /**
  16466. * Clones the current emitter and returns a copy of it
  16467. * @returns the new emitter
  16468. */
  16469. clone(): SphereParticleEmitter;
  16470. /**
  16471. * Called by the GPUParticleSystem to setup the update shader
  16472. * @param effect defines the update shader
  16473. */
  16474. applyToShader(effect: Effect): void;
  16475. /**
  16476. * Returns a string to use to update the GPU particles update shader
  16477. * @returns a string containng the defines string
  16478. */
  16479. getEffectDefines(): string;
  16480. /**
  16481. * Returns the string "SphereParticleEmitter"
  16482. * @returns a string containing the class name
  16483. */
  16484. getClassName(): string;
  16485. /**
  16486. * Serializes the particle system to a JSON object.
  16487. * @returns the JSON object
  16488. */
  16489. serialize(): any;
  16490. /**
  16491. * Parse properties from a JSON object
  16492. * @param serializationObject defines the JSON object
  16493. */
  16494. parse(serializationObject: any): void;
  16495. }
  16496. /**
  16497. * Particle emitter emitting particles from the inside of a sphere.
  16498. * It emits the particles randomly between two vectors.
  16499. */
  16500. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16501. /**
  16502. * The min limit of the emission direction.
  16503. */
  16504. direction1: Vector3;
  16505. /**
  16506. * The max limit of the emission direction.
  16507. */
  16508. direction2: Vector3;
  16509. /**
  16510. * Creates a new instance SphereDirectedParticleEmitter
  16511. * @param radius the radius of the emission sphere (1 by default)
  16512. * @param direction1 the min limit of the emission direction (up vector by default)
  16513. * @param direction2 the max limit of the emission direction (up vector by default)
  16514. */
  16515. constructor(radius?: number,
  16516. /**
  16517. * The min limit of the emission direction.
  16518. */
  16519. direction1?: Vector3,
  16520. /**
  16521. * The max limit of the emission direction.
  16522. */
  16523. direction2?: Vector3);
  16524. /**
  16525. * Called by the particle System when the direction is computed for the created particle.
  16526. * @param worldMatrix is the world matrix of the particle system
  16527. * @param directionToUpdate is the direction vector to update with the result
  16528. * @param particle is the particle we are computed the direction for
  16529. */
  16530. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16531. /**
  16532. * Clones the current emitter and returns a copy of it
  16533. * @returns the new emitter
  16534. */
  16535. clone(): SphereDirectedParticleEmitter;
  16536. /**
  16537. * Called by the GPUParticleSystem to setup the update shader
  16538. * @param effect defines the update shader
  16539. */
  16540. applyToShader(effect: Effect): void;
  16541. /**
  16542. * Returns a string to use to update the GPU particles update shader
  16543. * @returns a string containng the defines string
  16544. */
  16545. getEffectDefines(): string;
  16546. /**
  16547. * Returns the string "SphereDirectedParticleEmitter"
  16548. * @returns a string containing the class name
  16549. */
  16550. getClassName(): string;
  16551. /**
  16552. * Serializes the particle system to a JSON object.
  16553. * @returns the JSON object
  16554. */
  16555. serialize(): any;
  16556. /**
  16557. * Parse properties from a JSON object
  16558. * @param serializationObject defines the JSON object
  16559. */
  16560. parse(serializationObject: any): void;
  16561. }
  16562. }
  16563. declare module "babylonjs/Particles/EmitterTypes/index" {
  16564. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16565. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16566. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16567. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16568. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16569. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16570. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16571. }
  16572. declare module "babylonjs/Particles/IParticleSystem" {
  16573. import { Nullable } from "babylonjs/types";
  16574. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16577. import { Texture } from "babylonjs/Materials/Textures/texture";
  16578. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16579. import { Scene } from "babylonjs/scene";
  16580. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16581. import { Animation } from "babylonjs/Animations/animation";
  16582. /**
  16583. * Interface representing a particle system in Babylon.js.
  16584. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16585. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16586. */
  16587. export interface IParticleSystem {
  16588. /**
  16589. * List of animations used by the particle system.
  16590. */
  16591. animations: Animation[];
  16592. /**
  16593. * The id of the Particle system.
  16594. */
  16595. id: string;
  16596. /**
  16597. * The name of the Particle system.
  16598. */
  16599. name: string;
  16600. /**
  16601. * The emitter represents the Mesh or position we are attaching the particle system to.
  16602. */
  16603. emitter: Nullable<AbstractMesh | Vector3>;
  16604. /**
  16605. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16606. */
  16607. isBillboardBased: boolean;
  16608. /**
  16609. * The rendering group used by the Particle system to chose when to render.
  16610. */
  16611. renderingGroupId: number;
  16612. /**
  16613. * The layer mask we are rendering the particles through.
  16614. */
  16615. layerMask: number;
  16616. /**
  16617. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16618. */
  16619. updateSpeed: number;
  16620. /**
  16621. * The amount of time the particle system is running (depends of the overall update speed).
  16622. */
  16623. targetStopDuration: number;
  16624. /**
  16625. * The texture used to render each particle. (this can be a spritesheet)
  16626. */
  16627. particleTexture: Nullable<Texture>;
  16628. /**
  16629. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16630. */
  16631. blendMode: number;
  16632. /**
  16633. * Minimum life time of emitting particles.
  16634. */
  16635. minLifeTime: number;
  16636. /**
  16637. * Maximum life time of emitting particles.
  16638. */
  16639. maxLifeTime: number;
  16640. /**
  16641. * Minimum Size of emitting particles.
  16642. */
  16643. minSize: number;
  16644. /**
  16645. * Maximum Size of emitting particles.
  16646. */
  16647. maxSize: number;
  16648. /**
  16649. * Minimum scale of emitting particles on X axis.
  16650. */
  16651. minScaleX: number;
  16652. /**
  16653. * Maximum scale of emitting particles on X axis.
  16654. */
  16655. maxScaleX: number;
  16656. /**
  16657. * Minimum scale of emitting particles on Y axis.
  16658. */
  16659. minScaleY: number;
  16660. /**
  16661. * Maximum scale of emitting particles on Y axis.
  16662. */
  16663. maxScaleY: number;
  16664. /**
  16665. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16666. */
  16667. color1: Color4;
  16668. /**
  16669. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16670. */
  16671. color2: Color4;
  16672. /**
  16673. * Color the particle will have at the end of its lifetime.
  16674. */
  16675. colorDead: Color4;
  16676. /**
  16677. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16678. */
  16679. emitRate: number;
  16680. /**
  16681. * You can use gravity if you want to give an orientation to your particles.
  16682. */
  16683. gravity: Vector3;
  16684. /**
  16685. * Minimum power of emitting particles.
  16686. */
  16687. minEmitPower: number;
  16688. /**
  16689. * Maximum power of emitting particles.
  16690. */
  16691. maxEmitPower: number;
  16692. /**
  16693. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16694. */
  16695. minAngularSpeed: number;
  16696. /**
  16697. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16698. */
  16699. maxAngularSpeed: number;
  16700. /**
  16701. * Gets or sets the minimal initial rotation in radians.
  16702. */
  16703. minInitialRotation: number;
  16704. /**
  16705. * Gets or sets the maximal initial rotation in radians.
  16706. */
  16707. maxInitialRotation: number;
  16708. /**
  16709. * The particle emitter type defines the emitter used by the particle system.
  16710. * It can be for example box, sphere, or cone...
  16711. */
  16712. particleEmitterType: Nullable<IParticleEmitterType>;
  16713. /**
  16714. * Defines the delay in milliseconds before starting the system (0 by default)
  16715. */
  16716. startDelay: number;
  16717. /**
  16718. * 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
  16719. */
  16720. preWarmCycles: number;
  16721. /**
  16722. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16723. */
  16724. preWarmStepOffset: number;
  16725. /**
  16726. * 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)
  16727. */
  16728. spriteCellChangeSpeed: number;
  16729. /**
  16730. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16731. */
  16732. startSpriteCellID: number;
  16733. /**
  16734. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16735. */
  16736. endSpriteCellID: number;
  16737. /**
  16738. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16739. */
  16740. spriteCellWidth: number;
  16741. /**
  16742. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16743. */
  16744. spriteCellHeight: number;
  16745. /**
  16746. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16747. */
  16748. spriteRandomStartCell: boolean;
  16749. /**
  16750. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16751. */
  16752. isAnimationSheetEnabled: boolean;
  16753. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16754. translationPivot: Vector2;
  16755. /**
  16756. * Gets or sets a texture used to add random noise to particle positions
  16757. */
  16758. noiseTexture: Nullable<BaseTexture>;
  16759. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16760. noiseStrength: Vector3;
  16761. /**
  16762. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16763. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16764. */
  16765. billboardMode: number;
  16766. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16767. limitVelocityDamping: number;
  16768. /**
  16769. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16770. */
  16771. beginAnimationOnStart: boolean;
  16772. /**
  16773. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16774. */
  16775. beginAnimationFrom: number;
  16776. /**
  16777. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16778. */
  16779. beginAnimationTo: number;
  16780. /**
  16781. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16782. */
  16783. beginAnimationLoop: boolean;
  16784. /**
  16785. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16786. */
  16787. disposeOnStop: boolean;
  16788. /**
  16789. * Gets the maximum number of particles active at the same time.
  16790. * @returns The max number of active particles.
  16791. */
  16792. getCapacity(): number;
  16793. /**
  16794. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16795. * @returns True if it has been started, otherwise false.
  16796. */
  16797. isStarted(): boolean;
  16798. /**
  16799. * Animates the particle system for this frame.
  16800. */
  16801. animate(): void;
  16802. /**
  16803. * Renders the particle system in its current state.
  16804. * @returns the current number of particles
  16805. */
  16806. render(): number;
  16807. /**
  16808. * Dispose the particle system and frees its associated resources.
  16809. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16810. */
  16811. dispose(disposeTexture?: boolean): void;
  16812. /**
  16813. * Clones the particle system.
  16814. * @param name The name of the cloned object
  16815. * @param newEmitter The new emitter to use
  16816. * @returns the cloned particle system
  16817. */
  16818. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16819. /**
  16820. * Serializes the particle system to a JSON object.
  16821. * @returns the JSON object
  16822. */
  16823. serialize(): any;
  16824. /**
  16825. * Rebuild the particle system
  16826. */
  16827. rebuild(): void;
  16828. /**
  16829. * Starts the particle system and begins to emit
  16830. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16831. */
  16832. start(delay?: number): void;
  16833. /**
  16834. * Stops the particle system.
  16835. */
  16836. stop(): void;
  16837. /**
  16838. * Remove all active particles
  16839. */
  16840. reset(): void;
  16841. /**
  16842. * Is this system ready to be used/rendered
  16843. * @return true if the system is ready
  16844. */
  16845. isReady(): boolean;
  16846. /**
  16847. * Adds a new color gradient
  16848. * @param gradient defines the gradient to use (between 0 and 1)
  16849. * @param color1 defines the color to affect to the specified gradient
  16850. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16851. * @returns the current particle system
  16852. */
  16853. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16854. /**
  16855. * Remove a specific color gradient
  16856. * @param gradient defines the gradient to remove
  16857. * @returns the current particle system
  16858. */
  16859. removeColorGradient(gradient: number): IParticleSystem;
  16860. /**
  16861. * Adds a new size gradient
  16862. * @param gradient defines the gradient to use (between 0 and 1)
  16863. * @param factor defines the size factor to affect to the specified gradient
  16864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16865. * @returns the current particle system
  16866. */
  16867. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16868. /**
  16869. * Remove a specific size gradient
  16870. * @param gradient defines the gradient to remove
  16871. * @returns the current particle system
  16872. */
  16873. removeSizeGradient(gradient: number): IParticleSystem;
  16874. /**
  16875. * Gets the current list of color gradients.
  16876. * You must use addColorGradient and removeColorGradient to udpate this list
  16877. * @returns the list of color gradients
  16878. */
  16879. getColorGradients(): Nullable<Array<ColorGradient>>;
  16880. /**
  16881. * Gets the current list of size gradients.
  16882. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16883. * @returns the list of size gradients
  16884. */
  16885. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16886. /**
  16887. * Gets the current list of angular speed gradients.
  16888. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16889. * @returns the list of angular speed gradients
  16890. */
  16891. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16892. /**
  16893. * Adds a new angular speed gradient
  16894. * @param gradient defines the gradient to use (between 0 and 1)
  16895. * @param factor defines the angular speed to affect to the specified gradient
  16896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16897. * @returns the current particle system
  16898. */
  16899. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16900. /**
  16901. * Remove a specific angular speed gradient
  16902. * @param gradient defines the gradient to remove
  16903. * @returns the current particle system
  16904. */
  16905. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16906. /**
  16907. * Gets the current list of velocity gradients.
  16908. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16909. * @returns the list of velocity gradients
  16910. */
  16911. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16912. /**
  16913. * Adds a new velocity gradient
  16914. * @param gradient defines the gradient to use (between 0 and 1)
  16915. * @param factor defines the velocity to affect to the specified gradient
  16916. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16917. * @returns the current particle system
  16918. */
  16919. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16920. /**
  16921. * Remove a specific velocity gradient
  16922. * @param gradient defines the gradient to remove
  16923. * @returns the current particle system
  16924. */
  16925. removeVelocityGradient(gradient: number): IParticleSystem;
  16926. /**
  16927. * Gets the current list of limit velocity gradients.
  16928. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16929. * @returns the list of limit velocity gradients
  16930. */
  16931. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16932. /**
  16933. * Adds a new limit velocity gradient
  16934. * @param gradient defines the gradient to use (between 0 and 1)
  16935. * @param factor defines the limit velocity to affect to the specified gradient
  16936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16937. * @returns the current particle system
  16938. */
  16939. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16940. /**
  16941. * Remove a specific limit velocity gradient
  16942. * @param gradient defines the gradient to remove
  16943. * @returns the current particle system
  16944. */
  16945. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16946. /**
  16947. * Adds a new drag gradient
  16948. * @param gradient defines the gradient to use (between 0 and 1)
  16949. * @param factor defines the drag to affect to the specified gradient
  16950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16951. * @returns the current particle system
  16952. */
  16953. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16954. /**
  16955. * Remove a specific drag gradient
  16956. * @param gradient defines the gradient to remove
  16957. * @returns the current particle system
  16958. */
  16959. removeDragGradient(gradient: number): IParticleSystem;
  16960. /**
  16961. * Gets the current list of drag gradients.
  16962. * You must use addDragGradient and removeDragGradient to udpate this list
  16963. * @returns the list of drag gradients
  16964. */
  16965. getDragGradients(): Nullable<Array<FactorGradient>>;
  16966. /**
  16967. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16968. * @param gradient defines the gradient to use (between 0 and 1)
  16969. * @param factor defines the emit rate to affect to the specified gradient
  16970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16971. * @returns the current particle system
  16972. */
  16973. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16974. /**
  16975. * Remove a specific emit rate gradient
  16976. * @param gradient defines the gradient to remove
  16977. * @returns the current particle system
  16978. */
  16979. removeEmitRateGradient(gradient: number): IParticleSystem;
  16980. /**
  16981. * Gets the current list of emit rate gradients.
  16982. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16983. * @returns the list of emit rate gradients
  16984. */
  16985. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16986. /**
  16987. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16988. * @param gradient defines the gradient to use (between 0 and 1)
  16989. * @param factor defines the start size to affect to the specified gradient
  16990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16991. * @returns the current particle system
  16992. */
  16993. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16994. /**
  16995. * Remove a specific start size gradient
  16996. * @param gradient defines the gradient to remove
  16997. * @returns the current particle system
  16998. */
  16999. removeStartSizeGradient(gradient: number): IParticleSystem;
  17000. /**
  17001. * Gets the current list of start size gradients.
  17002. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17003. * @returns the list of start size gradients
  17004. */
  17005. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17006. /**
  17007. * Adds a new life time gradient
  17008. * @param gradient defines the gradient to use (between 0 and 1)
  17009. * @param factor defines the life time factor to affect to the specified gradient
  17010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17011. * @returns the current particle system
  17012. */
  17013. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17014. /**
  17015. * Remove a specific life time gradient
  17016. * @param gradient defines the gradient to remove
  17017. * @returns the current particle system
  17018. */
  17019. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17020. /**
  17021. * Gets the current list of life time gradients.
  17022. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17023. * @returns the list of life time gradients
  17024. */
  17025. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17026. /**
  17027. * Gets the current list of color gradients.
  17028. * You must use addColorGradient and removeColorGradient to udpate this list
  17029. * @returns the list of color gradients
  17030. */
  17031. getColorGradients(): Nullable<Array<ColorGradient>>;
  17032. /**
  17033. * Adds a new ramp gradient used to remap particle colors
  17034. * @param gradient defines the gradient to use (between 0 and 1)
  17035. * @param color defines the color to affect to the specified gradient
  17036. * @returns the current particle system
  17037. */
  17038. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17039. /**
  17040. * Gets the current list of ramp gradients.
  17041. * You must use addRampGradient and removeRampGradient to udpate this list
  17042. * @returns the list of ramp gradients
  17043. */
  17044. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17045. /** Gets or sets a boolean indicating that ramp gradients must be used
  17046. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17047. */
  17048. useRampGradients: boolean;
  17049. /**
  17050. * Adds a new color remap gradient
  17051. * @param gradient defines the gradient to use (between 0 and 1)
  17052. * @param min defines the color remap minimal range
  17053. * @param max defines the color remap maximal range
  17054. * @returns the current particle system
  17055. */
  17056. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17057. /**
  17058. * Gets the current list of color remap gradients.
  17059. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17060. * @returns the list of color remap gradients
  17061. */
  17062. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17063. /**
  17064. * Adds a new alpha remap gradient
  17065. * @param gradient defines the gradient to use (between 0 and 1)
  17066. * @param min defines the alpha remap minimal range
  17067. * @param max defines the alpha remap maximal range
  17068. * @returns the current particle system
  17069. */
  17070. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17071. /**
  17072. * Gets the current list of alpha remap gradients.
  17073. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17074. * @returns the list of alpha remap gradients
  17075. */
  17076. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17077. /**
  17078. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17079. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17080. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @returns the emitter
  17082. */
  17083. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17084. /**
  17085. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17086. * @param radius The radius of the hemisphere to emit from
  17087. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17088. * @returns the emitter
  17089. */
  17090. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17091. /**
  17092. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17093. * @param radius The radius of the sphere to emit from
  17094. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17095. * @returns the emitter
  17096. */
  17097. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17098. /**
  17099. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17100. * @param radius The radius of the sphere to emit from
  17101. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17102. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17103. * @returns the emitter
  17104. */
  17105. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17106. /**
  17107. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17108. * @param radius The radius of the emission cylinder
  17109. * @param height The height of the emission cylinder
  17110. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17111. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17112. * @returns the emitter
  17113. */
  17114. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17115. /**
  17116. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17117. * @param radius The radius of the cylinder to emit from
  17118. * @param height The height of the emission cylinder
  17119. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17120. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17121. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17122. * @returns the emitter
  17123. */
  17124. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17125. /**
  17126. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17127. * @param radius The radius of the cone to emit from
  17128. * @param angle The base angle of the cone
  17129. * @returns the emitter
  17130. */
  17131. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17132. /**
  17133. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17134. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17135. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17136. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17137. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17138. * @returns the emitter
  17139. */
  17140. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17141. /**
  17142. * Get hosting scene
  17143. * @returns the scene
  17144. */
  17145. getScene(): Scene;
  17146. }
  17147. }
  17148. declare module "babylonjs/Meshes/instancedMesh" {
  17149. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17150. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17151. import { Camera } from "babylonjs/Cameras/camera";
  17152. import { Node } from "babylonjs/node";
  17153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17154. import { Mesh } from "babylonjs/Meshes/mesh";
  17155. import { Material } from "babylonjs/Materials/material";
  17156. import { Skeleton } from "babylonjs/Bones/skeleton";
  17157. import { Light } from "babylonjs/Lights/light";
  17158. /**
  17159. * Creates an instance based on a source mesh.
  17160. */
  17161. export class InstancedMesh extends AbstractMesh {
  17162. private _sourceMesh;
  17163. private _currentLOD;
  17164. /** @hidden */
  17165. _indexInSourceMeshInstanceArray: number;
  17166. constructor(name: string, source: Mesh);
  17167. /**
  17168. * Returns the string "InstancedMesh".
  17169. */
  17170. getClassName(): string;
  17171. /** Gets the list of lights affecting that mesh */
  17172. readonly lightSources: Light[];
  17173. _resyncLightSources(): void;
  17174. _resyncLighSource(light: Light): void;
  17175. _removeLightSource(light: Light): void;
  17176. /**
  17177. * If the source mesh receives shadows
  17178. */
  17179. readonly receiveShadows: boolean;
  17180. /**
  17181. * The material of the source mesh
  17182. */
  17183. readonly material: Nullable<Material>;
  17184. /**
  17185. * Visibility of the source mesh
  17186. */
  17187. readonly visibility: number;
  17188. /**
  17189. * Skeleton of the source mesh
  17190. */
  17191. readonly skeleton: Nullable<Skeleton>;
  17192. /**
  17193. * Rendering ground id of the source mesh
  17194. */
  17195. renderingGroupId: number;
  17196. /**
  17197. * Returns the total number of vertices (integer).
  17198. */
  17199. getTotalVertices(): number;
  17200. /**
  17201. * Returns a positive integer : the total number of indices in this mesh geometry.
  17202. * @returns the numner of indices or zero if the mesh has no geometry.
  17203. */
  17204. getTotalIndices(): number;
  17205. /**
  17206. * The source mesh of the instance
  17207. */
  17208. readonly sourceMesh: Mesh;
  17209. /**
  17210. * Is this node ready to be used/rendered
  17211. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17212. * @return {boolean} is it ready
  17213. */
  17214. isReady(completeCheck?: boolean): boolean;
  17215. /**
  17216. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17217. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17218. * @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.
  17219. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17220. */
  17221. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17222. /**
  17223. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17224. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17225. * The `data` are either a numeric array either a Float32Array.
  17226. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17227. * 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).
  17228. * Note that a new underlying VertexBuffer object is created each call.
  17229. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17230. *
  17231. * Possible `kind` values :
  17232. * - VertexBuffer.PositionKind
  17233. * - VertexBuffer.UVKind
  17234. * - VertexBuffer.UV2Kind
  17235. * - VertexBuffer.UV3Kind
  17236. * - VertexBuffer.UV4Kind
  17237. * - VertexBuffer.UV5Kind
  17238. * - VertexBuffer.UV6Kind
  17239. * - VertexBuffer.ColorKind
  17240. * - VertexBuffer.MatricesIndicesKind
  17241. * - VertexBuffer.MatricesIndicesExtraKind
  17242. * - VertexBuffer.MatricesWeightsKind
  17243. * - VertexBuffer.MatricesWeightsExtraKind
  17244. *
  17245. * Returns the Mesh.
  17246. */
  17247. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17248. /**
  17249. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17250. * If the mesh has no geometry, it is simply returned as it is.
  17251. * The `data` are either a numeric array either a Float32Array.
  17252. * No new underlying VertexBuffer object is created.
  17253. * 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.
  17254. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17255. *
  17256. * Possible `kind` values :
  17257. * - VertexBuffer.PositionKind
  17258. * - VertexBuffer.UVKind
  17259. * - VertexBuffer.UV2Kind
  17260. * - VertexBuffer.UV3Kind
  17261. * - VertexBuffer.UV4Kind
  17262. * - VertexBuffer.UV5Kind
  17263. * - VertexBuffer.UV6Kind
  17264. * - VertexBuffer.ColorKind
  17265. * - VertexBuffer.MatricesIndicesKind
  17266. * - VertexBuffer.MatricesIndicesExtraKind
  17267. * - VertexBuffer.MatricesWeightsKind
  17268. * - VertexBuffer.MatricesWeightsExtraKind
  17269. *
  17270. * Returns the Mesh.
  17271. */
  17272. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17273. /**
  17274. * Sets the mesh indices.
  17275. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17276. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17277. * This method creates a new index buffer each call.
  17278. * Returns the Mesh.
  17279. */
  17280. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17281. /**
  17282. * Boolean : True if the mesh owns the requested kind of data.
  17283. */
  17284. isVerticesDataPresent(kind: string): boolean;
  17285. /**
  17286. * Returns an array of indices (IndicesArray).
  17287. */
  17288. getIndices(): Nullable<IndicesArray>;
  17289. readonly _positions: Nullable<Vector3[]>;
  17290. /**
  17291. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17292. * This means the mesh underlying bounding box and sphere are recomputed.
  17293. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17294. * @returns the current mesh
  17295. */
  17296. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17297. /** @hidden */
  17298. _preActivate(): InstancedMesh;
  17299. /** @hidden */
  17300. _activate(renderId: number): boolean;
  17301. getWorldMatrix(): Matrix;
  17302. readonly isAnInstance: boolean;
  17303. /**
  17304. * Returns the current associated LOD AbstractMesh.
  17305. */
  17306. getLOD(camera: Camera): AbstractMesh;
  17307. /** @hidden */
  17308. _syncSubMeshes(): InstancedMesh;
  17309. /** @hidden */
  17310. _generatePointsArray(): boolean;
  17311. /**
  17312. * Creates a new InstancedMesh from the current mesh.
  17313. * - name (string) : the cloned mesh name
  17314. * - newParent (optional Node) : the optional Node to parent the clone to.
  17315. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17316. *
  17317. * Returns the clone.
  17318. */
  17319. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17320. /**
  17321. * Disposes the InstancedMesh.
  17322. * Returns nothing.
  17323. */
  17324. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17325. }
  17326. }
  17327. declare module "babylonjs/Materials/shaderMaterial" {
  17328. import { Scene } from "babylonjs/scene";
  17329. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17331. import { Mesh } from "babylonjs/Meshes/mesh";
  17332. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17333. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17334. import { Texture } from "babylonjs/Materials/Textures/texture";
  17335. import { Material } from "babylonjs/Materials/material";
  17336. /**
  17337. * Defines the options associated with the creation of a shader material.
  17338. */
  17339. export interface IShaderMaterialOptions {
  17340. /**
  17341. * Does the material work in alpha blend mode
  17342. */
  17343. needAlphaBlending: boolean;
  17344. /**
  17345. * Does the material work in alpha test mode
  17346. */
  17347. needAlphaTesting: boolean;
  17348. /**
  17349. * The list of attribute names used in the shader
  17350. */
  17351. attributes: string[];
  17352. /**
  17353. * The list of unifrom names used in the shader
  17354. */
  17355. uniforms: string[];
  17356. /**
  17357. * The list of UBO names used in the shader
  17358. */
  17359. uniformBuffers: string[];
  17360. /**
  17361. * The list of sampler names used in the shader
  17362. */
  17363. samplers: string[];
  17364. /**
  17365. * The list of defines used in the shader
  17366. */
  17367. defines: string[];
  17368. }
  17369. /**
  17370. * 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.
  17371. *
  17372. * This returned material effects how the mesh will look based on the code in the shaders.
  17373. *
  17374. * @see http://doc.babylonjs.com/how_to/shader_material
  17375. */
  17376. export class ShaderMaterial extends Material {
  17377. private _shaderPath;
  17378. private _options;
  17379. private _textures;
  17380. private _textureArrays;
  17381. private _floats;
  17382. private _ints;
  17383. private _floatsArrays;
  17384. private _colors3;
  17385. private _colors3Arrays;
  17386. private _colors4;
  17387. private _vectors2;
  17388. private _vectors3;
  17389. private _vectors4;
  17390. private _matrices;
  17391. private _matrices3x3;
  17392. private _matrices2x2;
  17393. private _vectors2Arrays;
  17394. private _vectors3Arrays;
  17395. private _cachedWorldViewMatrix;
  17396. private _renderId;
  17397. /**
  17398. * Instantiate a new shader material.
  17399. * 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.
  17400. * This returned material effects how the mesh will look based on the code in the shaders.
  17401. * @see http://doc.babylonjs.com/how_to/shader_material
  17402. * @param name Define the name of the material in the scene
  17403. * @param scene Define the scene the material belongs to
  17404. * @param shaderPath Defines the route to the shader code in one of three ways:
  17405. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17406. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17407. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17408. * @param options Define the options used to create the shader
  17409. */
  17410. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17411. /**
  17412. * Gets the options used to compile the shader.
  17413. * They can be modified to trigger a new compilation
  17414. */
  17415. readonly options: IShaderMaterialOptions;
  17416. /**
  17417. * Gets the current class name of the material e.g. "ShaderMaterial"
  17418. * Mainly use in serialization.
  17419. * @returns the class name
  17420. */
  17421. getClassName(): string;
  17422. /**
  17423. * Specifies if the material will require alpha blending
  17424. * @returns a boolean specifying if alpha blending is needed
  17425. */
  17426. needAlphaBlending(): boolean;
  17427. /**
  17428. * Specifies if this material should be rendered in alpha test mode
  17429. * @returns a boolean specifying if an alpha test is needed.
  17430. */
  17431. needAlphaTesting(): boolean;
  17432. private _checkUniform;
  17433. /**
  17434. * Set a texture in the shader.
  17435. * @param name Define the name of the uniform samplers as defined in the shader
  17436. * @param texture Define the texture to bind to this sampler
  17437. * @return the material itself allowing "fluent" like uniform updates
  17438. */
  17439. setTexture(name: string, texture: Texture): ShaderMaterial;
  17440. /**
  17441. * Set a texture array in the shader.
  17442. * @param name Define the name of the uniform sampler array as defined in the shader
  17443. * @param textures Define the list of textures to bind to this sampler
  17444. * @return the material itself allowing "fluent" like uniform updates
  17445. */
  17446. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17447. /**
  17448. * Set a float in the shader.
  17449. * @param name Define the name of the uniform as defined in the shader
  17450. * @param value Define the value to give to the uniform
  17451. * @return the material itself allowing "fluent" like uniform updates
  17452. */
  17453. setFloat(name: string, value: number): ShaderMaterial;
  17454. /**
  17455. * Set a int in the shader.
  17456. * @param name Define the name of the uniform as defined in the shader
  17457. * @param value Define the value to give to the uniform
  17458. * @return the material itself allowing "fluent" like uniform updates
  17459. */
  17460. setInt(name: string, value: number): ShaderMaterial;
  17461. /**
  17462. * Set an array of floats in the shader.
  17463. * @param name Define the name of the uniform as defined in the shader
  17464. * @param value Define the value to give to the uniform
  17465. * @return the material itself allowing "fluent" like uniform updates
  17466. */
  17467. setFloats(name: string, value: number[]): ShaderMaterial;
  17468. /**
  17469. * Set a vec3 in the shader from a Color3.
  17470. * @param name Define the name of the uniform as defined in the shader
  17471. * @param value Define the value to give to the uniform
  17472. * @return the material itself allowing "fluent" like uniform updates
  17473. */
  17474. setColor3(name: string, value: Color3): ShaderMaterial;
  17475. /**
  17476. * Set a vec3 array in the shader from a Color3 array.
  17477. * @param name Define the name of the uniform as defined in the shader
  17478. * @param value Define the value to give to the uniform
  17479. * @return the material itself allowing "fluent" like uniform updates
  17480. */
  17481. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17482. /**
  17483. * Set a vec4 in the shader from a Color4.
  17484. * @param name Define the name of the uniform as defined in the shader
  17485. * @param value Define the value to give to the uniform
  17486. * @return the material itself allowing "fluent" like uniform updates
  17487. */
  17488. setColor4(name: string, value: Color4): ShaderMaterial;
  17489. /**
  17490. * Set a vec2 in the shader from a Vector2.
  17491. * @param name Define the name of the uniform as defined in the shader
  17492. * @param value Define the value to give to the uniform
  17493. * @return the material itself allowing "fluent" like uniform updates
  17494. */
  17495. setVector2(name: string, value: Vector2): ShaderMaterial;
  17496. /**
  17497. * Set a vec3 in the shader from a Vector3.
  17498. * @param name Define the name of the uniform as defined in the shader
  17499. * @param value Define the value to give to the uniform
  17500. * @return the material itself allowing "fluent" like uniform updates
  17501. */
  17502. setVector3(name: string, value: Vector3): ShaderMaterial;
  17503. /**
  17504. * Set a vec4 in the shader from a Vector4.
  17505. * @param name Define the name of the uniform as defined in the shader
  17506. * @param value Define the value to give to the uniform
  17507. * @return the material itself allowing "fluent" like uniform updates
  17508. */
  17509. setVector4(name: string, value: Vector4): ShaderMaterial;
  17510. /**
  17511. * Set a mat4 in the shader from a Matrix.
  17512. * @param name Define the name of the uniform as defined in the shader
  17513. * @param value Define the value to give to the uniform
  17514. * @return the material itself allowing "fluent" like uniform updates
  17515. */
  17516. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17517. /**
  17518. * Set a mat3 in the shader from a Float32Array.
  17519. * @param name Define the name of the uniform as defined in the shader
  17520. * @param value Define the value to give to the uniform
  17521. * @return the material itself allowing "fluent" like uniform updates
  17522. */
  17523. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17524. /**
  17525. * Set a mat2 in the shader from a Float32Array.
  17526. * @param name Define the name of the uniform as defined in the shader
  17527. * @param value Define the value to give to the uniform
  17528. * @return the material itself allowing "fluent" like uniform updates
  17529. */
  17530. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17531. /**
  17532. * Set a vec2 array in the shader from a number array.
  17533. * @param name Define the name of the uniform as defined in the shader
  17534. * @param value Define the value to give to the uniform
  17535. * @return the material itself allowing "fluent" like uniform updates
  17536. */
  17537. setArray2(name: string, value: number[]): ShaderMaterial;
  17538. /**
  17539. * Set a vec3 array in the shader from a number array.
  17540. * @param name Define the name of the uniform as defined in the shader
  17541. * @param value Define the value to give to the uniform
  17542. * @return the material itself allowing "fluent" like uniform updates
  17543. */
  17544. setArray3(name: string, value: number[]): ShaderMaterial;
  17545. private _checkCache;
  17546. /**
  17547. * Specifies that the submesh is ready to be used
  17548. * @param mesh defines the mesh to check
  17549. * @param subMesh defines which submesh to check
  17550. * @param useInstances specifies that instances should be used
  17551. * @returns a boolean indicating that the submesh is ready or not
  17552. */
  17553. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17554. /**
  17555. * Checks if the material is ready to render the requested mesh
  17556. * @param mesh Define the mesh to render
  17557. * @param useInstances Define whether or not the material is used with instances
  17558. * @returns true if ready, otherwise false
  17559. */
  17560. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17561. /**
  17562. * Binds the world matrix to the material
  17563. * @param world defines the world transformation matrix
  17564. */
  17565. bindOnlyWorldMatrix(world: Matrix): void;
  17566. /**
  17567. * Binds the material to the mesh
  17568. * @param world defines the world transformation matrix
  17569. * @param mesh defines the mesh to bind the material to
  17570. */
  17571. bind(world: Matrix, mesh?: Mesh): void;
  17572. /**
  17573. * Gets the active textures from the material
  17574. * @returns an array of textures
  17575. */
  17576. getActiveTextures(): BaseTexture[];
  17577. /**
  17578. * Specifies if the material uses a texture
  17579. * @param texture defines the texture to check against the material
  17580. * @returns a boolean specifying if the material uses the texture
  17581. */
  17582. hasTexture(texture: BaseTexture): boolean;
  17583. /**
  17584. * Makes a duplicate of the material, and gives it a new name
  17585. * @param name defines the new name for the duplicated material
  17586. * @returns the cloned material
  17587. */
  17588. clone(name: string): ShaderMaterial;
  17589. /**
  17590. * Disposes the material
  17591. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17592. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17593. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17594. */
  17595. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17596. /**
  17597. * Serializes this material in a JSON representation
  17598. * @returns the serialized material object
  17599. */
  17600. serialize(): any;
  17601. /**
  17602. * Creates a shader material from parsed shader material data
  17603. * @param source defines the JSON represnetation of the material
  17604. * @param scene defines the hosting scene
  17605. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17606. * @returns a new material
  17607. */
  17608. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17609. }
  17610. }
  17611. declare module "babylonjs/Shaders/color.fragment" {
  17612. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17613. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17614. /** @hidden */
  17615. export var colorPixelShader: {
  17616. name: string;
  17617. shader: string;
  17618. };
  17619. }
  17620. declare module "babylonjs/Shaders/color.vertex" {
  17621. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17622. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17623. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17624. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17625. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17626. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17627. /** @hidden */
  17628. export var colorVertexShader: {
  17629. name: string;
  17630. shader: string;
  17631. };
  17632. }
  17633. declare module "babylonjs/Meshes/linesMesh" {
  17634. import { Nullable } from "babylonjs/types";
  17635. import { Scene } from "babylonjs/scene";
  17636. import { Color3 } from "babylonjs/Maths/math";
  17637. import { Node } from "babylonjs/node";
  17638. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17639. import { Mesh } from "babylonjs/Meshes/mesh";
  17640. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17641. import { Effect } from "babylonjs/Materials/effect";
  17642. import { Material } from "babylonjs/Materials/material";
  17643. import "babylonjs/Shaders/color.fragment";
  17644. import "babylonjs/Shaders/color.vertex";
  17645. /**
  17646. * Line mesh
  17647. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17648. */
  17649. export class LinesMesh extends Mesh {
  17650. /**
  17651. * If vertex color should be applied to the mesh
  17652. */
  17653. useVertexColor?: boolean | undefined;
  17654. /**
  17655. * If vertex alpha should be applied to the mesh
  17656. */
  17657. useVertexAlpha?: boolean | undefined;
  17658. /**
  17659. * Color of the line (Default: White)
  17660. */
  17661. color: Color3;
  17662. /**
  17663. * Alpha of the line (Default: 1)
  17664. */
  17665. alpha: number;
  17666. /**
  17667. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17668. * This margin is expressed in world space coordinates, so its value may vary.
  17669. * Default value is 0.1
  17670. */
  17671. intersectionThreshold: number;
  17672. private _colorShader;
  17673. /**
  17674. * Creates a new LinesMesh
  17675. * @param name defines the name
  17676. * @param scene defines the hosting scene
  17677. * @param parent defines the parent mesh if any
  17678. * @param source defines the optional source LinesMesh used to clone data from
  17679. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17680. * When false, achieved by calling a clone(), also passing False.
  17681. * This will make creation of children, recursive.
  17682. * @param useVertexColor defines if this LinesMesh supports vertex color
  17683. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17684. */
  17685. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17686. /**
  17687. * If vertex color should be applied to the mesh
  17688. */
  17689. useVertexColor?: boolean | undefined,
  17690. /**
  17691. * If vertex alpha should be applied to the mesh
  17692. */
  17693. useVertexAlpha?: boolean | undefined);
  17694. private _addClipPlaneDefine;
  17695. private _removeClipPlaneDefine;
  17696. isReady(): boolean;
  17697. /**
  17698. * Returns the string "LineMesh"
  17699. */
  17700. getClassName(): string;
  17701. /**
  17702. * @hidden
  17703. */
  17704. /**
  17705. * @hidden
  17706. */
  17707. material: Material;
  17708. /**
  17709. * @hidden
  17710. */
  17711. readonly checkCollisions: boolean;
  17712. /** @hidden */
  17713. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17714. /** @hidden */
  17715. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17716. /**
  17717. * Disposes of the line mesh
  17718. * @param doNotRecurse If children should be disposed
  17719. */
  17720. dispose(doNotRecurse?: boolean): void;
  17721. /**
  17722. * Returns a new LineMesh object cloned from the current one.
  17723. */
  17724. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17725. /**
  17726. * Creates a new InstancedLinesMesh object from the mesh model.
  17727. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17728. * @param name defines the name of the new instance
  17729. * @returns a new InstancedLinesMesh
  17730. */
  17731. createInstance(name: string): InstancedLinesMesh;
  17732. }
  17733. /**
  17734. * Creates an instance based on a source LinesMesh
  17735. */
  17736. export class InstancedLinesMesh extends InstancedMesh {
  17737. /**
  17738. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17739. * This margin is expressed in world space coordinates, so its value may vary.
  17740. * Initilized with the intersectionThreshold value of the source LinesMesh
  17741. */
  17742. intersectionThreshold: number;
  17743. constructor(name: string, source: LinesMesh);
  17744. /**
  17745. * Returns the string "InstancedLinesMesh".
  17746. */
  17747. getClassName(): string;
  17748. }
  17749. }
  17750. declare module "babylonjs/Shaders/line.fragment" {
  17751. /** @hidden */
  17752. export var linePixelShader: {
  17753. name: string;
  17754. shader: string;
  17755. };
  17756. }
  17757. declare module "babylonjs/Shaders/line.vertex" {
  17758. /** @hidden */
  17759. export var lineVertexShader: {
  17760. name: string;
  17761. shader: string;
  17762. };
  17763. }
  17764. declare module "babylonjs/Rendering/edgesRenderer" {
  17765. import { Nullable } from "babylonjs/types";
  17766. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17768. import { Vector3 } from "babylonjs/Maths/math";
  17769. import { IDisposable } from "babylonjs/scene";
  17770. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17771. import "babylonjs/Shaders/line.fragment";
  17772. import "babylonjs/Shaders/line.vertex";
  17773. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17774. module "babylonjs/Meshes/abstractMesh" {
  17775. interface AbstractMesh {
  17776. /**
  17777. * Disables the mesh edge rendering mode
  17778. * @returns the currentAbstractMesh
  17779. */
  17780. disableEdgesRendering(): AbstractMesh;
  17781. /**
  17782. * Enables the edge rendering mode on the mesh.
  17783. * This mode makes the mesh edges visible
  17784. * @param epsilon defines the maximal distance between two angles to detect a face
  17785. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17786. * @returns the currentAbstractMesh
  17787. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17788. */
  17789. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17790. /**
  17791. * Gets the edgesRenderer associated with the mesh
  17792. */
  17793. edgesRenderer: Nullable<EdgesRenderer>;
  17794. }
  17795. }
  17796. module "babylonjs/Meshes/linesMesh" {
  17797. interface LinesMesh {
  17798. /**
  17799. * Enables the edge rendering mode on the mesh.
  17800. * This mode makes the mesh edges visible
  17801. * @param epsilon defines the maximal distance between two angles to detect a face
  17802. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17803. * @returns the currentAbstractMesh
  17804. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17805. */
  17806. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17807. }
  17808. }
  17809. module "babylonjs/Meshes/linesMesh" {
  17810. interface InstancedLinesMesh {
  17811. /**
  17812. * Enables the edge rendering mode on the mesh.
  17813. * This mode makes the mesh edges visible
  17814. * @param epsilon defines the maximal distance between two angles to detect a face
  17815. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17816. * @returns the current InstancedLinesMesh
  17817. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17818. */
  17819. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17820. }
  17821. }
  17822. /**
  17823. * Defines the minimum contract an Edges renderer should follow.
  17824. */
  17825. export interface IEdgesRenderer extends IDisposable {
  17826. /**
  17827. * Gets or sets a boolean indicating if the edgesRenderer is active
  17828. */
  17829. isEnabled: boolean;
  17830. /**
  17831. * Renders the edges of the attached mesh,
  17832. */
  17833. render(): void;
  17834. /**
  17835. * Checks wether or not the edges renderer is ready to render.
  17836. * @return true if ready, otherwise false.
  17837. */
  17838. isReady(): boolean;
  17839. }
  17840. /**
  17841. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17842. */
  17843. export class EdgesRenderer implements IEdgesRenderer {
  17844. /**
  17845. * Define the size of the edges with an orthographic camera
  17846. */
  17847. edgesWidthScalerForOrthographic: number;
  17848. /**
  17849. * Define the size of the edges with a perspective camera
  17850. */
  17851. edgesWidthScalerForPerspective: number;
  17852. protected _source: AbstractMesh;
  17853. protected _linesPositions: number[];
  17854. protected _linesNormals: number[];
  17855. protected _linesIndices: number[];
  17856. protected _epsilon: number;
  17857. protected _indicesCount: number;
  17858. protected _lineShader: ShaderMaterial;
  17859. protected _ib: DataBuffer;
  17860. protected _buffers: {
  17861. [key: string]: Nullable<VertexBuffer>;
  17862. };
  17863. protected _checkVerticesInsteadOfIndices: boolean;
  17864. private _meshRebuildObserver;
  17865. private _meshDisposeObserver;
  17866. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17867. isEnabled: boolean;
  17868. /**
  17869. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17870. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17871. * @param source Mesh used to create edges
  17872. * @param epsilon sum of angles in adjacency to check for edge
  17873. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17874. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17875. */
  17876. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17877. protected _prepareRessources(): void;
  17878. /** @hidden */
  17879. _rebuild(): void;
  17880. /**
  17881. * Releases the required resources for the edges renderer
  17882. */
  17883. dispose(): void;
  17884. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17885. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17886. /**
  17887. * Checks if the pair of p0 and p1 is en edge
  17888. * @param faceIndex
  17889. * @param edge
  17890. * @param faceNormals
  17891. * @param p0
  17892. * @param p1
  17893. * @private
  17894. */
  17895. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17896. /**
  17897. * push line into the position, normal and index buffer
  17898. * @protected
  17899. */
  17900. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17901. /**
  17902. * Generates lines edges from adjacencjes
  17903. * @private
  17904. */
  17905. _generateEdgesLines(): void;
  17906. /**
  17907. * Checks wether or not the edges renderer is ready to render.
  17908. * @return true if ready, otherwise false.
  17909. */
  17910. isReady(): boolean;
  17911. /**
  17912. * Renders the edges of the attached mesh,
  17913. */
  17914. render(): void;
  17915. }
  17916. /**
  17917. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17918. */
  17919. export class LineEdgesRenderer extends EdgesRenderer {
  17920. /**
  17921. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17922. * @param source LineMesh used to generate edges
  17923. * @param epsilon not important (specified angle for edge detection)
  17924. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17925. */
  17926. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17927. /**
  17928. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17929. */
  17930. _generateEdgesLines(): void;
  17931. }
  17932. }
  17933. declare module "babylonjs/Rendering/renderingGroup" {
  17934. import { SmartArray } from "babylonjs/Misc/smartArray";
  17935. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17937. import { Nullable } from "babylonjs/types";
  17938. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17939. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17940. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17941. import { Material } from "babylonjs/Materials/material";
  17942. import { Scene } from "babylonjs/scene";
  17943. /**
  17944. * This represents the object necessary to create a rendering group.
  17945. * This is exclusively used and created by the rendering manager.
  17946. * To modify the behavior, you use the available helpers in your scene or meshes.
  17947. * @hidden
  17948. */
  17949. export class RenderingGroup {
  17950. index: number;
  17951. private _scene;
  17952. private _opaqueSubMeshes;
  17953. private _transparentSubMeshes;
  17954. private _alphaTestSubMeshes;
  17955. private _depthOnlySubMeshes;
  17956. private _particleSystems;
  17957. private _spriteManagers;
  17958. private _opaqueSortCompareFn;
  17959. private _alphaTestSortCompareFn;
  17960. private _transparentSortCompareFn;
  17961. private _renderOpaque;
  17962. private _renderAlphaTest;
  17963. private _renderTransparent;
  17964. /** @hidden */
  17965. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17966. onBeforeTransparentRendering: () => void;
  17967. /**
  17968. * Set the opaque sort comparison function.
  17969. * If null the sub meshes will be render in the order they were created
  17970. */
  17971. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17972. /**
  17973. * Set the alpha test sort comparison function.
  17974. * If null the sub meshes will be render in the order they were created
  17975. */
  17976. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17977. /**
  17978. * Set the transparent sort comparison function.
  17979. * If null the sub meshes will be render in the order they were created
  17980. */
  17981. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17982. /**
  17983. * Creates a new rendering group.
  17984. * @param index The rendering group index
  17985. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17986. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17987. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17988. */
  17989. 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>);
  17990. /**
  17991. * Render all the sub meshes contained in the group.
  17992. * @param customRenderFunction Used to override the default render behaviour of the group.
  17993. * @returns true if rendered some submeshes.
  17994. */
  17995. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17996. /**
  17997. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17998. * @param subMeshes The submeshes to render
  17999. */
  18000. private renderOpaqueSorted;
  18001. /**
  18002. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  18003. * @param subMeshes The submeshes to render
  18004. */
  18005. private renderAlphaTestSorted;
  18006. /**
  18007. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  18008. * @param subMeshes The submeshes to render
  18009. */
  18010. private renderTransparentSorted;
  18011. /**
  18012. * Renders the submeshes in a specified order.
  18013. * @param subMeshes The submeshes to sort before render
  18014. * @param sortCompareFn The comparison function use to sort
  18015. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18016. * @param transparent Specifies to activate blending if true
  18017. */
  18018. private static renderSorted;
  18019. /**
  18020. * Renders the submeshes in the order they were dispatched (no sort applied).
  18021. * @param subMeshes The submeshes to render
  18022. */
  18023. private static renderUnsorted;
  18024. /**
  18025. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18026. * are rendered back to front if in the same alpha index.
  18027. *
  18028. * @param a The first submesh
  18029. * @param b The second submesh
  18030. * @returns The result of the comparison
  18031. */
  18032. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18033. /**
  18034. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18035. * are rendered back to front.
  18036. *
  18037. * @param a The first submesh
  18038. * @param b The second submesh
  18039. * @returns The result of the comparison
  18040. */
  18041. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18042. /**
  18043. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18044. * are rendered front to back (prevent overdraw).
  18045. *
  18046. * @param a The first submesh
  18047. * @param b The second submesh
  18048. * @returns The result of the comparison
  18049. */
  18050. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18051. /**
  18052. * Resets the different lists of submeshes to prepare a new frame.
  18053. */
  18054. prepare(): void;
  18055. dispose(): void;
  18056. /**
  18057. * Inserts the submesh in its correct queue depending on its material.
  18058. * @param subMesh The submesh to dispatch
  18059. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18060. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18061. */
  18062. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18063. dispatchSprites(spriteManager: ISpriteManager): void;
  18064. dispatchParticles(particleSystem: IParticleSystem): void;
  18065. private _renderParticles;
  18066. private _renderSprites;
  18067. }
  18068. }
  18069. declare module "babylonjs/Rendering/renderingManager" {
  18070. import { Nullable } from "babylonjs/types";
  18071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18072. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18073. import { SmartArray } from "babylonjs/Misc/smartArray";
  18074. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18075. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18076. import { Material } from "babylonjs/Materials/material";
  18077. import { Scene } from "babylonjs/scene";
  18078. import { Camera } from "babylonjs/Cameras/camera";
  18079. /**
  18080. * Interface describing the different options available in the rendering manager
  18081. * regarding Auto Clear between groups.
  18082. */
  18083. export interface IRenderingManagerAutoClearSetup {
  18084. /**
  18085. * Defines whether or not autoclear is enable.
  18086. */
  18087. autoClear: boolean;
  18088. /**
  18089. * Defines whether or not to autoclear the depth buffer.
  18090. */
  18091. depth: boolean;
  18092. /**
  18093. * Defines whether or not to autoclear the stencil buffer.
  18094. */
  18095. stencil: boolean;
  18096. }
  18097. /**
  18098. * This class is used by the onRenderingGroupObservable
  18099. */
  18100. export class RenderingGroupInfo {
  18101. /**
  18102. * The Scene that being rendered
  18103. */
  18104. scene: Scene;
  18105. /**
  18106. * The camera currently used for the rendering pass
  18107. */
  18108. camera: Nullable<Camera>;
  18109. /**
  18110. * The ID of the renderingGroup being processed
  18111. */
  18112. renderingGroupId: number;
  18113. }
  18114. /**
  18115. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18116. * It is enable to manage the different groups as well as the different necessary sort functions.
  18117. * This should not be used directly aside of the few static configurations
  18118. */
  18119. export class RenderingManager {
  18120. /**
  18121. * The max id used for rendering groups (not included)
  18122. */
  18123. static MAX_RENDERINGGROUPS: number;
  18124. /**
  18125. * The min id used for rendering groups (included)
  18126. */
  18127. static MIN_RENDERINGGROUPS: number;
  18128. /**
  18129. * Used to globally prevent autoclearing scenes.
  18130. */
  18131. static AUTOCLEAR: boolean;
  18132. /**
  18133. * @hidden
  18134. */
  18135. _useSceneAutoClearSetup: boolean;
  18136. private _scene;
  18137. private _renderingGroups;
  18138. private _depthStencilBufferAlreadyCleaned;
  18139. private _autoClearDepthStencil;
  18140. private _customOpaqueSortCompareFn;
  18141. private _customAlphaTestSortCompareFn;
  18142. private _customTransparentSortCompareFn;
  18143. private _renderingGroupInfo;
  18144. /**
  18145. * Instantiates a new rendering group for a particular scene
  18146. * @param scene Defines the scene the groups belongs to
  18147. */
  18148. constructor(scene: Scene);
  18149. private _clearDepthStencilBuffer;
  18150. /**
  18151. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18152. * @hidden
  18153. */
  18154. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18155. /**
  18156. * Resets the different information of the group to prepare a new frame
  18157. * @hidden
  18158. */
  18159. reset(): void;
  18160. /**
  18161. * Dispose and release the group and its associated resources.
  18162. * @hidden
  18163. */
  18164. dispose(): void;
  18165. /**
  18166. * Clear the info related to rendering groups preventing retention points during dispose.
  18167. */
  18168. freeRenderingGroups(): void;
  18169. private _prepareRenderingGroup;
  18170. /**
  18171. * Add a sprite manager to the rendering manager in order to render it this frame.
  18172. * @param spriteManager Define the sprite manager to render
  18173. */
  18174. dispatchSprites(spriteManager: ISpriteManager): void;
  18175. /**
  18176. * Add a particle system to the rendering manager in order to render it this frame.
  18177. * @param particleSystem Define the particle system to render
  18178. */
  18179. dispatchParticles(particleSystem: IParticleSystem): void;
  18180. /**
  18181. * Add a submesh to the manager in order to render it this frame
  18182. * @param subMesh The submesh to dispatch
  18183. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18184. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18185. */
  18186. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18187. /**
  18188. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18189. * This allowed control for front to back rendering or reversly depending of the special needs.
  18190. *
  18191. * @param renderingGroupId The rendering group id corresponding to its index
  18192. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18193. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18194. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18195. */
  18196. 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;
  18197. /**
  18198. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18199. *
  18200. * @param renderingGroupId The rendering group id corresponding to its index
  18201. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18202. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18203. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18204. */
  18205. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18206. /**
  18207. * Gets the current auto clear configuration for one rendering group of the rendering
  18208. * manager.
  18209. * @param index the rendering group index to get the information for
  18210. * @returns The auto clear setup for the requested rendering group
  18211. */
  18212. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18213. }
  18214. }
  18215. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18216. import { Observable } from "babylonjs/Misc/observable";
  18217. import { SmartArray } from "babylonjs/Misc/smartArray";
  18218. import { Nullable } from "babylonjs/types";
  18219. import { Camera } from "babylonjs/Cameras/camera";
  18220. import { Scene } from "babylonjs/scene";
  18221. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18222. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18224. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18225. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18226. import { Texture } from "babylonjs/Materials/Textures/texture";
  18227. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18228. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18229. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18230. import { Engine } from "babylonjs/Engines/engine";
  18231. /**
  18232. * This Helps creating a texture that will be created from a camera in your scene.
  18233. * It is basically a dynamic texture that could be used to create special effects for instance.
  18234. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18235. */
  18236. export class RenderTargetTexture extends Texture {
  18237. isCube: boolean;
  18238. /**
  18239. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18240. */
  18241. static readonly REFRESHRATE_RENDER_ONCE: number;
  18242. /**
  18243. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18244. */
  18245. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18246. /**
  18247. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18248. * the central point of your effect and can save a lot of performances.
  18249. */
  18250. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18251. /**
  18252. * Use this predicate to dynamically define the list of mesh you want to render.
  18253. * If set, the renderList property will be overwritten.
  18254. */
  18255. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18256. private _renderList;
  18257. /**
  18258. * Use this list to define the list of mesh you want to render.
  18259. */
  18260. renderList: Nullable<Array<AbstractMesh>>;
  18261. private _hookArray;
  18262. /**
  18263. * Define if particles should be rendered in your texture.
  18264. */
  18265. renderParticles: boolean;
  18266. /**
  18267. * Define if sprites should be rendered in your texture.
  18268. */
  18269. renderSprites: boolean;
  18270. /**
  18271. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18272. */
  18273. coordinatesMode: number;
  18274. /**
  18275. * Define the camera used to render the texture.
  18276. */
  18277. activeCamera: Nullable<Camera>;
  18278. /**
  18279. * Override the render function of the texture with your own one.
  18280. */
  18281. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18282. /**
  18283. * Define if camera post processes should be use while rendering the texture.
  18284. */
  18285. useCameraPostProcesses: boolean;
  18286. /**
  18287. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18288. */
  18289. ignoreCameraViewport: boolean;
  18290. private _postProcessManager;
  18291. private _postProcesses;
  18292. private _resizeObserver;
  18293. /**
  18294. * An event triggered when the texture is unbind.
  18295. */
  18296. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18297. /**
  18298. * An event triggered when the texture is unbind.
  18299. */
  18300. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18301. private _onAfterUnbindObserver;
  18302. /**
  18303. * Set a after unbind callback in the texture.
  18304. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18305. */
  18306. onAfterUnbind: () => void;
  18307. /**
  18308. * An event triggered before rendering the texture
  18309. */
  18310. onBeforeRenderObservable: Observable<number>;
  18311. private _onBeforeRenderObserver;
  18312. /**
  18313. * Set a before render callback in the texture.
  18314. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18315. */
  18316. onBeforeRender: (faceIndex: number) => void;
  18317. /**
  18318. * An event triggered after rendering the texture
  18319. */
  18320. onAfterRenderObservable: Observable<number>;
  18321. private _onAfterRenderObserver;
  18322. /**
  18323. * Set a after render callback in the texture.
  18324. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18325. */
  18326. onAfterRender: (faceIndex: number) => void;
  18327. /**
  18328. * An event triggered after the texture clear
  18329. */
  18330. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18331. private _onClearObserver;
  18332. /**
  18333. * Set a clear callback in the texture.
  18334. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18335. */
  18336. onClear: (Engine: Engine) => void;
  18337. /**
  18338. * Define the clear color of the Render Target if it should be different from the scene.
  18339. */
  18340. clearColor: Color4;
  18341. protected _size: number | {
  18342. width: number;
  18343. height: number;
  18344. };
  18345. protected _initialSizeParameter: number | {
  18346. width: number;
  18347. height: number;
  18348. } | {
  18349. ratio: number;
  18350. };
  18351. protected _sizeRatio: Nullable<number>;
  18352. /** @hidden */
  18353. _generateMipMaps: boolean;
  18354. protected _renderingManager: RenderingManager;
  18355. /** @hidden */
  18356. _waitingRenderList: string[];
  18357. protected _doNotChangeAspectRatio: boolean;
  18358. protected _currentRefreshId: number;
  18359. protected _refreshRate: number;
  18360. protected _textureMatrix: Matrix;
  18361. protected _samples: number;
  18362. protected _renderTargetOptions: RenderTargetCreationOptions;
  18363. /**
  18364. * Gets render target creation options that were used.
  18365. */
  18366. readonly renderTargetOptions: RenderTargetCreationOptions;
  18367. protected _engine: Engine;
  18368. protected _onRatioRescale(): void;
  18369. /**
  18370. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18371. * It must define where the camera used to render the texture is set
  18372. */
  18373. boundingBoxPosition: Vector3;
  18374. private _boundingBoxSize;
  18375. /**
  18376. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18377. * When defined, the cubemap will switch to local mode
  18378. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18379. * @example https://www.babylonjs-playground.com/#RNASML
  18380. */
  18381. boundingBoxSize: Vector3;
  18382. /**
  18383. * In case the RTT has been created with a depth texture, get the associated
  18384. * depth texture.
  18385. * Otherwise, return null.
  18386. */
  18387. depthStencilTexture: Nullable<InternalTexture>;
  18388. /**
  18389. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18390. * or used a shadow, depth texture...
  18391. * @param name The friendly name of the texture
  18392. * @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)
  18393. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18394. * @param generateMipMaps True if mip maps need to be generated after render.
  18395. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18396. * @param type The type of the buffer in the RTT (int, half float, float...)
  18397. * @param isCube True if a cube texture needs to be created
  18398. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18399. * @param generateDepthBuffer True to generate a depth buffer
  18400. * @param generateStencilBuffer True to generate a stencil buffer
  18401. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18402. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18403. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18404. */
  18405. constructor(name: string, size: number | {
  18406. width: number;
  18407. height: number;
  18408. } | {
  18409. ratio: number;
  18410. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18411. /**
  18412. * Creates a depth stencil texture.
  18413. * This is only available in WebGL 2 or with the depth texture extension available.
  18414. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18415. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18416. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18417. */
  18418. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18419. private _processSizeParameter;
  18420. /**
  18421. * Define the number of samples to use in case of MSAA.
  18422. * It defaults to one meaning no MSAA has been enabled.
  18423. */
  18424. samples: number;
  18425. /**
  18426. * Resets the refresh counter of the texture and start bak from scratch.
  18427. * Could be useful to regenerate the texture if it is setup to render only once.
  18428. */
  18429. resetRefreshCounter(): void;
  18430. /**
  18431. * Define the refresh rate of the texture or the rendering frequency.
  18432. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18433. */
  18434. refreshRate: number;
  18435. /**
  18436. * Adds a post process to the render target rendering passes.
  18437. * @param postProcess define the post process to add
  18438. */
  18439. addPostProcess(postProcess: PostProcess): void;
  18440. /**
  18441. * Clear all the post processes attached to the render target
  18442. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18443. */
  18444. clearPostProcesses(dispose?: boolean): void;
  18445. /**
  18446. * Remove one of the post process from the list of attached post processes to the texture
  18447. * @param postProcess define the post process to remove from the list
  18448. */
  18449. removePostProcess(postProcess: PostProcess): void;
  18450. /** @hidden */
  18451. _shouldRender(): boolean;
  18452. /**
  18453. * Gets the actual render size of the texture.
  18454. * @returns the width of the render size
  18455. */
  18456. getRenderSize(): number;
  18457. /**
  18458. * Gets the actual render width of the texture.
  18459. * @returns the width of the render size
  18460. */
  18461. getRenderWidth(): number;
  18462. /**
  18463. * Gets the actual render height of the texture.
  18464. * @returns the height of the render size
  18465. */
  18466. getRenderHeight(): number;
  18467. /**
  18468. * Get if the texture can be rescaled or not.
  18469. */
  18470. readonly canRescale: boolean;
  18471. /**
  18472. * Resize the texture using a ratio.
  18473. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18474. */
  18475. scale(ratio: number): void;
  18476. /**
  18477. * Get the texture reflection matrix used to rotate/transform the reflection.
  18478. * @returns the reflection matrix
  18479. */
  18480. getReflectionTextureMatrix(): Matrix;
  18481. /**
  18482. * Resize the texture to a new desired size.
  18483. * Be carrefull as it will recreate all the data in the new texture.
  18484. * @param size Define the new size. It can be:
  18485. * - a number for squared texture,
  18486. * - an object containing { width: number, height: number }
  18487. * - or an object containing a ratio { ratio: number }
  18488. */
  18489. resize(size: number | {
  18490. width: number;
  18491. height: number;
  18492. } | {
  18493. ratio: number;
  18494. }): void;
  18495. /**
  18496. * Renders all the objects from the render list into the texture.
  18497. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18498. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18499. */
  18500. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18501. private _bestReflectionRenderTargetDimension;
  18502. /**
  18503. * @hidden
  18504. * @param faceIndex face index to bind to if this is a cubetexture
  18505. */
  18506. _bindFrameBuffer(faceIndex?: number): void;
  18507. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18508. private renderToTarget;
  18509. /**
  18510. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18511. * This allowed control for front to back rendering or reversly depending of the special needs.
  18512. *
  18513. * @param renderingGroupId The rendering group id corresponding to its index
  18514. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18515. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18516. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18517. */
  18518. 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;
  18519. /**
  18520. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18521. *
  18522. * @param renderingGroupId The rendering group id corresponding to its index
  18523. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18524. */
  18525. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18526. /**
  18527. * Clones the texture.
  18528. * @returns the cloned texture
  18529. */
  18530. clone(): RenderTargetTexture;
  18531. /**
  18532. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18533. * @returns The JSON representation of the texture
  18534. */
  18535. serialize(): any;
  18536. /**
  18537. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18538. */
  18539. disposeFramebufferObjects(): void;
  18540. /**
  18541. * Dispose the texture and release its associated resources.
  18542. */
  18543. dispose(): void;
  18544. /** @hidden */
  18545. _rebuild(): void;
  18546. /**
  18547. * Clear the info related to rendering groups preventing retention point in material dispose.
  18548. */
  18549. freeRenderingGroups(): void;
  18550. /**
  18551. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18552. * @returns the view count
  18553. */
  18554. getViewCount(): number;
  18555. }
  18556. }
  18557. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18558. import { Scene } from "babylonjs/scene";
  18559. import { Plane } from "babylonjs/Maths/math";
  18560. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18561. /**
  18562. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18563. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18564. * You can then easily use it as a reflectionTexture on a flat surface.
  18565. * In case the surface is not a plane, please consider relying on reflection probes.
  18566. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18567. */
  18568. export class MirrorTexture extends RenderTargetTexture {
  18569. private scene;
  18570. /**
  18571. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18572. * 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.
  18573. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18574. */
  18575. mirrorPlane: Plane;
  18576. /**
  18577. * Define the blur ratio used to blur the reflection if needed.
  18578. */
  18579. blurRatio: number;
  18580. /**
  18581. * Define the adaptive blur kernel used to blur the reflection if needed.
  18582. * This will autocompute the closest best match for the `blurKernel`
  18583. */
  18584. adaptiveBlurKernel: number;
  18585. /**
  18586. * Define the blur kernel used to blur the reflection if needed.
  18587. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18588. */
  18589. blurKernel: number;
  18590. /**
  18591. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18592. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18593. */
  18594. blurKernelX: number;
  18595. /**
  18596. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18597. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18598. */
  18599. blurKernelY: number;
  18600. private _autoComputeBlurKernel;
  18601. protected _onRatioRescale(): void;
  18602. private _updateGammaSpace;
  18603. private _imageProcessingConfigChangeObserver;
  18604. private _transformMatrix;
  18605. private _mirrorMatrix;
  18606. private _savedViewMatrix;
  18607. private _blurX;
  18608. private _blurY;
  18609. private _adaptiveBlurKernel;
  18610. private _blurKernelX;
  18611. private _blurKernelY;
  18612. private _blurRatio;
  18613. /**
  18614. * Instantiates a Mirror Texture.
  18615. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18616. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18617. * You can then easily use it as a reflectionTexture on a flat surface.
  18618. * In case the surface is not a plane, please consider relying on reflection probes.
  18619. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18620. * @param name
  18621. * @param size
  18622. * @param scene
  18623. * @param generateMipMaps
  18624. * @param type
  18625. * @param samplingMode
  18626. * @param generateDepthBuffer
  18627. */
  18628. constructor(name: string, size: number | {
  18629. width: number;
  18630. height: number;
  18631. } | {
  18632. ratio: number;
  18633. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18634. private _preparePostProcesses;
  18635. /**
  18636. * Clone the mirror texture.
  18637. * @returns the cloned texture
  18638. */
  18639. clone(): MirrorTexture;
  18640. /**
  18641. * Serialize the texture to a JSON representation you could use in Parse later on
  18642. * @returns the serialized JSON representation
  18643. */
  18644. serialize(): any;
  18645. /**
  18646. * Dispose the texture and release its associated resources.
  18647. */
  18648. dispose(): void;
  18649. }
  18650. }
  18651. declare module "babylonjs/Materials/Textures/texture" {
  18652. import { Observable } from "babylonjs/Misc/observable";
  18653. import { Nullable } from "babylonjs/types";
  18654. import { Scene } from "babylonjs/scene";
  18655. import { Matrix } from "babylonjs/Maths/math";
  18656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18657. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18658. /**
  18659. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18660. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18661. */
  18662. export class Texture extends BaseTexture {
  18663. /** @hidden */
  18664. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18665. /** @hidden */
  18666. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18667. /** @hidden */
  18668. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18669. /** nearest is mag = nearest and min = nearest and mip = linear */
  18670. static readonly NEAREST_SAMPLINGMODE: number;
  18671. /** nearest is mag = nearest and min = nearest and mip = linear */
  18672. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18673. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18674. static readonly BILINEAR_SAMPLINGMODE: number;
  18675. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18676. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18677. /** Trilinear is mag = linear and min = linear and mip = linear */
  18678. static readonly TRILINEAR_SAMPLINGMODE: number;
  18679. /** Trilinear is mag = linear and min = linear and mip = linear */
  18680. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18681. /** mag = nearest and min = nearest and mip = nearest */
  18682. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18683. /** mag = nearest and min = linear and mip = nearest */
  18684. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18685. /** mag = nearest and min = linear and mip = linear */
  18686. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18687. /** mag = nearest and min = linear and mip = none */
  18688. static readonly NEAREST_LINEAR: number;
  18689. /** mag = nearest and min = nearest and mip = none */
  18690. static readonly NEAREST_NEAREST: number;
  18691. /** mag = linear and min = nearest and mip = nearest */
  18692. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18693. /** mag = linear and min = nearest and mip = linear */
  18694. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18695. /** mag = linear and min = linear and mip = none */
  18696. static readonly LINEAR_LINEAR: number;
  18697. /** mag = linear and min = nearest and mip = none */
  18698. static readonly LINEAR_NEAREST: number;
  18699. /** Explicit coordinates mode */
  18700. static readonly EXPLICIT_MODE: number;
  18701. /** Spherical coordinates mode */
  18702. static readonly SPHERICAL_MODE: number;
  18703. /** Planar coordinates mode */
  18704. static readonly PLANAR_MODE: number;
  18705. /** Cubic coordinates mode */
  18706. static readonly CUBIC_MODE: number;
  18707. /** Projection coordinates mode */
  18708. static readonly PROJECTION_MODE: number;
  18709. /** Inverse Cubic coordinates mode */
  18710. static readonly SKYBOX_MODE: number;
  18711. /** Inverse Cubic coordinates mode */
  18712. static readonly INVCUBIC_MODE: number;
  18713. /** Equirectangular coordinates mode */
  18714. static readonly EQUIRECTANGULAR_MODE: number;
  18715. /** Equirectangular Fixed coordinates mode */
  18716. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18717. /** Equirectangular Fixed Mirrored coordinates mode */
  18718. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18719. /** Texture is not repeating outside of 0..1 UVs */
  18720. static readonly CLAMP_ADDRESSMODE: number;
  18721. /** Texture is repeating outside of 0..1 UVs */
  18722. static readonly WRAP_ADDRESSMODE: number;
  18723. /** Texture is repeating and mirrored */
  18724. static readonly MIRROR_ADDRESSMODE: number;
  18725. /**
  18726. * 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
  18727. */
  18728. static UseSerializedUrlIfAny: boolean;
  18729. /**
  18730. * Define the url of the texture.
  18731. */
  18732. url: Nullable<string>;
  18733. /**
  18734. * Define an offset on the texture to offset the u coordinates of the UVs
  18735. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18736. */
  18737. uOffset: number;
  18738. /**
  18739. * Define an offset on the texture to offset the v coordinates of the UVs
  18740. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18741. */
  18742. vOffset: number;
  18743. /**
  18744. * Define an offset on the texture to scale the u coordinates of the UVs
  18745. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18746. */
  18747. uScale: number;
  18748. /**
  18749. * Define an offset on the texture to scale the v coordinates of the UVs
  18750. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18751. */
  18752. vScale: number;
  18753. /**
  18754. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18755. * @see http://doc.babylonjs.com/how_to/more_materials
  18756. */
  18757. uAng: number;
  18758. /**
  18759. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18760. * @see http://doc.babylonjs.com/how_to/more_materials
  18761. */
  18762. vAng: number;
  18763. /**
  18764. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18765. * @see http://doc.babylonjs.com/how_to/more_materials
  18766. */
  18767. wAng: number;
  18768. /**
  18769. * Defines the center of rotation (U)
  18770. */
  18771. uRotationCenter: number;
  18772. /**
  18773. * Defines the center of rotation (V)
  18774. */
  18775. vRotationCenter: number;
  18776. /**
  18777. * Defines the center of rotation (W)
  18778. */
  18779. wRotationCenter: number;
  18780. /**
  18781. * Are mip maps generated for this texture or not.
  18782. */
  18783. readonly noMipmap: boolean;
  18784. /**
  18785. * List of inspectable custom properties (used by the Inspector)
  18786. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18787. */
  18788. inspectableCustomProperties: Nullable<IInspectable[]>;
  18789. private _noMipmap;
  18790. /** @hidden */
  18791. _invertY: boolean;
  18792. private _rowGenerationMatrix;
  18793. private _cachedTextureMatrix;
  18794. private _projectionModeMatrix;
  18795. private _t0;
  18796. private _t1;
  18797. private _t2;
  18798. private _cachedUOffset;
  18799. private _cachedVOffset;
  18800. private _cachedUScale;
  18801. private _cachedVScale;
  18802. private _cachedUAng;
  18803. private _cachedVAng;
  18804. private _cachedWAng;
  18805. private _cachedProjectionMatrixId;
  18806. private _cachedCoordinatesMode;
  18807. /** @hidden */
  18808. protected _initialSamplingMode: number;
  18809. /** @hidden */
  18810. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18811. private _deleteBuffer;
  18812. protected _format: Nullable<number>;
  18813. private _delayedOnLoad;
  18814. private _delayedOnError;
  18815. /**
  18816. * Observable triggered once the texture has been loaded.
  18817. */
  18818. onLoadObservable: Observable<Texture>;
  18819. protected _isBlocking: boolean;
  18820. /**
  18821. * Is the texture preventing material to render while loading.
  18822. * If false, a default texture will be used instead of the loading one during the preparation step.
  18823. */
  18824. isBlocking: boolean;
  18825. /**
  18826. * Get the current sampling mode associated with the texture.
  18827. */
  18828. readonly samplingMode: number;
  18829. /**
  18830. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18831. */
  18832. readonly invertY: boolean;
  18833. /**
  18834. * Instantiates a new texture.
  18835. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18836. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18837. * @param url define the url of the picture to load as a texture
  18838. * @param scene define the scene the texture will belong to
  18839. * @param noMipmap define if the texture will require mip maps or not
  18840. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18841. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18842. * @param onLoad define a callback triggered when the texture has been loaded
  18843. * @param onError define a callback triggered when an error occurred during the loading session
  18844. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18845. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18846. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18847. */
  18848. constructor(url: Nullable<string>, scene: Nullable<Scene>, 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);
  18849. /**
  18850. * Update the url (and optional buffer) of this texture if url was null during construction.
  18851. * @param url the url of the texture
  18852. * @param buffer the buffer of the texture (defaults to null)
  18853. * @param onLoad callback called when the texture is loaded (defaults to null)
  18854. */
  18855. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18856. /**
  18857. * Finish the loading sequence of a texture flagged as delayed load.
  18858. * @hidden
  18859. */
  18860. delayLoad(): void;
  18861. private _prepareRowForTextureGeneration;
  18862. /**
  18863. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18864. * @returns the transform matrix of the texture.
  18865. */
  18866. getTextureMatrix(): Matrix;
  18867. /**
  18868. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18869. * @returns The reflection texture transform
  18870. */
  18871. getReflectionTextureMatrix(): Matrix;
  18872. /**
  18873. * Clones the texture.
  18874. * @returns the cloned texture
  18875. */
  18876. clone(): Texture;
  18877. /**
  18878. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18879. * @returns The JSON representation of the texture
  18880. */
  18881. serialize(): any;
  18882. /**
  18883. * Get the current class name of the texture useful for serialization or dynamic coding.
  18884. * @returns "Texture"
  18885. */
  18886. getClassName(): string;
  18887. /**
  18888. * Dispose the texture and release its associated resources.
  18889. */
  18890. dispose(): void;
  18891. /**
  18892. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18893. * @param parsedTexture Define the JSON representation of the texture
  18894. * @param scene Define the scene the parsed texture should be instantiated in
  18895. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18896. * @returns The parsed texture if successful
  18897. */
  18898. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18899. /**
  18900. * Creates a texture from its base 64 representation.
  18901. * @param data Define the base64 payload without the data: prefix
  18902. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18903. * @param scene Define the scene the texture should belong to
  18904. * @param noMipmap Forces the texture to not create mip map information if true
  18905. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18906. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18907. * @param onLoad define a callback triggered when the texture has been loaded
  18908. * @param onError define a callback triggered when an error occurred during the loading session
  18909. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18910. * @returns the created texture
  18911. */
  18912. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18913. /**
  18914. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18915. * @param data Define the base64 payload without the data: prefix
  18916. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18917. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18918. * @param scene Define the scene the texture should belong to
  18919. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18920. * @param noMipmap Forces the texture to not create mip map information if true
  18921. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18922. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18923. * @param onLoad define a callback triggered when the texture has been loaded
  18924. * @param onError define a callback triggered when an error occurred during the loading session
  18925. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18926. * @returns the created texture
  18927. */
  18928. 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;
  18929. }
  18930. }
  18931. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18932. import { Nullable } from "babylonjs/types";
  18933. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18934. import { Scene } from "babylonjs/scene";
  18935. module "babylonjs/Engines/engine" {
  18936. interface Engine {
  18937. /**
  18938. * Creates a raw texture
  18939. * @param data defines the data to store in the texture
  18940. * @param width defines the width of the texture
  18941. * @param height defines the height of the texture
  18942. * @param format defines the format of the data
  18943. * @param generateMipMaps defines if the engine should generate the mip levels
  18944. * @param invertY defines if data must be stored with Y axis inverted
  18945. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18946. * @param compression defines the compression used (null by default)
  18947. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18948. * @returns the raw texture inside an InternalTexture
  18949. */
  18950. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18951. /**
  18952. * Update a raw texture
  18953. * @param texture defines the texture to update
  18954. * @param data defines the data to store in the texture
  18955. * @param format defines the format of the data
  18956. * @param invertY defines if data must be stored with Y axis inverted
  18957. */
  18958. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18959. /**
  18960. * Update a raw texture
  18961. * @param texture defines the texture to update
  18962. * @param data defines the data to store in the texture
  18963. * @param format defines the format of the data
  18964. * @param invertY defines if data must be stored with Y axis inverted
  18965. * @param compression defines the compression used (null by default)
  18966. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18967. */
  18968. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18969. /**
  18970. * Creates a new raw cube texture
  18971. * @param data defines the array of data to use to create each face
  18972. * @param size defines the size of the textures
  18973. * @param format defines the format of the data
  18974. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18975. * @param generateMipMaps defines if the engine should generate the mip levels
  18976. * @param invertY defines if data must be stored with Y axis inverted
  18977. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18978. * @param compression defines the compression used (null by default)
  18979. * @returns the cube texture as an InternalTexture
  18980. */
  18981. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18982. /**
  18983. * Update a raw cube texture
  18984. * @param texture defines the texture to udpdate
  18985. * @param data defines the data to store
  18986. * @param format defines the data format
  18987. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18988. * @param invertY defines if data must be stored with Y axis inverted
  18989. */
  18990. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18991. /**
  18992. * Update a raw cube texture
  18993. * @param texture defines the texture to udpdate
  18994. * @param data defines the data to store
  18995. * @param format defines the data format
  18996. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18997. * @param invertY defines if data must be stored with Y axis inverted
  18998. * @param compression defines the compression used (null by default)
  18999. */
  19000. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  19001. /**
  19002. * Update a raw cube texture
  19003. * @param texture defines the texture to udpdate
  19004. * @param data defines the data to store
  19005. * @param format defines the data format
  19006. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19007. * @param invertY defines if data must be stored with Y axis inverted
  19008. * @param compression defines the compression used (null by default)
  19009. * @param level defines which level of the texture to update
  19010. */
  19011. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  19012. /**
  19013. * Creates a new raw cube texture from a specified url
  19014. * @param url defines the url where the data is located
  19015. * @param scene defines the current scene
  19016. * @param size defines the size of the textures
  19017. * @param format defines the format of the data
  19018. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19019. * @param noMipmap defines if the engine should avoid generating the mip levels
  19020. * @param callback defines a callback used to extract texture data from loaded data
  19021. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19022. * @param onLoad defines a callback called when texture is loaded
  19023. * @param onError defines a callback called if there is an error
  19024. * @returns the cube texture as an InternalTexture
  19025. */
  19026. 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;
  19027. /**
  19028. * Creates a new raw cube texture from a specified url
  19029. * @param url defines the url where the data is located
  19030. * @param scene defines the current scene
  19031. * @param size defines the size of the textures
  19032. * @param format defines the format of the data
  19033. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19034. * @param noMipmap defines if the engine should avoid generating the mip levels
  19035. * @param callback defines a callback used to extract texture data from loaded data
  19036. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19037. * @param onLoad defines a callback called when texture is loaded
  19038. * @param onError defines a callback called if there is an error
  19039. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19040. * @param invertY defines if data must be stored with Y axis inverted
  19041. * @returns the cube texture as an InternalTexture
  19042. */
  19043. 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;
  19044. /**
  19045. * Creates a new raw 3D texture
  19046. * @param data defines the data used to create the texture
  19047. * @param width defines the width of the texture
  19048. * @param height defines the height of the texture
  19049. * @param depth defines the depth of the texture
  19050. * @param format defines the format of the texture
  19051. * @param generateMipMaps defines if the engine must generate mip levels
  19052. * @param invertY defines if data must be stored with Y axis inverted
  19053. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19054. * @param compression defines the compressed used (can be null)
  19055. * @param textureType defines the compressed used (can be null)
  19056. * @returns a new raw 3D texture (stored in an InternalTexture)
  19057. */
  19058. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19059. /**
  19060. * Update a raw 3D texture
  19061. * @param texture defines the texture to update
  19062. * @param data defines the data to store
  19063. * @param format defines the data format
  19064. * @param invertY defines if data must be stored with Y axis inverted
  19065. */
  19066. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19067. /**
  19068. * Update a raw 3D texture
  19069. * @param texture defines the texture to update
  19070. * @param data defines the data to store
  19071. * @param format defines the data format
  19072. * @param invertY defines if data must be stored with Y axis inverted
  19073. * @param compression defines the used compression (can be null)
  19074. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19075. */
  19076. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19077. }
  19078. }
  19079. }
  19080. declare module "babylonjs/Materials/Textures/rawTexture" {
  19081. import { Scene } from "babylonjs/scene";
  19082. import { Texture } from "babylonjs/Materials/Textures/texture";
  19083. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19084. /**
  19085. * Raw texture can help creating a texture directly from an array of data.
  19086. * This can be super useful if you either get the data from an uncompressed source or
  19087. * if you wish to create your texture pixel by pixel.
  19088. */
  19089. export class RawTexture extends Texture {
  19090. /**
  19091. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19092. */
  19093. format: number;
  19094. private _engine;
  19095. /**
  19096. * Instantiates a new RawTexture.
  19097. * Raw texture can help creating a texture directly from an array of data.
  19098. * This can be super useful if you either get the data from an uncompressed source or
  19099. * if you wish to create your texture pixel by pixel.
  19100. * @param data define the array of data to use to create the texture
  19101. * @param width define the width of the texture
  19102. * @param height define the height of the texture
  19103. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19104. * @param scene define the scene the texture belongs to
  19105. * @param generateMipMaps define whether mip maps should be generated or not
  19106. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19107. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19108. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19109. */
  19110. constructor(data: ArrayBufferView, width: number, height: number,
  19111. /**
  19112. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19113. */
  19114. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19115. /**
  19116. * Updates the texture underlying data.
  19117. * @param data Define the new data of the texture
  19118. */
  19119. update(data: ArrayBufferView): void;
  19120. /**
  19121. * Creates a luminance texture from some data.
  19122. * @param data Define the texture data
  19123. * @param width Define the width of the texture
  19124. * @param height Define the height of the texture
  19125. * @param scene Define the scene the texture belongs to
  19126. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19127. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19128. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19129. * @returns the luminance texture
  19130. */
  19131. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19132. /**
  19133. * Creates a luminance alpha texture from some data.
  19134. * @param data Define the texture data
  19135. * @param width Define the width of the texture
  19136. * @param height Define the height of the texture
  19137. * @param scene Define the scene the texture belongs to
  19138. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19139. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19140. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19141. * @returns the luminance alpha texture
  19142. */
  19143. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19144. /**
  19145. * Creates an alpha texture from some data.
  19146. * @param data Define the texture data
  19147. * @param width Define the width of the texture
  19148. * @param height Define the height of the texture
  19149. * @param scene Define the scene the texture belongs to
  19150. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19151. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19152. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19153. * @returns the alpha texture
  19154. */
  19155. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19156. /**
  19157. * Creates a RGB texture from some data.
  19158. * @param data Define the texture data
  19159. * @param width Define the width of the texture
  19160. * @param height Define the height of the texture
  19161. * @param scene Define the scene the texture belongs to
  19162. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19163. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19164. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19165. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19166. * @returns the RGB alpha texture
  19167. */
  19168. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19169. /**
  19170. * Creates a RGBA texture from some data.
  19171. * @param data Define the texture data
  19172. * @param width Define the width of the texture
  19173. * @param height Define the height of the texture
  19174. * @param scene Define the scene the texture belongs to
  19175. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19176. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19177. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19178. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19179. * @returns the RGBA texture
  19180. */
  19181. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19182. /**
  19183. * Creates a R texture from some data.
  19184. * @param data Define the texture data
  19185. * @param width Define the width of the texture
  19186. * @param height Define the height of the texture
  19187. * @param scene Define the scene the texture belongs to
  19188. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19189. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19190. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19191. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19192. * @returns the R texture
  19193. */
  19194. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19195. }
  19196. }
  19197. declare module "babylonjs/Animations/runtimeAnimation" {
  19198. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19199. import { Animatable } from "babylonjs/Animations/animatable";
  19200. import { Scene } from "babylonjs/scene";
  19201. /**
  19202. * Defines a runtime animation
  19203. */
  19204. export class RuntimeAnimation {
  19205. private _events;
  19206. /**
  19207. * The current frame of the runtime animation
  19208. */
  19209. private _currentFrame;
  19210. /**
  19211. * The animation used by the runtime animation
  19212. */
  19213. private _animation;
  19214. /**
  19215. * The target of the runtime animation
  19216. */
  19217. private _target;
  19218. /**
  19219. * The initiating animatable
  19220. */
  19221. private _host;
  19222. /**
  19223. * The original value of the runtime animation
  19224. */
  19225. private _originalValue;
  19226. /**
  19227. * The original blend value of the runtime animation
  19228. */
  19229. private _originalBlendValue;
  19230. /**
  19231. * The offsets cache of the runtime animation
  19232. */
  19233. private _offsetsCache;
  19234. /**
  19235. * The high limits cache of the runtime animation
  19236. */
  19237. private _highLimitsCache;
  19238. /**
  19239. * Specifies if the runtime animation has been stopped
  19240. */
  19241. private _stopped;
  19242. /**
  19243. * The blending factor of the runtime animation
  19244. */
  19245. private _blendingFactor;
  19246. /**
  19247. * The BabylonJS scene
  19248. */
  19249. private _scene;
  19250. /**
  19251. * The current value of the runtime animation
  19252. */
  19253. private _currentValue;
  19254. /** @hidden */
  19255. _animationState: _IAnimationState;
  19256. /**
  19257. * The active target of the runtime animation
  19258. */
  19259. private _activeTargets;
  19260. private _currentActiveTarget;
  19261. private _directTarget;
  19262. /**
  19263. * The target path of the runtime animation
  19264. */
  19265. private _targetPath;
  19266. /**
  19267. * The weight of the runtime animation
  19268. */
  19269. private _weight;
  19270. /**
  19271. * The ratio offset of the runtime animation
  19272. */
  19273. private _ratioOffset;
  19274. /**
  19275. * The previous delay of the runtime animation
  19276. */
  19277. private _previousDelay;
  19278. /**
  19279. * The previous ratio of the runtime animation
  19280. */
  19281. private _previousRatio;
  19282. private _enableBlending;
  19283. private _keys;
  19284. private _minFrame;
  19285. private _maxFrame;
  19286. private _minValue;
  19287. private _maxValue;
  19288. private _targetIsArray;
  19289. /**
  19290. * Gets the current frame of the runtime animation
  19291. */
  19292. readonly currentFrame: number;
  19293. /**
  19294. * Gets the weight of the runtime animation
  19295. */
  19296. readonly weight: number;
  19297. /**
  19298. * Gets the current value of the runtime animation
  19299. */
  19300. readonly currentValue: any;
  19301. /**
  19302. * Gets the target path of the runtime animation
  19303. */
  19304. readonly targetPath: string;
  19305. /**
  19306. * Gets the actual target of the runtime animation
  19307. */
  19308. readonly target: any;
  19309. /** @hidden */
  19310. _onLoop: () => void;
  19311. /**
  19312. * Create a new RuntimeAnimation object
  19313. * @param target defines the target of the animation
  19314. * @param animation defines the source animation object
  19315. * @param scene defines the hosting scene
  19316. * @param host defines the initiating Animatable
  19317. */
  19318. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19319. private _preparePath;
  19320. /**
  19321. * Gets the animation from the runtime animation
  19322. */
  19323. readonly animation: Animation;
  19324. /**
  19325. * Resets the runtime animation to the beginning
  19326. * @param restoreOriginal defines whether to restore the target property to the original value
  19327. */
  19328. reset(restoreOriginal?: boolean): void;
  19329. /**
  19330. * Specifies if the runtime animation is stopped
  19331. * @returns Boolean specifying if the runtime animation is stopped
  19332. */
  19333. isStopped(): boolean;
  19334. /**
  19335. * Disposes of the runtime animation
  19336. */
  19337. dispose(): void;
  19338. /**
  19339. * Apply the interpolated value to the target
  19340. * @param currentValue defines the value computed by the animation
  19341. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19342. */
  19343. setValue(currentValue: any, weight: number): void;
  19344. private _getOriginalValues;
  19345. private _setValue;
  19346. /**
  19347. * Gets the loop pmode of the runtime animation
  19348. * @returns Loop Mode
  19349. */
  19350. private _getCorrectLoopMode;
  19351. /**
  19352. * Move the current animation to a given frame
  19353. * @param frame defines the frame to move to
  19354. */
  19355. goToFrame(frame: number): void;
  19356. /**
  19357. * @hidden Internal use only
  19358. */
  19359. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19360. /**
  19361. * Execute the current animation
  19362. * @param delay defines the delay to add to the current frame
  19363. * @param from defines the lower bound of the animation range
  19364. * @param to defines the upper bound of the animation range
  19365. * @param loop defines if the current animation must loop
  19366. * @param speedRatio defines the current speed ratio
  19367. * @param weight defines the weight of the animation (default is -1 so no weight)
  19368. * @param onLoop optional callback called when animation loops
  19369. * @returns a boolean indicating if the animation is running
  19370. */
  19371. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19372. }
  19373. }
  19374. declare module "babylonjs/Animations/animatable" {
  19375. import { Animation } from "babylonjs/Animations/animation";
  19376. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19377. import { Nullable } from "babylonjs/types";
  19378. import { Observable } from "babylonjs/Misc/observable";
  19379. import { Scene } from "babylonjs/scene";
  19380. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19381. import { Node } from "babylonjs/node";
  19382. /**
  19383. * Class used to store an actual running animation
  19384. */
  19385. export class Animatable {
  19386. /** defines the target object */
  19387. target: any;
  19388. /** defines the starting frame number (default is 0) */
  19389. fromFrame: number;
  19390. /** defines the ending frame number (default is 100) */
  19391. toFrame: number;
  19392. /** defines if the animation must loop (default is false) */
  19393. loopAnimation: boolean;
  19394. /** defines a callback to call when animation ends if it is not looping */
  19395. onAnimationEnd?: (() => void) | null | undefined;
  19396. /** defines a callback to call when animation loops */
  19397. onAnimationLoop?: (() => void) | null | undefined;
  19398. private _localDelayOffset;
  19399. private _pausedDelay;
  19400. private _runtimeAnimations;
  19401. private _paused;
  19402. private _scene;
  19403. private _speedRatio;
  19404. private _weight;
  19405. private _syncRoot;
  19406. /**
  19407. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19408. * This will only apply for non looping animation (default is true)
  19409. */
  19410. disposeOnEnd: boolean;
  19411. /**
  19412. * Gets a boolean indicating if the animation has started
  19413. */
  19414. animationStarted: boolean;
  19415. /**
  19416. * Observer raised when the animation ends
  19417. */
  19418. onAnimationEndObservable: Observable<Animatable>;
  19419. /**
  19420. * Observer raised when the animation loops
  19421. */
  19422. onAnimationLoopObservable: Observable<Animatable>;
  19423. /**
  19424. * Gets the root Animatable used to synchronize and normalize animations
  19425. */
  19426. readonly syncRoot: Nullable<Animatable>;
  19427. /**
  19428. * Gets the current frame of the first RuntimeAnimation
  19429. * Used to synchronize Animatables
  19430. */
  19431. readonly masterFrame: number;
  19432. /**
  19433. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19434. */
  19435. weight: number;
  19436. /**
  19437. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19438. */
  19439. speedRatio: number;
  19440. /**
  19441. * Creates a new Animatable
  19442. * @param scene defines the hosting scene
  19443. * @param target defines the target object
  19444. * @param fromFrame defines the starting frame number (default is 0)
  19445. * @param toFrame defines the ending frame number (default is 100)
  19446. * @param loopAnimation defines if the animation must loop (default is false)
  19447. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19448. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19449. * @param animations defines a group of animation to add to the new Animatable
  19450. * @param onAnimationLoop defines a callback to call when animation loops
  19451. */
  19452. constructor(scene: Scene,
  19453. /** defines the target object */
  19454. target: any,
  19455. /** defines the starting frame number (default is 0) */
  19456. fromFrame?: number,
  19457. /** defines the ending frame number (default is 100) */
  19458. toFrame?: number,
  19459. /** defines if the animation must loop (default is false) */
  19460. loopAnimation?: boolean, speedRatio?: number,
  19461. /** defines a callback to call when animation ends if it is not looping */
  19462. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19463. /** defines a callback to call when animation loops */
  19464. onAnimationLoop?: (() => void) | null | undefined);
  19465. /**
  19466. * Synchronize and normalize current Animatable with a source Animatable
  19467. * This is useful when using animation weights and when animations are not of the same length
  19468. * @param root defines the root Animatable to synchronize with
  19469. * @returns the current Animatable
  19470. */
  19471. syncWith(root: Animatable): Animatable;
  19472. /**
  19473. * Gets the list of runtime animations
  19474. * @returns an array of RuntimeAnimation
  19475. */
  19476. getAnimations(): RuntimeAnimation[];
  19477. /**
  19478. * Adds more animations to the current animatable
  19479. * @param target defines the target of the animations
  19480. * @param animations defines the new animations to add
  19481. */
  19482. appendAnimations(target: any, animations: Animation[]): void;
  19483. /**
  19484. * Gets the source animation for a specific property
  19485. * @param property defines the propertyu to look for
  19486. * @returns null or the source animation for the given property
  19487. */
  19488. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19489. /**
  19490. * Gets the runtime animation for a specific property
  19491. * @param property defines the propertyu to look for
  19492. * @returns null or the runtime animation for the given property
  19493. */
  19494. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19495. /**
  19496. * Resets the animatable to its original state
  19497. */
  19498. reset(): void;
  19499. /**
  19500. * Allows the animatable to blend with current running animations
  19501. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19502. * @param blendingSpeed defines the blending speed to use
  19503. */
  19504. enableBlending(blendingSpeed: number): void;
  19505. /**
  19506. * Disable animation blending
  19507. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19508. */
  19509. disableBlending(): void;
  19510. /**
  19511. * Jump directly to a given frame
  19512. * @param frame defines the frame to jump to
  19513. */
  19514. goToFrame(frame: number): void;
  19515. /**
  19516. * Pause the animation
  19517. */
  19518. pause(): void;
  19519. /**
  19520. * Restart the animation
  19521. */
  19522. restart(): void;
  19523. private _raiseOnAnimationEnd;
  19524. /**
  19525. * Stop and delete the current animation
  19526. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19527. * @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)
  19528. */
  19529. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19530. /**
  19531. * Wait asynchronously for the animation to end
  19532. * @returns a promise which will be fullfilled when the animation ends
  19533. */
  19534. waitAsync(): Promise<Animatable>;
  19535. /** @hidden */
  19536. _animate(delay: number): boolean;
  19537. }
  19538. module "babylonjs/scene" {
  19539. interface Scene {
  19540. /** @hidden */
  19541. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19542. /** @hidden */
  19543. _processLateAnimationBindingsForMatrices(holder: {
  19544. totalWeight: number;
  19545. animations: RuntimeAnimation[];
  19546. originalValue: Matrix;
  19547. }): any;
  19548. /** @hidden */
  19549. _processLateAnimationBindingsForQuaternions(holder: {
  19550. totalWeight: number;
  19551. animations: RuntimeAnimation[];
  19552. originalValue: Quaternion;
  19553. }, refQuaternion: Quaternion): Quaternion;
  19554. /** @hidden */
  19555. _processLateAnimationBindings(): void;
  19556. /**
  19557. * Will start the animation sequence of a given target
  19558. * @param target defines the target
  19559. * @param from defines from which frame should animation start
  19560. * @param to defines until which frame should animation run.
  19561. * @param weight defines the weight to apply to the animation (1.0 by default)
  19562. * @param loop defines if the animation loops
  19563. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19564. * @param onAnimationEnd defines the function to be executed when the animation ends
  19565. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19566. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19567. * @param onAnimationLoop defines the callback to call when an animation loops
  19568. * @returns the animatable object created for this animation
  19569. */
  19570. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19571. /**
  19572. * Will start the animation sequence of a given target
  19573. * @param target defines the target
  19574. * @param from defines from which frame should animation start
  19575. * @param to defines until which frame should animation run.
  19576. * @param loop defines if the animation loops
  19577. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19578. * @param onAnimationEnd defines the function to be executed when the animation ends
  19579. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19580. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19581. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19582. * @param onAnimationLoop defines the callback to call when an animation loops
  19583. * @returns the animatable object created for this animation
  19584. */
  19585. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19586. /**
  19587. * Will start the animation sequence of a given target and its hierarchy
  19588. * @param target defines the target
  19589. * @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.
  19590. * @param from defines from which frame should animation start
  19591. * @param to defines until which frame should animation run.
  19592. * @param loop defines if the animation loops
  19593. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19594. * @param onAnimationEnd defines the function to be executed when the animation ends
  19595. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19596. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19597. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19598. * @param onAnimationLoop defines the callback to call when an animation loops
  19599. * @returns the list of created animatables
  19600. */
  19601. 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[];
  19602. /**
  19603. * Begin a new animation on a given node
  19604. * @param target defines the target where the animation will take place
  19605. * @param animations defines the list of animations to start
  19606. * @param from defines the initial value
  19607. * @param to defines the final value
  19608. * @param loop defines if you want animation to loop (off by default)
  19609. * @param speedRatio defines the speed ratio to apply to all animations
  19610. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19611. * @param onAnimationLoop defines the callback to call when an animation loops
  19612. * @returns the list of created animatables
  19613. */
  19614. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19615. /**
  19616. * Begin a new animation on a given node and its hierarchy
  19617. * @param target defines the root node where the animation will take place
  19618. * @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.
  19619. * @param animations defines the list of animations to start
  19620. * @param from defines the initial value
  19621. * @param to defines the final value
  19622. * @param loop defines if you want animation to loop (off by default)
  19623. * @param speedRatio defines the speed ratio to apply to all animations
  19624. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19625. * @param onAnimationLoop defines the callback to call when an animation loops
  19626. * @returns the list of animatables created for all nodes
  19627. */
  19628. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19629. /**
  19630. * Gets the animatable associated with a specific target
  19631. * @param target defines the target of the animatable
  19632. * @returns the required animatable if found
  19633. */
  19634. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19635. /**
  19636. * Gets all animatables associated with a given target
  19637. * @param target defines the target to look animatables for
  19638. * @returns an array of Animatables
  19639. */
  19640. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19641. /**
  19642. * Stops and removes all animations that have been applied to the scene
  19643. */
  19644. stopAllAnimations(): void;
  19645. }
  19646. }
  19647. module "babylonjs/Bones/bone" {
  19648. interface Bone {
  19649. /**
  19650. * Copy an animation range from another bone
  19651. * @param source defines the source bone
  19652. * @param rangeName defines the range name to copy
  19653. * @param frameOffset defines the frame offset
  19654. * @param rescaleAsRequired defines if rescaling must be applied if required
  19655. * @param skelDimensionsRatio defines the scaling ratio
  19656. * @returns true if operation was successful
  19657. */
  19658. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19659. }
  19660. }
  19661. }
  19662. declare module "babylonjs/Bones/skeleton" {
  19663. import { Bone } from "babylonjs/Bones/bone";
  19664. import { IAnimatable } from "babylonjs/Misc/tools";
  19665. import { Observable } from "babylonjs/Misc/observable";
  19666. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19667. import { Scene } from "babylonjs/scene";
  19668. import { Nullable } from "babylonjs/types";
  19669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19670. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19671. import { Animatable } from "babylonjs/Animations/animatable";
  19672. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19673. import { Animation } from "babylonjs/Animations/animation";
  19674. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19675. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19676. /**
  19677. * Class used to handle skinning animations
  19678. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19679. */
  19680. export class Skeleton implements IAnimatable {
  19681. /** defines the skeleton name */
  19682. name: string;
  19683. /** defines the skeleton Id */
  19684. id: string;
  19685. /**
  19686. * Defines the list of child bones
  19687. */
  19688. bones: Bone[];
  19689. /**
  19690. * Defines an estimate of the dimension of the skeleton at rest
  19691. */
  19692. dimensionsAtRest: Vector3;
  19693. /**
  19694. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19695. */
  19696. needInitialSkinMatrix: boolean;
  19697. /**
  19698. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19699. */
  19700. overrideMesh: Nullable<AbstractMesh>;
  19701. /**
  19702. * Gets the list of animations attached to this skeleton
  19703. */
  19704. animations: Array<Animation>;
  19705. private _scene;
  19706. private _isDirty;
  19707. private _transformMatrices;
  19708. private _transformMatrixTexture;
  19709. private _meshesWithPoseMatrix;
  19710. private _animatables;
  19711. private _identity;
  19712. private _synchronizedWithMesh;
  19713. private _ranges;
  19714. private _lastAbsoluteTransformsUpdateId;
  19715. private _canUseTextureForBones;
  19716. private _uniqueId;
  19717. /** @hidden */
  19718. _numBonesWithLinkedTransformNode: number;
  19719. /**
  19720. * Specifies if the skeleton should be serialized
  19721. */
  19722. doNotSerialize: boolean;
  19723. private _useTextureToStoreBoneMatrices;
  19724. /**
  19725. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19726. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19727. */
  19728. useTextureToStoreBoneMatrices: boolean;
  19729. private _animationPropertiesOverride;
  19730. /**
  19731. * Gets or sets the animation properties override
  19732. */
  19733. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19734. /**
  19735. * List of inspectable custom properties (used by the Inspector)
  19736. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19737. */
  19738. inspectableCustomProperties: IInspectable[];
  19739. /**
  19740. * An observable triggered before computing the skeleton's matrices
  19741. */
  19742. onBeforeComputeObservable: Observable<Skeleton>;
  19743. /**
  19744. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19745. */
  19746. readonly isUsingTextureForMatrices: boolean;
  19747. /**
  19748. * Gets the unique ID of this skeleton
  19749. */
  19750. readonly uniqueId: number;
  19751. /**
  19752. * Creates a new skeleton
  19753. * @param name defines the skeleton name
  19754. * @param id defines the skeleton Id
  19755. * @param scene defines the hosting scene
  19756. */
  19757. constructor(
  19758. /** defines the skeleton name */
  19759. name: string,
  19760. /** defines the skeleton Id */
  19761. id: string, scene: Scene);
  19762. /**
  19763. * Gets the current object class name.
  19764. * @return the class name
  19765. */
  19766. getClassName(): string;
  19767. /**
  19768. * Returns an array containing the root bones
  19769. * @returns an array containing the root bones
  19770. */
  19771. getChildren(): Array<Bone>;
  19772. /**
  19773. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19774. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19775. * @returns a Float32Array containing matrices data
  19776. */
  19777. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19778. /**
  19779. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19780. * @returns a raw texture containing the data
  19781. */
  19782. getTransformMatrixTexture(): Nullable<RawTexture>;
  19783. /**
  19784. * Gets the current hosting scene
  19785. * @returns a scene object
  19786. */
  19787. getScene(): Scene;
  19788. /**
  19789. * Gets a string representing the current skeleton data
  19790. * @param fullDetails defines a boolean indicating if we want a verbose version
  19791. * @returns a string representing the current skeleton data
  19792. */
  19793. toString(fullDetails?: boolean): string;
  19794. /**
  19795. * Get bone's index searching by name
  19796. * @param name defines bone's name to search for
  19797. * @return the indice of the bone. Returns -1 if not found
  19798. */
  19799. getBoneIndexByName(name: string): number;
  19800. /**
  19801. * Creater a new animation range
  19802. * @param name defines the name of the range
  19803. * @param from defines the start key
  19804. * @param to defines the end key
  19805. */
  19806. createAnimationRange(name: string, from: number, to: number): void;
  19807. /**
  19808. * Delete a specific animation range
  19809. * @param name defines the name of the range
  19810. * @param deleteFrames defines if frames must be removed as well
  19811. */
  19812. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19813. /**
  19814. * Gets a specific animation range
  19815. * @param name defines the name of the range to look for
  19816. * @returns the requested animation range or null if not found
  19817. */
  19818. getAnimationRange(name: string): Nullable<AnimationRange>;
  19819. /**
  19820. * Gets the list of all animation ranges defined on this skeleton
  19821. * @returns an array
  19822. */
  19823. getAnimationRanges(): Nullable<AnimationRange>[];
  19824. /**
  19825. * Copy animation range from a source skeleton.
  19826. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19827. * @param source defines the source skeleton
  19828. * @param name defines the name of the range to copy
  19829. * @param rescaleAsRequired defines if rescaling must be applied if required
  19830. * @returns true if operation was successful
  19831. */
  19832. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19833. /**
  19834. * Forces the skeleton to go to rest pose
  19835. */
  19836. returnToRest(): void;
  19837. private _getHighestAnimationFrame;
  19838. /**
  19839. * Begin a specific animation range
  19840. * @param name defines the name of the range to start
  19841. * @param loop defines if looping must be turned on (false by default)
  19842. * @param speedRatio defines the speed ratio to apply (1 by default)
  19843. * @param onAnimationEnd defines a callback which will be called when animation will end
  19844. * @returns a new animatable
  19845. */
  19846. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19847. /** @hidden */
  19848. _markAsDirty(): void;
  19849. /** @hidden */
  19850. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19851. /** @hidden */
  19852. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19853. private _computeTransformMatrices;
  19854. /**
  19855. * Build all resources required to render a skeleton
  19856. */
  19857. prepare(): void;
  19858. /**
  19859. * Gets the list of animatables currently running for this skeleton
  19860. * @returns an array of animatables
  19861. */
  19862. getAnimatables(): IAnimatable[];
  19863. /**
  19864. * Clone the current skeleton
  19865. * @param name defines the name of the new skeleton
  19866. * @param id defines the id of the new skeleton
  19867. * @returns the new skeleton
  19868. */
  19869. clone(name: string, id: string): Skeleton;
  19870. /**
  19871. * Enable animation blending for this skeleton
  19872. * @param blendingSpeed defines the blending speed to apply
  19873. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19874. */
  19875. enableBlending(blendingSpeed?: number): void;
  19876. /**
  19877. * Releases all resources associated with the current skeleton
  19878. */
  19879. dispose(): void;
  19880. /**
  19881. * Serialize the skeleton in a JSON object
  19882. * @returns a JSON object
  19883. */
  19884. serialize(): any;
  19885. /**
  19886. * Creates a new skeleton from serialized data
  19887. * @param parsedSkeleton defines the serialized data
  19888. * @param scene defines the hosting scene
  19889. * @returns a new skeleton
  19890. */
  19891. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19892. /**
  19893. * Compute all node absolute transforms
  19894. * @param forceUpdate defines if computation must be done even if cache is up to date
  19895. */
  19896. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19897. /**
  19898. * Gets the root pose matrix
  19899. * @returns a matrix
  19900. */
  19901. getPoseMatrix(): Nullable<Matrix>;
  19902. /**
  19903. * Sorts bones per internal index
  19904. */
  19905. sortBones(): void;
  19906. private _sortBones;
  19907. }
  19908. }
  19909. declare module "babylonjs/Morph/morphTarget" {
  19910. import { IAnimatable } from "babylonjs/Misc/tools";
  19911. import { Observable } from "babylonjs/Misc/observable";
  19912. import { Nullable, FloatArray } from "babylonjs/types";
  19913. import { Scene } from "babylonjs/scene";
  19914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19915. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19916. /**
  19917. * Defines a target to use with MorphTargetManager
  19918. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19919. */
  19920. export class MorphTarget implements IAnimatable {
  19921. /** defines the name of the target */
  19922. name: string;
  19923. /**
  19924. * Gets or sets the list of animations
  19925. */
  19926. animations: import("babylonjs/Animations/animation").Animation[];
  19927. private _scene;
  19928. private _positions;
  19929. private _normals;
  19930. private _tangents;
  19931. private _influence;
  19932. /**
  19933. * Observable raised when the influence changes
  19934. */
  19935. onInfluenceChanged: Observable<boolean>;
  19936. /** @hidden */
  19937. _onDataLayoutChanged: Observable<void>;
  19938. /**
  19939. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19940. */
  19941. influence: number;
  19942. /**
  19943. * Gets or sets the id of the morph Target
  19944. */
  19945. id: string;
  19946. private _animationPropertiesOverride;
  19947. /**
  19948. * Gets or sets the animation properties override
  19949. */
  19950. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19951. /**
  19952. * Creates a new MorphTarget
  19953. * @param name defines the name of the target
  19954. * @param influence defines the influence to use
  19955. * @param scene defines the scene the morphtarget belongs to
  19956. */
  19957. constructor(
  19958. /** defines the name of the target */
  19959. name: string, influence?: number, scene?: Nullable<Scene>);
  19960. /**
  19961. * Gets a boolean defining if the target contains position data
  19962. */
  19963. readonly hasPositions: boolean;
  19964. /**
  19965. * Gets a boolean defining if the target contains normal data
  19966. */
  19967. readonly hasNormals: boolean;
  19968. /**
  19969. * Gets a boolean defining if the target contains tangent data
  19970. */
  19971. readonly hasTangents: boolean;
  19972. /**
  19973. * Affects position data to this target
  19974. * @param data defines the position data to use
  19975. */
  19976. setPositions(data: Nullable<FloatArray>): void;
  19977. /**
  19978. * Gets the position data stored in this target
  19979. * @returns a FloatArray containing the position data (or null if not present)
  19980. */
  19981. getPositions(): Nullable<FloatArray>;
  19982. /**
  19983. * Affects normal data to this target
  19984. * @param data defines the normal data to use
  19985. */
  19986. setNormals(data: Nullable<FloatArray>): void;
  19987. /**
  19988. * Gets the normal data stored in this target
  19989. * @returns a FloatArray containing the normal data (or null if not present)
  19990. */
  19991. getNormals(): Nullable<FloatArray>;
  19992. /**
  19993. * Affects tangent data to this target
  19994. * @param data defines the tangent data to use
  19995. */
  19996. setTangents(data: Nullable<FloatArray>): void;
  19997. /**
  19998. * Gets the tangent data stored in this target
  19999. * @returns a FloatArray containing the tangent data (or null if not present)
  20000. */
  20001. getTangents(): Nullable<FloatArray>;
  20002. /**
  20003. * Serializes the current target into a Serialization object
  20004. * @returns the serialized object
  20005. */
  20006. serialize(): any;
  20007. /**
  20008. * Returns the string "MorphTarget"
  20009. * @returns "MorphTarget"
  20010. */
  20011. getClassName(): string;
  20012. /**
  20013. * Creates a new target from serialized data
  20014. * @param serializationObject defines the serialized data to use
  20015. * @returns a new MorphTarget
  20016. */
  20017. static Parse(serializationObject: any): MorphTarget;
  20018. /**
  20019. * Creates a MorphTarget from mesh data
  20020. * @param mesh defines the source mesh
  20021. * @param name defines the name to use for the new target
  20022. * @param influence defines the influence to attach to the target
  20023. * @returns a new MorphTarget
  20024. */
  20025. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20026. }
  20027. }
  20028. declare module "babylonjs/Morph/morphTargetManager" {
  20029. import { Nullable } from "babylonjs/types";
  20030. import { Scene } from "babylonjs/scene";
  20031. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20032. /**
  20033. * This class is used to deform meshes using morphing between different targets
  20034. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20035. */
  20036. export class MorphTargetManager {
  20037. private _targets;
  20038. private _targetInfluenceChangedObservers;
  20039. private _targetDataLayoutChangedObservers;
  20040. private _activeTargets;
  20041. private _scene;
  20042. private _influences;
  20043. private _supportsNormals;
  20044. private _supportsTangents;
  20045. private _vertexCount;
  20046. private _uniqueId;
  20047. private _tempInfluences;
  20048. /**
  20049. * Creates a new MorphTargetManager
  20050. * @param scene defines the current scene
  20051. */
  20052. constructor(scene?: Nullable<Scene>);
  20053. /**
  20054. * Gets the unique ID of this manager
  20055. */
  20056. readonly uniqueId: number;
  20057. /**
  20058. * Gets the number of vertices handled by this manager
  20059. */
  20060. readonly vertexCount: number;
  20061. /**
  20062. * Gets a boolean indicating if this manager supports morphing of normals
  20063. */
  20064. readonly supportsNormals: boolean;
  20065. /**
  20066. * Gets a boolean indicating if this manager supports morphing of tangents
  20067. */
  20068. readonly supportsTangents: boolean;
  20069. /**
  20070. * Gets the number of targets stored in this manager
  20071. */
  20072. readonly numTargets: number;
  20073. /**
  20074. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20075. */
  20076. readonly numInfluencers: number;
  20077. /**
  20078. * Gets the list of influences (one per target)
  20079. */
  20080. readonly influences: Float32Array;
  20081. /**
  20082. * Gets the active target at specified index. An active target is a target with an influence > 0
  20083. * @param index defines the index to check
  20084. * @returns the requested target
  20085. */
  20086. getActiveTarget(index: number): MorphTarget;
  20087. /**
  20088. * Gets the target at specified index
  20089. * @param index defines the index to check
  20090. * @returns the requested target
  20091. */
  20092. getTarget(index: number): MorphTarget;
  20093. /**
  20094. * Add a new target to this manager
  20095. * @param target defines the target to add
  20096. */
  20097. addTarget(target: MorphTarget): void;
  20098. /**
  20099. * Removes a target from the manager
  20100. * @param target defines the target to remove
  20101. */
  20102. removeTarget(target: MorphTarget): void;
  20103. /**
  20104. * Serializes the current manager into a Serialization object
  20105. * @returns the serialized object
  20106. */
  20107. serialize(): any;
  20108. private _syncActiveTargets;
  20109. /**
  20110. * Syncrhonize the targets with all the meshes using this morph target manager
  20111. */
  20112. synchronize(): void;
  20113. /**
  20114. * Creates a new MorphTargetManager from serialized data
  20115. * @param serializationObject defines the serialized data
  20116. * @param scene defines the hosting scene
  20117. * @returns the new MorphTargetManager
  20118. */
  20119. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20120. }
  20121. }
  20122. declare module "babylonjs/Meshes/meshLODLevel" {
  20123. import { Mesh } from "babylonjs/Meshes/mesh";
  20124. import { Nullable } from "babylonjs/types";
  20125. /**
  20126. * Class used to represent a specific level of detail of a mesh
  20127. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20128. */
  20129. export class MeshLODLevel {
  20130. /** Defines the distance where this level should star being displayed */
  20131. distance: number;
  20132. /** Defines the mesh to use to render this level */
  20133. mesh: Nullable<Mesh>;
  20134. /**
  20135. * Creates a new LOD level
  20136. * @param distance defines the distance where this level should star being displayed
  20137. * @param mesh defines the mesh to use to render this level
  20138. */
  20139. constructor(
  20140. /** Defines the distance where this level should star being displayed */
  20141. distance: number,
  20142. /** Defines the mesh to use to render this level */
  20143. mesh: Nullable<Mesh>);
  20144. }
  20145. }
  20146. declare module "babylonjs/Meshes/groundMesh" {
  20147. import { Scene } from "babylonjs/scene";
  20148. import { Vector3 } from "babylonjs/Maths/math";
  20149. import { Mesh } from "babylonjs/Meshes/mesh";
  20150. /**
  20151. * Mesh representing the gorund
  20152. */
  20153. export class GroundMesh extends Mesh {
  20154. /** If octree should be generated */
  20155. generateOctree: boolean;
  20156. private _heightQuads;
  20157. /** @hidden */
  20158. _subdivisionsX: number;
  20159. /** @hidden */
  20160. _subdivisionsY: number;
  20161. /** @hidden */
  20162. _width: number;
  20163. /** @hidden */
  20164. _height: number;
  20165. /** @hidden */
  20166. _minX: number;
  20167. /** @hidden */
  20168. _maxX: number;
  20169. /** @hidden */
  20170. _minZ: number;
  20171. /** @hidden */
  20172. _maxZ: number;
  20173. constructor(name: string, scene: Scene);
  20174. /**
  20175. * "GroundMesh"
  20176. * @returns "GroundMesh"
  20177. */
  20178. getClassName(): string;
  20179. /**
  20180. * The minimum of x and y subdivisions
  20181. */
  20182. readonly subdivisions: number;
  20183. /**
  20184. * X subdivisions
  20185. */
  20186. readonly subdivisionsX: number;
  20187. /**
  20188. * Y subdivisions
  20189. */
  20190. readonly subdivisionsY: number;
  20191. /**
  20192. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20193. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20194. * @param chunksCount the number of subdivisions for x and y
  20195. * @param octreeBlocksSize (Default: 32)
  20196. */
  20197. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20198. /**
  20199. * Returns a height (y) value in the Worl system :
  20200. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20201. * @param x x coordinate
  20202. * @param z z coordinate
  20203. * @returns the ground y position if (x, z) are outside the ground surface.
  20204. */
  20205. getHeightAtCoordinates(x: number, z: number): number;
  20206. /**
  20207. * Returns a normalized vector (Vector3) orthogonal to the ground
  20208. * at the ground coordinates (x, z) expressed in the World system.
  20209. * @param x x coordinate
  20210. * @param z z coordinate
  20211. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20212. */
  20213. getNormalAtCoordinates(x: number, z: number): Vector3;
  20214. /**
  20215. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20216. * at the ground coordinates (x, z) expressed in the World system.
  20217. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20218. * @param x x coordinate
  20219. * @param z z coordinate
  20220. * @param ref vector to store the result
  20221. * @returns the GroundMesh.
  20222. */
  20223. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20224. /**
  20225. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20226. * if the ground has been updated.
  20227. * This can be used in the render loop.
  20228. * @returns the GroundMesh.
  20229. */
  20230. updateCoordinateHeights(): GroundMesh;
  20231. private _getFacetAt;
  20232. private _initHeightQuads;
  20233. private _computeHeightQuads;
  20234. /**
  20235. * Serializes this ground mesh
  20236. * @param serializationObject object to write serialization to
  20237. */
  20238. serialize(serializationObject: any): void;
  20239. /**
  20240. * Parses a serialized ground mesh
  20241. * @param parsedMesh the serialized mesh
  20242. * @param scene the scene to create the ground mesh in
  20243. * @returns the created ground mesh
  20244. */
  20245. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20246. }
  20247. }
  20248. declare module "babylonjs/Physics/physicsJoint" {
  20249. import { Vector3 } from "babylonjs/Maths/math";
  20250. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20251. /**
  20252. * Interface for Physics-Joint data
  20253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20254. */
  20255. export interface PhysicsJointData {
  20256. /**
  20257. * The main pivot of the joint
  20258. */
  20259. mainPivot?: Vector3;
  20260. /**
  20261. * The connected pivot of the joint
  20262. */
  20263. connectedPivot?: Vector3;
  20264. /**
  20265. * The main axis of the joint
  20266. */
  20267. mainAxis?: Vector3;
  20268. /**
  20269. * The connected axis of the joint
  20270. */
  20271. connectedAxis?: Vector3;
  20272. /**
  20273. * The collision of the joint
  20274. */
  20275. collision?: boolean;
  20276. /**
  20277. * Native Oimo/Cannon/Energy data
  20278. */
  20279. nativeParams?: any;
  20280. }
  20281. /**
  20282. * This is a holder class for the physics joint created by the physics plugin
  20283. * It holds a set of functions to control the underlying joint
  20284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20285. */
  20286. export class PhysicsJoint {
  20287. /**
  20288. * The type of the physics joint
  20289. */
  20290. type: number;
  20291. /**
  20292. * The data for the physics joint
  20293. */
  20294. jointData: PhysicsJointData;
  20295. private _physicsJoint;
  20296. protected _physicsPlugin: IPhysicsEnginePlugin;
  20297. /**
  20298. * Initializes the physics joint
  20299. * @param type The type of the physics joint
  20300. * @param jointData The data for the physics joint
  20301. */
  20302. constructor(
  20303. /**
  20304. * The type of the physics joint
  20305. */
  20306. type: number,
  20307. /**
  20308. * The data for the physics joint
  20309. */
  20310. jointData: PhysicsJointData);
  20311. /**
  20312. * Gets the physics joint
  20313. */
  20314. /**
  20315. * Sets the physics joint
  20316. */
  20317. physicsJoint: any;
  20318. /**
  20319. * Sets the physics plugin
  20320. */
  20321. physicsPlugin: IPhysicsEnginePlugin;
  20322. /**
  20323. * Execute a function that is physics-plugin specific.
  20324. * @param {Function} func the function that will be executed.
  20325. * It accepts two parameters: the physics world and the physics joint
  20326. */
  20327. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20328. /**
  20329. * Distance-Joint type
  20330. */
  20331. static DistanceJoint: number;
  20332. /**
  20333. * Hinge-Joint type
  20334. */
  20335. static HingeJoint: number;
  20336. /**
  20337. * Ball-and-Socket joint type
  20338. */
  20339. static BallAndSocketJoint: number;
  20340. /**
  20341. * Wheel-Joint type
  20342. */
  20343. static WheelJoint: number;
  20344. /**
  20345. * Slider-Joint type
  20346. */
  20347. static SliderJoint: number;
  20348. /**
  20349. * Prismatic-Joint type
  20350. */
  20351. static PrismaticJoint: number;
  20352. /**
  20353. * Universal-Joint type
  20354. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20355. */
  20356. static UniversalJoint: number;
  20357. /**
  20358. * Hinge-Joint 2 type
  20359. */
  20360. static Hinge2Joint: number;
  20361. /**
  20362. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20363. */
  20364. static PointToPointJoint: number;
  20365. /**
  20366. * Spring-Joint type
  20367. */
  20368. static SpringJoint: number;
  20369. /**
  20370. * Lock-Joint type
  20371. */
  20372. static LockJoint: number;
  20373. }
  20374. /**
  20375. * A class representing a physics distance joint
  20376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20377. */
  20378. export class DistanceJoint extends PhysicsJoint {
  20379. /**
  20380. *
  20381. * @param jointData The data for the Distance-Joint
  20382. */
  20383. constructor(jointData: DistanceJointData);
  20384. /**
  20385. * Update the predefined distance.
  20386. * @param maxDistance The maximum preferred distance
  20387. * @param minDistance The minimum preferred distance
  20388. */
  20389. updateDistance(maxDistance: number, minDistance?: number): void;
  20390. }
  20391. /**
  20392. * Represents a Motor-Enabled Joint
  20393. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20394. */
  20395. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20396. /**
  20397. * Initializes the Motor-Enabled Joint
  20398. * @param type The type of the joint
  20399. * @param jointData The physica joint data for the joint
  20400. */
  20401. constructor(type: number, jointData: PhysicsJointData);
  20402. /**
  20403. * Set the motor values.
  20404. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20405. * @param force the force to apply
  20406. * @param maxForce max force for this motor.
  20407. */
  20408. setMotor(force?: number, maxForce?: number): void;
  20409. /**
  20410. * Set the motor's limits.
  20411. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20412. * @param upperLimit The upper limit of the motor
  20413. * @param lowerLimit The lower limit of the motor
  20414. */
  20415. setLimit(upperLimit: number, lowerLimit?: number): void;
  20416. }
  20417. /**
  20418. * This class represents a single physics Hinge-Joint
  20419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20420. */
  20421. export class HingeJoint extends MotorEnabledJoint {
  20422. /**
  20423. * Initializes the Hinge-Joint
  20424. * @param jointData The joint data for the Hinge-Joint
  20425. */
  20426. constructor(jointData: PhysicsJointData);
  20427. /**
  20428. * Set the motor values.
  20429. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20430. * @param {number} force the force to apply
  20431. * @param {number} maxForce max force for this motor.
  20432. */
  20433. setMotor(force?: number, maxForce?: number): void;
  20434. /**
  20435. * Set the motor's limits.
  20436. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20437. * @param upperLimit The upper limit of the motor
  20438. * @param lowerLimit The lower limit of the motor
  20439. */
  20440. setLimit(upperLimit: number, lowerLimit?: number): void;
  20441. }
  20442. /**
  20443. * This class represents a dual hinge physics joint (same as wheel joint)
  20444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20445. */
  20446. export class Hinge2Joint extends MotorEnabledJoint {
  20447. /**
  20448. * Initializes the Hinge2-Joint
  20449. * @param jointData The joint data for the Hinge2-Joint
  20450. */
  20451. constructor(jointData: PhysicsJointData);
  20452. /**
  20453. * Set the motor values.
  20454. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20455. * @param {number} targetSpeed the speed the motor is to reach
  20456. * @param {number} maxForce max force for this motor.
  20457. * @param {motorIndex} the motor's index, 0 or 1.
  20458. */
  20459. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20460. /**
  20461. * Set the motor limits.
  20462. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20463. * @param {number} upperLimit the upper limit
  20464. * @param {number} lowerLimit lower limit
  20465. * @param {motorIndex} the motor's index, 0 or 1.
  20466. */
  20467. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20468. }
  20469. /**
  20470. * Interface for a motor enabled joint
  20471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20472. */
  20473. export interface IMotorEnabledJoint {
  20474. /**
  20475. * Physics joint
  20476. */
  20477. physicsJoint: any;
  20478. /**
  20479. * Sets the motor of the motor-enabled joint
  20480. * @param force The force of the motor
  20481. * @param maxForce The maximum force of the motor
  20482. * @param motorIndex The index of the motor
  20483. */
  20484. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20485. /**
  20486. * Sets the limit of the motor
  20487. * @param upperLimit The upper limit of the motor
  20488. * @param lowerLimit The lower limit of the motor
  20489. * @param motorIndex The index of the motor
  20490. */
  20491. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20492. }
  20493. /**
  20494. * Joint data for a Distance-Joint
  20495. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20496. */
  20497. export interface DistanceJointData extends PhysicsJointData {
  20498. /**
  20499. * Max distance the 2 joint objects can be apart
  20500. */
  20501. maxDistance: number;
  20502. }
  20503. /**
  20504. * Joint data from a spring joint
  20505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20506. */
  20507. export interface SpringJointData extends PhysicsJointData {
  20508. /**
  20509. * Length of the spring
  20510. */
  20511. length: number;
  20512. /**
  20513. * Stiffness of the spring
  20514. */
  20515. stiffness: number;
  20516. /**
  20517. * Damping of the spring
  20518. */
  20519. damping: number;
  20520. /** this callback will be called when applying the force to the impostors. */
  20521. forceApplicationCallback: () => void;
  20522. }
  20523. }
  20524. declare module "babylonjs/Physics/physicsRaycastResult" {
  20525. import { Vector3 } from "babylonjs/Maths/math";
  20526. /**
  20527. * Holds the data for the raycast result
  20528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20529. */
  20530. export class PhysicsRaycastResult {
  20531. private _hasHit;
  20532. private _hitDistance;
  20533. private _hitNormalWorld;
  20534. private _hitPointWorld;
  20535. private _rayFromWorld;
  20536. private _rayToWorld;
  20537. /**
  20538. * Gets if there was a hit
  20539. */
  20540. readonly hasHit: boolean;
  20541. /**
  20542. * Gets the distance from the hit
  20543. */
  20544. readonly hitDistance: number;
  20545. /**
  20546. * Gets the hit normal/direction in the world
  20547. */
  20548. readonly hitNormalWorld: Vector3;
  20549. /**
  20550. * Gets the hit point in the world
  20551. */
  20552. readonly hitPointWorld: Vector3;
  20553. /**
  20554. * Gets the ray "start point" of the ray in the world
  20555. */
  20556. readonly rayFromWorld: Vector3;
  20557. /**
  20558. * Gets the ray "end point" of the ray in the world
  20559. */
  20560. readonly rayToWorld: Vector3;
  20561. /**
  20562. * Sets the hit data (normal & point in world space)
  20563. * @param hitNormalWorld defines the normal in world space
  20564. * @param hitPointWorld defines the point in world space
  20565. */
  20566. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20567. /**
  20568. * Sets the distance from the start point to the hit point
  20569. * @param distance
  20570. */
  20571. setHitDistance(distance: number): void;
  20572. /**
  20573. * Calculates the distance manually
  20574. */
  20575. calculateHitDistance(): void;
  20576. /**
  20577. * Resets all the values to default
  20578. * @param from The from point on world space
  20579. * @param to The to point on world space
  20580. */
  20581. reset(from?: Vector3, to?: Vector3): void;
  20582. }
  20583. /**
  20584. * Interface for the size containing width and height
  20585. */
  20586. interface IXYZ {
  20587. /**
  20588. * X
  20589. */
  20590. x: number;
  20591. /**
  20592. * Y
  20593. */
  20594. y: number;
  20595. /**
  20596. * Z
  20597. */
  20598. z: number;
  20599. }
  20600. }
  20601. declare module "babylonjs/Physics/IPhysicsEngine" {
  20602. import { Nullable } from "babylonjs/types";
  20603. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20605. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20606. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20607. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20608. /**
  20609. * Interface used to describe a physics joint
  20610. */
  20611. export interface PhysicsImpostorJoint {
  20612. /** Defines the main impostor to which the joint is linked */
  20613. mainImpostor: PhysicsImpostor;
  20614. /** Defines the impostor that is connected to the main impostor using this joint */
  20615. connectedImpostor: PhysicsImpostor;
  20616. /** Defines the joint itself */
  20617. joint: PhysicsJoint;
  20618. }
  20619. /** @hidden */
  20620. export interface IPhysicsEnginePlugin {
  20621. world: any;
  20622. name: string;
  20623. setGravity(gravity: Vector3): void;
  20624. setTimeStep(timeStep: number): void;
  20625. getTimeStep(): number;
  20626. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20627. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20628. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20629. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20630. removePhysicsBody(impostor: PhysicsImpostor): void;
  20631. generateJoint(joint: PhysicsImpostorJoint): void;
  20632. removeJoint(joint: PhysicsImpostorJoint): void;
  20633. isSupported(): boolean;
  20634. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20635. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20636. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20637. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20638. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20639. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20640. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20641. getBodyMass(impostor: PhysicsImpostor): number;
  20642. getBodyFriction(impostor: PhysicsImpostor): number;
  20643. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20644. getBodyRestitution(impostor: PhysicsImpostor): number;
  20645. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20646. getBodyPressure?(impostor: PhysicsImpostor): number;
  20647. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20648. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20649. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20650. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20651. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20652. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20653. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20654. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20655. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20656. sleepBody(impostor: PhysicsImpostor): void;
  20657. wakeUpBody(impostor: PhysicsImpostor): void;
  20658. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20659. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20660. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20661. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20662. getRadius(impostor: PhysicsImpostor): number;
  20663. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20664. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20665. dispose(): void;
  20666. }
  20667. /**
  20668. * Interface used to define a physics engine
  20669. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20670. */
  20671. export interface IPhysicsEngine {
  20672. /**
  20673. * Gets the gravity vector used by the simulation
  20674. */
  20675. gravity: Vector3;
  20676. /**
  20677. * Sets the gravity vector used by the simulation
  20678. * @param gravity defines the gravity vector to use
  20679. */
  20680. setGravity(gravity: Vector3): void;
  20681. /**
  20682. * Set the time step of the physics engine.
  20683. * Default is 1/60.
  20684. * To slow it down, enter 1/600 for example.
  20685. * To speed it up, 1/30
  20686. * @param newTimeStep the new timestep to apply to this world.
  20687. */
  20688. setTimeStep(newTimeStep: number): void;
  20689. /**
  20690. * Get the time step of the physics engine.
  20691. * @returns the current time step
  20692. */
  20693. getTimeStep(): number;
  20694. /**
  20695. * Release all resources
  20696. */
  20697. dispose(): void;
  20698. /**
  20699. * Gets the name of the current physics plugin
  20700. * @returns the name of the plugin
  20701. */
  20702. getPhysicsPluginName(): string;
  20703. /**
  20704. * Adding a new impostor for the impostor tracking.
  20705. * This will be done by the impostor itself.
  20706. * @param impostor the impostor to add
  20707. */
  20708. addImpostor(impostor: PhysicsImpostor): void;
  20709. /**
  20710. * Remove an impostor from the engine.
  20711. * This impostor and its mesh will not longer be updated by the physics engine.
  20712. * @param impostor the impostor to remove
  20713. */
  20714. removeImpostor(impostor: PhysicsImpostor): void;
  20715. /**
  20716. * Add a joint to the physics engine
  20717. * @param mainImpostor defines the main impostor to which the joint is added.
  20718. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20719. * @param joint defines the joint that will connect both impostors.
  20720. */
  20721. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20722. /**
  20723. * Removes a joint from the simulation
  20724. * @param mainImpostor defines the impostor used with the joint
  20725. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20726. * @param joint defines the joint to remove
  20727. */
  20728. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20729. /**
  20730. * Gets the current plugin used to run the simulation
  20731. * @returns current plugin
  20732. */
  20733. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20734. /**
  20735. * Gets the list of physic impostors
  20736. * @returns an array of PhysicsImpostor
  20737. */
  20738. getImpostors(): Array<PhysicsImpostor>;
  20739. /**
  20740. * Gets the impostor for a physics enabled object
  20741. * @param object defines the object impersonated by the impostor
  20742. * @returns the PhysicsImpostor or null if not found
  20743. */
  20744. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20745. /**
  20746. * Gets the impostor for a physics body object
  20747. * @param body defines physics body used by the impostor
  20748. * @returns the PhysicsImpostor or null if not found
  20749. */
  20750. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20751. /**
  20752. * Does a raycast in the physics world
  20753. * @param from when should the ray start?
  20754. * @param to when should the ray end?
  20755. * @returns PhysicsRaycastResult
  20756. */
  20757. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20758. /**
  20759. * Called by the scene. No need to call it.
  20760. * @param delta defines the timespam between frames
  20761. */
  20762. _step(delta: number): void;
  20763. }
  20764. }
  20765. declare module "babylonjs/Physics/physicsImpostor" {
  20766. import { Nullable, IndicesArray } from "babylonjs/types";
  20767. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20768. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20770. import { Scene } from "babylonjs/scene";
  20771. import { Bone } from "babylonjs/Bones/bone";
  20772. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20773. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20774. /**
  20775. * The interface for the physics imposter parameters
  20776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20777. */
  20778. export interface PhysicsImpostorParameters {
  20779. /**
  20780. * The mass of the physics imposter
  20781. */
  20782. mass: number;
  20783. /**
  20784. * The friction of the physics imposter
  20785. */
  20786. friction?: number;
  20787. /**
  20788. * The coefficient of restitution of the physics imposter
  20789. */
  20790. restitution?: number;
  20791. /**
  20792. * The native options of the physics imposter
  20793. */
  20794. nativeOptions?: any;
  20795. /**
  20796. * Specifies if the parent should be ignored
  20797. */
  20798. ignoreParent?: boolean;
  20799. /**
  20800. * Specifies if bi-directional transformations should be disabled
  20801. */
  20802. disableBidirectionalTransformation?: boolean;
  20803. /**
  20804. * The pressure inside the physics imposter, soft object only
  20805. */
  20806. pressure?: number;
  20807. /**
  20808. * The stiffness the physics imposter, soft object only
  20809. */
  20810. stiffness?: number;
  20811. /**
  20812. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20813. */
  20814. velocityIterations?: number;
  20815. /**
  20816. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20817. */
  20818. positionIterations?: number;
  20819. /**
  20820. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20821. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20822. * Add to fix multiple points
  20823. */
  20824. fixedPoints?: number;
  20825. /**
  20826. * The collision margin around a soft object
  20827. */
  20828. margin?: number;
  20829. /**
  20830. * The collision margin around a soft object
  20831. */
  20832. damping?: number;
  20833. /**
  20834. * The path for a rope based on an extrusion
  20835. */
  20836. path?: any;
  20837. /**
  20838. * The shape of an extrusion used for a rope based on an extrusion
  20839. */
  20840. shape?: any;
  20841. }
  20842. /**
  20843. * Interface for a physics-enabled object
  20844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20845. */
  20846. export interface IPhysicsEnabledObject {
  20847. /**
  20848. * The position of the physics-enabled object
  20849. */
  20850. position: Vector3;
  20851. /**
  20852. * The rotation of the physics-enabled object
  20853. */
  20854. rotationQuaternion: Nullable<Quaternion>;
  20855. /**
  20856. * The scale of the physics-enabled object
  20857. */
  20858. scaling: Vector3;
  20859. /**
  20860. * The rotation of the physics-enabled object
  20861. */
  20862. rotation?: Vector3;
  20863. /**
  20864. * The parent of the physics-enabled object
  20865. */
  20866. parent?: any;
  20867. /**
  20868. * The bounding info of the physics-enabled object
  20869. * @returns The bounding info of the physics-enabled object
  20870. */
  20871. getBoundingInfo(): BoundingInfo;
  20872. /**
  20873. * Computes the world matrix
  20874. * @param force Specifies if the world matrix should be computed by force
  20875. * @returns A world matrix
  20876. */
  20877. computeWorldMatrix(force: boolean): Matrix;
  20878. /**
  20879. * Gets the world matrix
  20880. * @returns A world matrix
  20881. */
  20882. getWorldMatrix?(): Matrix;
  20883. /**
  20884. * Gets the child meshes
  20885. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20886. * @returns An array of abstract meshes
  20887. */
  20888. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20889. /**
  20890. * Gets the vertex data
  20891. * @param kind The type of vertex data
  20892. * @returns A nullable array of numbers, or a float32 array
  20893. */
  20894. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20895. /**
  20896. * Gets the indices from the mesh
  20897. * @returns A nullable array of index arrays
  20898. */
  20899. getIndices?(): Nullable<IndicesArray>;
  20900. /**
  20901. * Gets the scene from the mesh
  20902. * @returns the indices array or null
  20903. */
  20904. getScene?(): Scene;
  20905. /**
  20906. * Gets the absolute position from the mesh
  20907. * @returns the absolute position
  20908. */
  20909. getAbsolutePosition(): Vector3;
  20910. /**
  20911. * Gets the absolute pivot point from the mesh
  20912. * @returns the absolute pivot point
  20913. */
  20914. getAbsolutePivotPoint(): Vector3;
  20915. /**
  20916. * Rotates the mesh
  20917. * @param axis The axis of rotation
  20918. * @param amount The amount of rotation
  20919. * @param space The space of the rotation
  20920. * @returns The rotation transform node
  20921. */
  20922. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20923. /**
  20924. * Translates the mesh
  20925. * @param axis The axis of translation
  20926. * @param distance The distance of translation
  20927. * @param space The space of the translation
  20928. * @returns The transform node
  20929. */
  20930. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20931. /**
  20932. * Sets the absolute position of the mesh
  20933. * @param absolutePosition The absolute position of the mesh
  20934. * @returns The transform node
  20935. */
  20936. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20937. /**
  20938. * Gets the class name of the mesh
  20939. * @returns The class name
  20940. */
  20941. getClassName(): string;
  20942. }
  20943. /**
  20944. * Represents a physics imposter
  20945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20946. */
  20947. export class PhysicsImpostor {
  20948. /**
  20949. * The physics-enabled object used as the physics imposter
  20950. */
  20951. object: IPhysicsEnabledObject;
  20952. /**
  20953. * The type of the physics imposter
  20954. */
  20955. type: number;
  20956. private _options;
  20957. private _scene?;
  20958. /**
  20959. * The default object size of the imposter
  20960. */
  20961. static DEFAULT_OBJECT_SIZE: Vector3;
  20962. /**
  20963. * The identity quaternion of the imposter
  20964. */
  20965. static IDENTITY_QUATERNION: Quaternion;
  20966. /** @hidden */
  20967. _pluginData: any;
  20968. private _physicsEngine;
  20969. private _physicsBody;
  20970. private _bodyUpdateRequired;
  20971. private _onBeforePhysicsStepCallbacks;
  20972. private _onAfterPhysicsStepCallbacks;
  20973. /** @hidden */
  20974. _onPhysicsCollideCallbacks: Array<{
  20975. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20976. otherImpostors: Array<PhysicsImpostor>;
  20977. }>;
  20978. private _deltaPosition;
  20979. private _deltaRotation;
  20980. private _deltaRotationConjugated;
  20981. /** hidden */
  20982. _isFromLine: boolean;
  20983. private _parent;
  20984. private _isDisposed;
  20985. private static _tmpVecs;
  20986. private static _tmpQuat;
  20987. /**
  20988. * Specifies if the physics imposter is disposed
  20989. */
  20990. readonly isDisposed: boolean;
  20991. /**
  20992. * Gets the mass of the physics imposter
  20993. */
  20994. mass: number;
  20995. /**
  20996. * Gets the coefficient of friction
  20997. */
  20998. /**
  20999. * Sets the coefficient of friction
  21000. */
  21001. friction: number;
  21002. /**
  21003. * Gets the coefficient of restitution
  21004. */
  21005. /**
  21006. * Sets the coefficient of restitution
  21007. */
  21008. restitution: number;
  21009. /**
  21010. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  21011. */
  21012. /**
  21013. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21014. */
  21015. pressure: number;
  21016. /**
  21017. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21018. */
  21019. /**
  21020. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21021. */
  21022. stiffness: number;
  21023. /**
  21024. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21025. */
  21026. /**
  21027. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21028. */
  21029. velocityIterations: number;
  21030. /**
  21031. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21032. */
  21033. /**
  21034. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21035. */
  21036. positionIterations: number;
  21037. /**
  21038. * The unique id of the physics imposter
  21039. * set by the physics engine when adding this impostor to the array
  21040. */
  21041. uniqueId: number;
  21042. /**
  21043. * @hidden
  21044. */
  21045. soft: boolean;
  21046. /**
  21047. * @hidden
  21048. */
  21049. segments: number;
  21050. private _joints;
  21051. /**
  21052. * Initializes the physics imposter
  21053. * @param object The physics-enabled object used as the physics imposter
  21054. * @param type The type of the physics imposter
  21055. * @param _options The options for the physics imposter
  21056. * @param _scene The Babylon scene
  21057. */
  21058. constructor(
  21059. /**
  21060. * The physics-enabled object used as the physics imposter
  21061. */
  21062. object: IPhysicsEnabledObject,
  21063. /**
  21064. * The type of the physics imposter
  21065. */
  21066. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21067. /**
  21068. * This function will completly initialize this impostor.
  21069. * It will create a new body - but only if this mesh has no parent.
  21070. * If it has, this impostor will not be used other than to define the impostor
  21071. * of the child mesh.
  21072. * @hidden
  21073. */
  21074. _init(): void;
  21075. private _getPhysicsParent;
  21076. /**
  21077. * Should a new body be generated.
  21078. * @returns boolean specifying if body initialization is required
  21079. */
  21080. isBodyInitRequired(): boolean;
  21081. /**
  21082. * Sets the updated scaling
  21083. * @param updated Specifies if the scaling is updated
  21084. */
  21085. setScalingUpdated(): void;
  21086. /**
  21087. * Force a regeneration of this or the parent's impostor's body.
  21088. * Use under cautious - This will remove all joints already implemented.
  21089. */
  21090. forceUpdate(): void;
  21091. /**
  21092. * Gets the body that holds this impostor. Either its own, or its parent.
  21093. */
  21094. /**
  21095. * Set the physics body. Used mainly by the physics engine/plugin
  21096. */
  21097. physicsBody: any;
  21098. /**
  21099. * Get the parent of the physics imposter
  21100. * @returns Physics imposter or null
  21101. */
  21102. /**
  21103. * Sets the parent of the physics imposter
  21104. */
  21105. parent: Nullable<PhysicsImpostor>;
  21106. /**
  21107. * Resets the update flags
  21108. */
  21109. resetUpdateFlags(): void;
  21110. /**
  21111. * Gets the object extend size
  21112. * @returns the object extend size
  21113. */
  21114. getObjectExtendSize(): Vector3;
  21115. /**
  21116. * Gets the object center
  21117. * @returns The object center
  21118. */
  21119. getObjectCenter(): Vector3;
  21120. /**
  21121. * Get a specific parametes from the options parameter
  21122. * @param paramName The object parameter name
  21123. * @returns The object parameter
  21124. */
  21125. getParam(paramName: string): any;
  21126. /**
  21127. * Sets a specific parameter in the options given to the physics plugin
  21128. * @param paramName The parameter name
  21129. * @param value The value of the parameter
  21130. */
  21131. setParam(paramName: string, value: number): void;
  21132. /**
  21133. * Specifically change the body's mass option. Won't recreate the physics body object
  21134. * @param mass The mass of the physics imposter
  21135. */
  21136. setMass(mass: number): void;
  21137. /**
  21138. * Gets the linear velocity
  21139. * @returns linear velocity or null
  21140. */
  21141. getLinearVelocity(): Nullable<Vector3>;
  21142. /**
  21143. * Sets the linear velocity
  21144. * @param velocity linear velocity or null
  21145. */
  21146. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21147. /**
  21148. * Gets the angular velocity
  21149. * @returns angular velocity or null
  21150. */
  21151. getAngularVelocity(): Nullable<Vector3>;
  21152. /**
  21153. * Sets the angular velocity
  21154. * @param velocity The velocity or null
  21155. */
  21156. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21157. /**
  21158. * Execute a function with the physics plugin native code
  21159. * Provide a function the will have two variables - the world object and the physics body object
  21160. * @param func The function to execute with the physics plugin native code
  21161. */
  21162. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21163. /**
  21164. * Register a function that will be executed before the physics world is stepping forward
  21165. * @param func The function to execute before the physics world is stepped forward
  21166. */
  21167. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21168. /**
  21169. * Unregister a function that will be executed before the physics world is stepping forward
  21170. * @param func The function to execute before the physics world is stepped forward
  21171. */
  21172. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21173. /**
  21174. * Register a function that will be executed after the physics step
  21175. * @param func The function to execute after physics step
  21176. */
  21177. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21178. /**
  21179. * Unregisters a function that will be executed after the physics step
  21180. * @param func The function to execute after physics step
  21181. */
  21182. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21183. /**
  21184. * register a function that will be executed when this impostor collides against a different body
  21185. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21186. * @param func Callback that is executed on collision
  21187. */
  21188. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21189. /**
  21190. * Unregisters the physics imposter on contact
  21191. * @param collideAgainst The physics object to collide against
  21192. * @param func Callback to execute on collision
  21193. */
  21194. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21195. private _tmpQuat;
  21196. private _tmpQuat2;
  21197. /**
  21198. * Get the parent rotation
  21199. * @returns The parent rotation
  21200. */
  21201. getParentsRotation(): Quaternion;
  21202. /**
  21203. * this function is executed by the physics engine.
  21204. */
  21205. beforeStep: () => void;
  21206. /**
  21207. * this function is executed by the physics engine
  21208. */
  21209. afterStep: () => void;
  21210. /**
  21211. * Legacy collision detection event support
  21212. */
  21213. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21214. /**
  21215. * event and body object due to cannon's event-based architecture.
  21216. */
  21217. onCollide: (e: {
  21218. body: any;
  21219. }) => void;
  21220. /**
  21221. * Apply a force
  21222. * @param force The force to apply
  21223. * @param contactPoint The contact point for the force
  21224. * @returns The physics imposter
  21225. */
  21226. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21227. /**
  21228. * Apply an impulse
  21229. * @param force The impulse force
  21230. * @param contactPoint The contact point for the impulse force
  21231. * @returns The physics imposter
  21232. */
  21233. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21234. /**
  21235. * A help function to create a joint
  21236. * @param otherImpostor A physics imposter used to create a joint
  21237. * @param jointType The type of joint
  21238. * @param jointData The data for the joint
  21239. * @returns The physics imposter
  21240. */
  21241. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21242. /**
  21243. * Add a joint to this impostor with a different impostor
  21244. * @param otherImpostor A physics imposter used to add a joint
  21245. * @param joint The joint to add
  21246. * @returns The physics imposter
  21247. */
  21248. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21249. /**
  21250. * Add an anchor to a cloth impostor
  21251. * @param otherImpostor rigid impostor to anchor to
  21252. * @param width ratio across width from 0 to 1
  21253. * @param height ratio up height from 0 to 1
  21254. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21255. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21256. * @returns impostor the soft imposter
  21257. */
  21258. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21259. /**
  21260. * Add a hook to a rope impostor
  21261. * @param otherImpostor rigid impostor to anchor to
  21262. * @param length ratio across rope from 0 to 1
  21263. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21264. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21265. * @returns impostor the rope imposter
  21266. */
  21267. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21268. /**
  21269. * Will keep this body still, in a sleep mode.
  21270. * @returns the physics imposter
  21271. */
  21272. sleep(): PhysicsImpostor;
  21273. /**
  21274. * Wake the body up.
  21275. * @returns The physics imposter
  21276. */
  21277. wakeUp(): PhysicsImpostor;
  21278. /**
  21279. * Clones the physics imposter
  21280. * @param newObject The physics imposter clones to this physics-enabled object
  21281. * @returns A nullable physics imposter
  21282. */
  21283. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21284. /**
  21285. * Disposes the physics imposter
  21286. */
  21287. dispose(): void;
  21288. /**
  21289. * Sets the delta position
  21290. * @param position The delta position amount
  21291. */
  21292. setDeltaPosition(position: Vector3): void;
  21293. /**
  21294. * Sets the delta rotation
  21295. * @param rotation The delta rotation amount
  21296. */
  21297. setDeltaRotation(rotation: Quaternion): void;
  21298. /**
  21299. * Gets the box size of the physics imposter and stores the result in the input parameter
  21300. * @param result Stores the box size
  21301. * @returns The physics imposter
  21302. */
  21303. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21304. /**
  21305. * Gets the radius of the physics imposter
  21306. * @returns Radius of the physics imposter
  21307. */
  21308. getRadius(): number;
  21309. /**
  21310. * Sync a bone with this impostor
  21311. * @param bone The bone to sync to the impostor.
  21312. * @param boneMesh The mesh that the bone is influencing.
  21313. * @param jointPivot The pivot of the joint / bone in local space.
  21314. * @param distToJoint Optional distance from the impostor to the joint.
  21315. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21316. */
  21317. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21318. /**
  21319. * Sync impostor to a bone
  21320. * @param bone The bone that the impostor will be synced to.
  21321. * @param boneMesh The mesh that the bone is influencing.
  21322. * @param jointPivot The pivot of the joint / bone in local space.
  21323. * @param distToJoint Optional distance from the impostor to the joint.
  21324. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21325. * @param boneAxis Optional vector3 axis the bone is aligned with
  21326. */
  21327. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21328. /**
  21329. * No-Imposter type
  21330. */
  21331. static NoImpostor: number;
  21332. /**
  21333. * Sphere-Imposter type
  21334. */
  21335. static SphereImpostor: number;
  21336. /**
  21337. * Box-Imposter type
  21338. */
  21339. static BoxImpostor: number;
  21340. /**
  21341. * Plane-Imposter type
  21342. */
  21343. static PlaneImpostor: number;
  21344. /**
  21345. * Mesh-imposter type
  21346. */
  21347. static MeshImpostor: number;
  21348. /**
  21349. * Cylinder-Imposter type
  21350. */
  21351. static CylinderImpostor: number;
  21352. /**
  21353. * Particle-Imposter type
  21354. */
  21355. static ParticleImpostor: number;
  21356. /**
  21357. * Heightmap-Imposter type
  21358. */
  21359. static HeightmapImpostor: number;
  21360. /**
  21361. * ConvexHull-Impostor type (Ammo.js plugin only)
  21362. */
  21363. static ConvexHullImpostor: number;
  21364. /**
  21365. * Rope-Imposter type
  21366. */
  21367. static RopeImpostor: number;
  21368. /**
  21369. * Cloth-Imposter type
  21370. */
  21371. static ClothImpostor: number;
  21372. /**
  21373. * Softbody-Imposter type
  21374. */
  21375. static SoftbodyImpostor: number;
  21376. }
  21377. }
  21378. declare module "babylonjs/Meshes/mesh" {
  21379. import { Observable } from "babylonjs/Misc/observable";
  21380. import { IAnimatable } from "babylonjs/Misc/tools";
  21381. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21382. import { Camera } from "babylonjs/Cameras/camera";
  21383. import { Scene } from "babylonjs/scene";
  21384. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21385. import { Engine } from "babylonjs/Engines/engine";
  21386. import { Node } from "babylonjs/node";
  21387. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21388. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21389. import { Buffer } from "babylonjs/Meshes/buffer";
  21390. import { Geometry } from "babylonjs/Meshes/geometry";
  21391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21392. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21393. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21394. import { Effect } from "babylonjs/Materials/effect";
  21395. import { Material } from "babylonjs/Materials/material";
  21396. import { Skeleton } from "babylonjs/Bones/skeleton";
  21397. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21398. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21399. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21400. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21401. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21402. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21403. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21404. /**
  21405. * @hidden
  21406. **/
  21407. export class _CreationDataStorage {
  21408. closePath?: boolean;
  21409. closeArray?: boolean;
  21410. idx: number[];
  21411. dashSize: number;
  21412. gapSize: number;
  21413. path3D: Path3D;
  21414. pathArray: Vector3[][];
  21415. arc: number;
  21416. radius: number;
  21417. cap: number;
  21418. tessellation: number;
  21419. }
  21420. /**
  21421. * @hidden
  21422. **/
  21423. class _InstanceDataStorage {
  21424. visibleInstances: any;
  21425. batchCache: _InstancesBatch;
  21426. instancesBufferSize: number;
  21427. instancesBuffer: Nullable<Buffer>;
  21428. instancesData: Float32Array;
  21429. overridenInstanceCount: number;
  21430. isFrozen: boolean;
  21431. previousBatch: _InstancesBatch;
  21432. hardwareInstancedRendering: boolean;
  21433. sideOrientation: number;
  21434. }
  21435. /**
  21436. * @hidden
  21437. **/
  21438. export class _InstancesBatch {
  21439. mustReturn: boolean;
  21440. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21441. renderSelf: boolean[];
  21442. hardwareInstancedRendering: boolean[];
  21443. }
  21444. /**
  21445. * Class used to represent renderable models
  21446. */
  21447. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21448. /**
  21449. * Mesh side orientation : usually the external or front surface
  21450. */
  21451. static readonly FRONTSIDE: number;
  21452. /**
  21453. * Mesh side orientation : usually the internal or back surface
  21454. */
  21455. static readonly BACKSIDE: number;
  21456. /**
  21457. * Mesh side orientation : both internal and external or front and back surfaces
  21458. */
  21459. static readonly DOUBLESIDE: number;
  21460. /**
  21461. * Mesh side orientation : by default, `FRONTSIDE`
  21462. */
  21463. static readonly DEFAULTSIDE: number;
  21464. /**
  21465. * Mesh cap setting : no cap
  21466. */
  21467. static readonly NO_CAP: number;
  21468. /**
  21469. * Mesh cap setting : one cap at the beginning of the mesh
  21470. */
  21471. static readonly CAP_START: number;
  21472. /**
  21473. * Mesh cap setting : one cap at the end of the mesh
  21474. */
  21475. static readonly CAP_END: number;
  21476. /**
  21477. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21478. */
  21479. static readonly CAP_ALL: number;
  21480. /**
  21481. * Gets the default side orientation.
  21482. * @param orientation the orientation to value to attempt to get
  21483. * @returns the default orientation
  21484. * @hidden
  21485. */
  21486. static _GetDefaultSideOrientation(orientation?: number): number;
  21487. private _onBeforeRenderObservable;
  21488. private _onBeforeBindObservable;
  21489. private _onAfterRenderObservable;
  21490. private _onBeforeDrawObservable;
  21491. /**
  21492. * An event triggered before rendering the mesh
  21493. */
  21494. readonly onBeforeRenderObservable: Observable<Mesh>;
  21495. /**
  21496. * An event triggered before binding the mesh
  21497. */
  21498. readonly onBeforeBindObservable: Observable<Mesh>;
  21499. /**
  21500. * An event triggered after rendering the mesh
  21501. */
  21502. readonly onAfterRenderObservable: Observable<Mesh>;
  21503. /**
  21504. * An event triggered before drawing the mesh
  21505. */
  21506. readonly onBeforeDrawObservable: Observable<Mesh>;
  21507. private _onBeforeDrawObserver;
  21508. /**
  21509. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21510. */
  21511. onBeforeDraw: () => void;
  21512. /**
  21513. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21514. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21515. */
  21516. delayLoadState: number;
  21517. /**
  21518. * Gets the list of instances created from this mesh
  21519. * it is not supposed to be modified manually.
  21520. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21521. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21522. */
  21523. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21524. /**
  21525. * Gets the file containing delay loading data for this mesh
  21526. */
  21527. delayLoadingFile: string;
  21528. /** @hidden */
  21529. _binaryInfo: any;
  21530. private _LODLevels;
  21531. /**
  21532. * User defined function used to change how LOD level selection is done
  21533. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21534. */
  21535. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21536. private _morphTargetManager;
  21537. /**
  21538. * Gets or sets the morph target manager
  21539. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21540. */
  21541. morphTargetManager: Nullable<MorphTargetManager>;
  21542. /** @hidden */
  21543. _creationDataStorage: Nullable<_CreationDataStorage>;
  21544. /** @hidden */
  21545. _geometry: Nullable<Geometry>;
  21546. /** @hidden */
  21547. _delayInfo: Array<string>;
  21548. /** @hidden */
  21549. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21550. /** @hidden */
  21551. _instanceDataStorage: _InstanceDataStorage;
  21552. private _effectiveMaterial;
  21553. /** @hidden */
  21554. _shouldGenerateFlatShading: boolean;
  21555. private _preActivateId;
  21556. /** @hidden */
  21557. _originalBuilderSideOrientation: number;
  21558. /**
  21559. * Use this property to change the original side orientation defined at construction time
  21560. */
  21561. overrideMaterialSideOrientation: Nullable<number>;
  21562. private _areNormalsFrozen;
  21563. private _sourcePositions;
  21564. private _sourceNormals;
  21565. private _source;
  21566. private meshMap;
  21567. /**
  21568. * Gets the source mesh (the one used to clone this one from)
  21569. */
  21570. readonly source: Nullable<Mesh>;
  21571. /**
  21572. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21573. */
  21574. isUnIndexed: boolean;
  21575. /**
  21576. * @constructor
  21577. * @param name The value used by scene.getMeshByName() to do a lookup.
  21578. * @param scene The scene to add this mesh to.
  21579. * @param parent The parent of this mesh, if it has one
  21580. * @param source An optional Mesh from which geometry is shared, cloned.
  21581. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21582. * When false, achieved by calling a clone(), also passing False.
  21583. * This will make creation of children, recursive.
  21584. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21585. */
  21586. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21587. /**
  21588. * Gets the class name
  21589. * @returns the string "Mesh".
  21590. */
  21591. getClassName(): string;
  21592. /** @hidden */
  21593. readonly _isMesh: boolean;
  21594. /**
  21595. * Returns a description of this mesh
  21596. * @param fullDetails define if full details about this mesh must be used
  21597. * @returns a descriptive string representing this mesh
  21598. */
  21599. toString(fullDetails?: boolean): string;
  21600. /** @hidden */
  21601. _unBindEffect(): void;
  21602. /**
  21603. * Gets a boolean indicating if this mesh has LOD
  21604. */
  21605. readonly hasLODLevels: boolean;
  21606. /**
  21607. * Gets the list of MeshLODLevel associated with the current mesh
  21608. * @returns an array of MeshLODLevel
  21609. */
  21610. getLODLevels(): MeshLODLevel[];
  21611. private _sortLODLevels;
  21612. /**
  21613. * Add a mesh as LOD level triggered at the given distance.
  21614. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21615. * @param distance The distance from the center of the object to show this level
  21616. * @param mesh The mesh to be added as LOD level (can be null)
  21617. * @return This mesh (for chaining)
  21618. */
  21619. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21620. /**
  21621. * Returns the LOD level mesh at the passed distance or null if not found.
  21622. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21623. * @param distance The distance from the center of the object to show this level
  21624. * @returns a Mesh or `null`
  21625. */
  21626. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21627. /**
  21628. * Remove a mesh from the LOD array
  21629. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21630. * @param mesh defines the mesh to be removed
  21631. * @return This mesh (for chaining)
  21632. */
  21633. removeLODLevel(mesh: Mesh): Mesh;
  21634. /**
  21635. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21636. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21637. * @param camera defines the camera to use to compute distance
  21638. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21639. * @return This mesh (for chaining)
  21640. */
  21641. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21642. /**
  21643. * Gets the mesh internal Geometry object
  21644. */
  21645. readonly geometry: Nullable<Geometry>;
  21646. /**
  21647. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21648. * @returns the total number of vertices
  21649. */
  21650. getTotalVertices(): number;
  21651. /**
  21652. * Returns the content of an associated vertex buffer
  21653. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21654. * - VertexBuffer.PositionKind
  21655. * - VertexBuffer.UVKind
  21656. * - VertexBuffer.UV2Kind
  21657. * - VertexBuffer.UV3Kind
  21658. * - VertexBuffer.UV4Kind
  21659. * - VertexBuffer.UV5Kind
  21660. * - VertexBuffer.UV6Kind
  21661. * - VertexBuffer.ColorKind
  21662. * - VertexBuffer.MatricesIndicesKind
  21663. * - VertexBuffer.MatricesIndicesExtraKind
  21664. * - VertexBuffer.MatricesWeightsKind
  21665. * - VertexBuffer.MatricesWeightsExtraKind
  21666. * @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
  21667. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21668. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21669. */
  21670. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21671. /**
  21672. * Returns the mesh VertexBuffer object from the requested `kind`
  21673. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21674. * - VertexBuffer.PositionKind
  21675. * - VertexBuffer.UVKind
  21676. * - VertexBuffer.UV2Kind
  21677. * - VertexBuffer.UV3Kind
  21678. * - VertexBuffer.UV4Kind
  21679. * - VertexBuffer.UV5Kind
  21680. * - VertexBuffer.UV6Kind
  21681. * - VertexBuffer.ColorKind
  21682. * - VertexBuffer.MatricesIndicesKind
  21683. * - VertexBuffer.MatricesIndicesExtraKind
  21684. * - VertexBuffer.MatricesWeightsKind
  21685. * - VertexBuffer.MatricesWeightsExtraKind
  21686. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21687. */
  21688. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21689. /**
  21690. * Tests if a specific vertex buffer is associated with this mesh
  21691. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21692. * - VertexBuffer.PositionKind
  21693. * - VertexBuffer.UVKind
  21694. * - VertexBuffer.UV2Kind
  21695. * - VertexBuffer.UV3Kind
  21696. * - VertexBuffer.UV4Kind
  21697. * - VertexBuffer.UV5Kind
  21698. * - VertexBuffer.UV6Kind
  21699. * - VertexBuffer.ColorKind
  21700. * - VertexBuffer.MatricesIndicesKind
  21701. * - VertexBuffer.MatricesIndicesExtraKind
  21702. * - VertexBuffer.MatricesWeightsKind
  21703. * - VertexBuffer.MatricesWeightsExtraKind
  21704. * @returns a boolean
  21705. */
  21706. isVerticesDataPresent(kind: string): boolean;
  21707. /**
  21708. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21709. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21710. * - VertexBuffer.PositionKind
  21711. * - VertexBuffer.UVKind
  21712. * - VertexBuffer.UV2Kind
  21713. * - VertexBuffer.UV3Kind
  21714. * - VertexBuffer.UV4Kind
  21715. * - VertexBuffer.UV5Kind
  21716. * - VertexBuffer.UV6Kind
  21717. * - VertexBuffer.ColorKind
  21718. * - VertexBuffer.MatricesIndicesKind
  21719. * - VertexBuffer.MatricesIndicesExtraKind
  21720. * - VertexBuffer.MatricesWeightsKind
  21721. * - VertexBuffer.MatricesWeightsExtraKind
  21722. * @returns a boolean
  21723. */
  21724. isVertexBufferUpdatable(kind: string): boolean;
  21725. /**
  21726. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21727. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21728. * - VertexBuffer.PositionKind
  21729. * - VertexBuffer.UVKind
  21730. * - VertexBuffer.UV2Kind
  21731. * - VertexBuffer.UV3Kind
  21732. * - VertexBuffer.UV4Kind
  21733. * - VertexBuffer.UV5Kind
  21734. * - VertexBuffer.UV6Kind
  21735. * - VertexBuffer.ColorKind
  21736. * - VertexBuffer.MatricesIndicesKind
  21737. * - VertexBuffer.MatricesIndicesExtraKind
  21738. * - VertexBuffer.MatricesWeightsKind
  21739. * - VertexBuffer.MatricesWeightsExtraKind
  21740. * @returns an array of strings
  21741. */
  21742. getVerticesDataKinds(): string[];
  21743. /**
  21744. * Returns a positive integer : the total number of indices in this mesh geometry.
  21745. * @returns the numner of indices or zero if the mesh has no geometry.
  21746. */
  21747. getTotalIndices(): number;
  21748. /**
  21749. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21750. * @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.
  21751. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21752. * @returns the indices array or an empty array if the mesh has no geometry
  21753. */
  21754. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21755. readonly isBlocked: boolean;
  21756. /**
  21757. * Determine if the current mesh is ready to be rendered
  21758. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21759. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21760. * @returns true if all associated assets are ready (material, textures, shaders)
  21761. */
  21762. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21763. /**
  21764. * 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.
  21765. */
  21766. readonly areNormalsFrozen: boolean;
  21767. /**
  21768. * 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.
  21769. * @returns the current mesh
  21770. */
  21771. freezeNormals(): Mesh;
  21772. /**
  21773. * 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
  21774. * @returns the current mesh
  21775. */
  21776. unfreezeNormals(): Mesh;
  21777. /**
  21778. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21779. */
  21780. overridenInstanceCount: number;
  21781. /** @hidden */
  21782. _preActivate(): Mesh;
  21783. /** @hidden */
  21784. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21785. /** @hidden */
  21786. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21787. /**
  21788. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21789. * This means the mesh underlying bounding box and sphere are recomputed.
  21790. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21791. * @returns the current mesh
  21792. */
  21793. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21794. /** @hidden */
  21795. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21796. /**
  21797. * This function will subdivide the mesh into multiple submeshes
  21798. * @param count defines the expected number of submeshes
  21799. */
  21800. subdivide(count: number): void;
  21801. /**
  21802. * Copy a FloatArray into a specific associated vertex buffer
  21803. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21804. * - VertexBuffer.PositionKind
  21805. * - VertexBuffer.UVKind
  21806. * - VertexBuffer.UV2Kind
  21807. * - VertexBuffer.UV3Kind
  21808. * - VertexBuffer.UV4Kind
  21809. * - VertexBuffer.UV5Kind
  21810. * - VertexBuffer.UV6Kind
  21811. * - VertexBuffer.ColorKind
  21812. * - VertexBuffer.MatricesIndicesKind
  21813. * - VertexBuffer.MatricesIndicesExtraKind
  21814. * - VertexBuffer.MatricesWeightsKind
  21815. * - VertexBuffer.MatricesWeightsExtraKind
  21816. * @param data defines the data source
  21817. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21818. * @param stride defines the data stride size (can be null)
  21819. * @returns the current mesh
  21820. */
  21821. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21822. /**
  21823. * Flags an associated vertex buffer as updatable
  21824. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21825. * - VertexBuffer.PositionKind
  21826. * - VertexBuffer.UVKind
  21827. * - VertexBuffer.UV2Kind
  21828. * - VertexBuffer.UV3Kind
  21829. * - VertexBuffer.UV4Kind
  21830. * - VertexBuffer.UV5Kind
  21831. * - VertexBuffer.UV6Kind
  21832. * - VertexBuffer.ColorKind
  21833. * - VertexBuffer.MatricesIndicesKind
  21834. * - VertexBuffer.MatricesIndicesExtraKind
  21835. * - VertexBuffer.MatricesWeightsKind
  21836. * - VertexBuffer.MatricesWeightsExtraKind
  21837. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21838. */
  21839. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21840. /**
  21841. * Sets the mesh global Vertex Buffer
  21842. * @param buffer defines the buffer to use
  21843. * @returns the current mesh
  21844. */
  21845. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21846. /**
  21847. * Update a specific associated vertex buffer
  21848. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21849. * - VertexBuffer.PositionKind
  21850. * - VertexBuffer.UVKind
  21851. * - VertexBuffer.UV2Kind
  21852. * - VertexBuffer.UV3Kind
  21853. * - VertexBuffer.UV4Kind
  21854. * - VertexBuffer.UV5Kind
  21855. * - VertexBuffer.UV6Kind
  21856. * - VertexBuffer.ColorKind
  21857. * - VertexBuffer.MatricesIndicesKind
  21858. * - VertexBuffer.MatricesIndicesExtraKind
  21859. * - VertexBuffer.MatricesWeightsKind
  21860. * - VertexBuffer.MatricesWeightsExtraKind
  21861. * @param data defines the data source
  21862. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21863. * @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)
  21864. * @returns the current mesh
  21865. */
  21866. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21867. /**
  21868. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21869. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21870. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21871. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21872. * @returns the current mesh
  21873. */
  21874. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21875. /**
  21876. * Creates a un-shared specific occurence of the geometry for the mesh.
  21877. * @returns the current mesh
  21878. */
  21879. makeGeometryUnique(): Mesh;
  21880. /**
  21881. * Set the index buffer of this mesh
  21882. * @param indices defines the source data
  21883. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21884. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21885. * @returns the current mesh
  21886. */
  21887. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21888. /**
  21889. * Update the current index buffer
  21890. * @param indices defines the source data
  21891. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21892. * @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)
  21893. * @returns the current mesh
  21894. */
  21895. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21896. /**
  21897. * Invert the geometry to move from a right handed system to a left handed one.
  21898. * @returns the current mesh
  21899. */
  21900. toLeftHanded(): Mesh;
  21901. /** @hidden */
  21902. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21903. /** @hidden */
  21904. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21905. /**
  21906. * Registers for this mesh a javascript function called just before the rendering process
  21907. * @param func defines the function to call before rendering this mesh
  21908. * @returns the current mesh
  21909. */
  21910. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21911. /**
  21912. * Disposes a previously registered javascript function called before the rendering
  21913. * @param func defines the function to remove
  21914. * @returns the current mesh
  21915. */
  21916. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21917. /**
  21918. * Registers for this mesh a javascript function called just after the rendering is complete
  21919. * @param func defines the function to call after rendering this mesh
  21920. * @returns the current mesh
  21921. */
  21922. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21923. /**
  21924. * Disposes a previously registered javascript function called after the rendering.
  21925. * @param func defines the function to remove
  21926. * @returns the current mesh
  21927. */
  21928. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21929. /** @hidden */
  21930. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21931. /** @hidden */
  21932. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21933. /** @hidden */
  21934. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21935. /** @hidden */
  21936. _freeze(): void;
  21937. /** @hidden */
  21938. _unFreeze(): void;
  21939. /**
  21940. * 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
  21941. * @param subMesh defines the subMesh to render
  21942. * @param enableAlphaMode defines if alpha mode can be changed
  21943. * @returns the current mesh
  21944. */
  21945. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21946. private _onBeforeDraw;
  21947. /**
  21948. * Renormalize the mesh and patch it up if there are no weights
  21949. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21950. * However in the case of zero weights then we set just a single influence to 1.
  21951. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21952. */
  21953. cleanMatrixWeights(): void;
  21954. private normalizeSkinFourWeights;
  21955. private normalizeSkinWeightsAndExtra;
  21956. /**
  21957. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21958. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21959. * the user know there was an issue with importing the mesh
  21960. * @returns a validation object with skinned, valid and report string
  21961. */
  21962. validateSkinning(): {
  21963. skinned: boolean;
  21964. valid: boolean;
  21965. report: string;
  21966. };
  21967. /** @hidden */
  21968. _checkDelayState(): Mesh;
  21969. private _queueLoad;
  21970. /**
  21971. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21972. * A mesh is in the frustum if its bounding box intersects the frustum
  21973. * @param frustumPlanes defines the frustum to test
  21974. * @returns true if the mesh is in the frustum planes
  21975. */
  21976. isInFrustum(frustumPlanes: Plane[]): boolean;
  21977. /**
  21978. * Sets the mesh material by the material or multiMaterial `id` property
  21979. * @param id is a string identifying the material or the multiMaterial
  21980. * @returns the current mesh
  21981. */
  21982. setMaterialByID(id: string): Mesh;
  21983. /**
  21984. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21985. * @returns an array of IAnimatable
  21986. */
  21987. getAnimatables(): IAnimatable[];
  21988. /**
  21989. * Modifies the mesh geometry according to the passed transformation matrix.
  21990. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21991. * The mesh normals are modified using the same transformation.
  21992. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21993. * @param transform defines the transform matrix to use
  21994. * @see http://doc.babylonjs.com/resources/baking_transformations
  21995. * @returns the current mesh
  21996. */
  21997. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21998. /**
  21999. * Modifies the mesh geometry according to its own current World Matrix.
  22000. * The mesh World Matrix is then reset.
  22001. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  22002. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22003. * @see http://doc.babylonjs.com/resources/baking_transformations
  22004. * @returns the current mesh
  22005. */
  22006. bakeCurrentTransformIntoVertices(): Mesh;
  22007. /** @hidden */
  22008. readonly _positions: Nullable<Vector3[]>;
  22009. /** @hidden */
  22010. _resetPointsArrayCache(): Mesh;
  22011. /** @hidden */
  22012. _generatePointsArray(): boolean;
  22013. /**
  22014. * Returns a new Mesh object generated from the current mesh properties.
  22015. * This method must not get confused with createInstance()
  22016. * @param name is a string, the name given to the new mesh
  22017. * @param newParent can be any Node object (default `null`)
  22018. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22019. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22020. * @returns a new mesh
  22021. */
  22022. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22023. /**
  22024. * Releases resources associated with this mesh.
  22025. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22026. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22027. */
  22028. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22029. /**
  22030. * Modifies the mesh geometry according to a displacement map.
  22031. * 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.
  22032. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22033. * @param url is a string, the URL from the image file is to be downloaded.
  22034. * @param minHeight is the lower limit of the displacement.
  22035. * @param maxHeight is the upper limit of the displacement.
  22036. * @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.
  22037. * @param uvOffset is an optional vector2 used to offset UV.
  22038. * @param uvScale is an optional vector2 used to scale UV.
  22039. * @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.
  22040. * @returns the Mesh.
  22041. */
  22042. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22043. /**
  22044. * Modifies the mesh geometry according to a displacementMap buffer.
  22045. * 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.
  22046. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22047. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22048. * @param heightMapWidth is the width of the buffer image.
  22049. * @param heightMapHeight is the height of the buffer image.
  22050. * @param minHeight is the lower limit of the displacement.
  22051. * @param maxHeight is the upper limit of the displacement.
  22052. * @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.
  22053. * @param uvOffset is an optional vector2 used to offset UV.
  22054. * @param uvScale is an optional vector2 used to scale UV.
  22055. * @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.
  22056. * @returns the Mesh.
  22057. */
  22058. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22059. /**
  22060. * Modify the mesh to get a flat shading rendering.
  22061. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22062. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22063. * @returns current mesh
  22064. */
  22065. convertToFlatShadedMesh(): Mesh;
  22066. /**
  22067. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22068. * In other words, more vertices, no more indices and a single bigger VBO.
  22069. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22070. * @returns current mesh
  22071. */
  22072. convertToUnIndexedMesh(): Mesh;
  22073. /**
  22074. * Inverses facet orientations.
  22075. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22076. * @param flipNormals will also inverts the normals
  22077. * @returns current mesh
  22078. */
  22079. flipFaces(flipNormals?: boolean): Mesh;
  22080. /**
  22081. * Increase the number of facets and hence vertices in a mesh
  22082. * Vertex normals are interpolated from existing vertex normals
  22083. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22084. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22085. */
  22086. increaseVertices(numberPerEdge: number): void;
  22087. /**
  22088. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22089. * This will undo any application of covertToFlatShadedMesh
  22090. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22091. */
  22092. forceSharedVertices(): void;
  22093. /** @hidden */
  22094. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22095. /** @hidden */
  22096. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22097. /**
  22098. * Creates a new InstancedMesh object from the mesh model.
  22099. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22100. * @param name defines the name of the new instance
  22101. * @returns a new InstancedMesh
  22102. */
  22103. createInstance(name: string): InstancedMesh;
  22104. /**
  22105. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22106. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22107. * @returns the current mesh
  22108. */
  22109. synchronizeInstances(): Mesh;
  22110. /**
  22111. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22112. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22113. * This should be used together with the simplification to avoid disappearing triangles.
  22114. * @param successCallback an optional success callback to be called after the optimization finished.
  22115. * @returns the current mesh
  22116. */
  22117. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22118. /**
  22119. * Serialize current mesh
  22120. * @param serializationObject defines the object which will receive the serialization data
  22121. */
  22122. serialize(serializationObject: any): void;
  22123. /** @hidden */
  22124. _syncGeometryWithMorphTargetManager(): void;
  22125. /** @hidden */
  22126. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22127. /**
  22128. * Returns a new Mesh object parsed from the source provided.
  22129. * @param parsedMesh is the source
  22130. * @param scene defines the hosting scene
  22131. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22132. * @returns a new Mesh
  22133. */
  22134. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22135. /**
  22136. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22137. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22138. * @param name defines the name of the mesh to create
  22139. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22140. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22141. * @param closePath creates a seam between the first and the last points of each path of the path array
  22142. * @param offset is taken in account only if the `pathArray` is containing a single path
  22143. * @param scene defines the hosting scene
  22144. * @param updatable defines if the mesh must be flagged as updatable
  22145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22146. * @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)
  22147. * @returns a new Mesh
  22148. */
  22149. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22150. /**
  22151. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22152. * @param name defines the name of the mesh to create
  22153. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22154. * @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
  22155. * @param scene defines the hosting scene
  22156. * @param updatable defines if the mesh must be flagged as updatable
  22157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22158. * @returns a new Mesh
  22159. */
  22160. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22161. /**
  22162. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22163. * @param name defines the name of the mesh to create
  22164. * @param size sets the size (float) of each box side (default 1)
  22165. * @param scene defines the hosting scene
  22166. * @param updatable defines if the mesh must be flagged as updatable
  22167. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22168. * @returns a new Mesh
  22169. */
  22170. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22171. /**
  22172. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22173. * @param name defines the name of the mesh to create
  22174. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22175. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22176. * @param scene defines the hosting scene
  22177. * @param updatable defines if the mesh must be flagged as updatable
  22178. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22179. * @returns a new Mesh
  22180. */
  22181. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22182. /**
  22183. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22184. * @param name defines the name of the mesh to create
  22185. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22186. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22187. * @param scene defines the hosting scene
  22188. * @returns a new Mesh
  22189. */
  22190. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22191. /**
  22192. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22193. * @param name defines the name of the mesh to create
  22194. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22195. * @param diameterTop set the top cap diameter (floats, default 1)
  22196. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22197. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22198. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22199. * @param scene defines the hosting scene
  22200. * @param updatable defines if the mesh must be flagged as updatable
  22201. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22202. * @returns a new Mesh
  22203. */
  22204. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22205. /**
  22206. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22207. * @param name defines the name of the mesh to create
  22208. * @param diameter sets the diameter size (float) of the torus (default 1)
  22209. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22210. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22211. * @param scene defines the hosting scene
  22212. * @param updatable defines if the mesh must be flagged as updatable
  22213. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22214. * @returns a new Mesh
  22215. */
  22216. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22217. /**
  22218. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22219. * @param name defines the name of the mesh to create
  22220. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22221. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22222. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22223. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22224. * @param p the number of windings on X axis (positive integers, default 2)
  22225. * @param q the number of windings on Y axis (positive integers, default 3)
  22226. * @param scene defines the hosting scene
  22227. * @param updatable defines if the mesh must be flagged as updatable
  22228. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22229. * @returns a new Mesh
  22230. */
  22231. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22232. /**
  22233. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22234. * @param name defines the name of the mesh to create
  22235. * @param points is an array successive Vector3
  22236. * @param scene defines the hosting scene
  22237. * @param updatable defines if the mesh must be flagged as updatable
  22238. * @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).
  22239. * @returns a new Mesh
  22240. */
  22241. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22242. /**
  22243. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22244. * @param name defines the name of the mesh to create
  22245. * @param points is an array successive Vector3
  22246. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22247. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22248. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22249. * @param scene defines the hosting scene
  22250. * @param updatable defines if the mesh must be flagged as updatable
  22251. * @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)
  22252. * @returns a new Mesh
  22253. */
  22254. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22255. /**
  22256. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22257. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22258. * 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.
  22259. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22260. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22261. * Remember you can only change the shape positions, not their number when updating a polygon.
  22262. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22263. * @param name defines the name of the mesh to create
  22264. * @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
  22265. * @param scene defines the hosting scene
  22266. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22267. * @param updatable defines if the mesh must be flagged as updatable
  22268. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22269. * @param earcutInjection can be used to inject your own earcut reference
  22270. * @returns a new Mesh
  22271. */
  22272. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22273. /**
  22274. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22275. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22276. * @param name defines the name of the mesh to create
  22277. * @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
  22278. * @param depth defines the height of extrusion
  22279. * @param scene defines the hosting scene
  22280. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22281. * @param updatable defines if the mesh must be flagged as updatable
  22282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22283. * @param earcutInjection can be used to inject your own earcut reference
  22284. * @returns a new Mesh
  22285. */
  22286. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22287. /**
  22288. * Creates an extruded shape mesh.
  22289. * 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
  22290. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22291. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22292. * @param name defines the name of the mesh to create
  22293. * @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
  22294. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22295. * @param scale is the value to scale the shape
  22296. * @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
  22297. * @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
  22298. * @param scene defines the hosting scene
  22299. * @param updatable defines if the mesh must be flagged as updatable
  22300. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22301. * @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)
  22302. * @returns a new Mesh
  22303. */
  22304. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22305. /**
  22306. * Creates an custom extruded shape mesh.
  22307. * The custom extrusion is a parametric shape.
  22308. * It has no predefined shape. Its final shape will depend on the input parameters.
  22309. * Please consider using the same method from the MeshBuilder class instead
  22310. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22311. * @param name defines the name of the mesh to create
  22312. * @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
  22313. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22314. * @param scaleFunction is a custom Javascript function called on each path point
  22315. * @param rotationFunction is a custom Javascript function called on each path point
  22316. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22317. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22318. * @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
  22319. * @param scene defines the hosting scene
  22320. * @param updatable defines if the mesh must be flagged as updatable
  22321. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22322. * @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)
  22323. * @returns a new Mesh
  22324. */
  22325. 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;
  22326. /**
  22327. * Creates lathe mesh.
  22328. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22329. * Please consider using the same method from the MeshBuilder class instead
  22330. * @param name defines the name of the mesh to create
  22331. * @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
  22332. * @param radius is the radius value of the lathe
  22333. * @param tessellation is the side number of the lathe.
  22334. * @param scene defines the hosting scene
  22335. * @param updatable defines if the mesh must be flagged as updatable
  22336. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22337. * @returns a new Mesh
  22338. */
  22339. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22340. /**
  22341. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22342. * @param name defines the name of the mesh to create
  22343. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22344. * @param scene defines the hosting scene
  22345. * @param updatable defines if the mesh must be flagged as updatable
  22346. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22347. * @returns a new Mesh
  22348. */
  22349. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22350. /**
  22351. * Creates a ground mesh.
  22352. * Please consider using the same method from the MeshBuilder class instead
  22353. * @param name defines the name of the mesh to create
  22354. * @param width set the width of the ground
  22355. * @param height set the height of the ground
  22356. * @param subdivisions sets the number of subdivisions per side
  22357. * @param scene defines the hosting scene
  22358. * @param updatable defines if the mesh must be flagged as updatable
  22359. * @returns a new Mesh
  22360. */
  22361. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22362. /**
  22363. * Creates a tiled ground mesh.
  22364. * Please consider using the same method from the MeshBuilder class instead
  22365. * @param name defines the name of the mesh to create
  22366. * @param xmin set the ground minimum X coordinate
  22367. * @param zmin set the ground minimum Y coordinate
  22368. * @param xmax set the ground maximum X coordinate
  22369. * @param zmax set the ground maximum Z coordinate
  22370. * @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
  22371. * @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
  22372. * @param scene defines the hosting scene
  22373. * @param updatable defines if the mesh must be flagged as updatable
  22374. * @returns a new Mesh
  22375. */
  22376. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22377. w: number;
  22378. h: number;
  22379. }, precision: {
  22380. w: number;
  22381. h: number;
  22382. }, scene: Scene, updatable?: boolean): Mesh;
  22383. /**
  22384. * Creates a ground mesh from a height map.
  22385. * Please consider using the same method from the MeshBuilder class instead
  22386. * @see http://doc.babylonjs.com/babylon101/height_map
  22387. * @param name defines the name of the mesh to create
  22388. * @param url sets the URL of the height map image resource
  22389. * @param width set the ground width size
  22390. * @param height set the ground height size
  22391. * @param subdivisions sets the number of subdivision per side
  22392. * @param minHeight is the minimum altitude on the ground
  22393. * @param maxHeight is the maximum altitude on the ground
  22394. * @param scene defines the hosting scene
  22395. * @param updatable defines if the mesh must be flagged as updatable
  22396. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22397. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22398. * @returns a new Mesh
  22399. */
  22400. 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;
  22401. /**
  22402. * Creates a tube mesh.
  22403. * The tube is a parametric shape.
  22404. * It has no predefined shape. Its final shape will depend on the input parameters.
  22405. * Please consider using the same method from the MeshBuilder class instead
  22406. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22407. * @param name defines the name of the mesh to create
  22408. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22409. * @param radius sets the tube radius size
  22410. * @param tessellation is the number of sides on the tubular surface
  22411. * @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
  22412. * @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
  22413. * @param scene defines the hosting scene
  22414. * @param updatable defines if the mesh must be flagged as updatable
  22415. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22416. * @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)
  22417. * @returns a new Mesh
  22418. */
  22419. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22420. (i: number, distance: number): number;
  22421. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22422. /**
  22423. * Creates a polyhedron mesh.
  22424. * Please consider using the same method from the MeshBuilder class instead.
  22425. * * 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
  22426. * * The parameter `size` (positive float, default 1) sets the polygon size
  22427. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22428. * * 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`
  22429. * * 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
  22430. * * 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)`)
  22431. * * 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
  22432. * * 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
  22433. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22434. * * If you create a double-sided mesh, you can choose what parts of 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
  22435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22436. * @param name defines the name of the mesh to create
  22437. * @param options defines the options used to create the mesh
  22438. * @param scene defines the hosting scene
  22439. * @returns a new Mesh
  22440. */
  22441. static CreatePolyhedron(name: string, options: {
  22442. type?: number;
  22443. size?: number;
  22444. sizeX?: number;
  22445. sizeY?: number;
  22446. sizeZ?: number;
  22447. custom?: any;
  22448. faceUV?: Vector4[];
  22449. faceColors?: Color4[];
  22450. updatable?: boolean;
  22451. sideOrientation?: number;
  22452. }, scene: Scene): Mesh;
  22453. /**
  22454. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22455. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22456. * * 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`)
  22457. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22458. * * 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
  22459. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22460. * * If you create a double-sided mesh, you can choose what parts of 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
  22461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22462. * @param name defines the name of the mesh
  22463. * @param options defines the options used to create the mesh
  22464. * @param scene defines the hosting scene
  22465. * @returns a new Mesh
  22466. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22467. */
  22468. static CreateIcoSphere(name: string, options: {
  22469. radius?: number;
  22470. flat?: boolean;
  22471. subdivisions?: number;
  22472. sideOrientation?: number;
  22473. updatable?: boolean;
  22474. }, scene: Scene): Mesh;
  22475. /**
  22476. * Creates a decal mesh.
  22477. * Please consider using the same method from the MeshBuilder class instead.
  22478. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22479. * @param name defines the name of the mesh
  22480. * @param sourceMesh defines the mesh receiving the decal
  22481. * @param position sets the position of the decal in world coordinates
  22482. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22483. * @param size sets the decal scaling
  22484. * @param angle sets the angle to rotate the decal
  22485. * @returns a new Mesh
  22486. */
  22487. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22488. /**
  22489. * Prepare internal position array for software CPU skinning
  22490. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22491. */
  22492. setPositionsForCPUSkinning(): Float32Array;
  22493. /**
  22494. * Prepare internal normal array for software CPU skinning
  22495. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22496. */
  22497. setNormalsForCPUSkinning(): Float32Array;
  22498. /**
  22499. * Updates the vertex buffer by applying transformation from the bones
  22500. * @param skeleton defines the skeleton to apply to current mesh
  22501. * @returns the current mesh
  22502. */
  22503. applySkeleton(skeleton: Skeleton): Mesh;
  22504. /**
  22505. * 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
  22506. * @param meshes defines the list of meshes to scan
  22507. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22508. */
  22509. static MinMax(meshes: AbstractMesh[]): {
  22510. min: Vector3;
  22511. max: Vector3;
  22512. };
  22513. /**
  22514. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22515. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22516. * @returns a vector3
  22517. */
  22518. static Center(meshesOrMinMaxVector: {
  22519. min: Vector3;
  22520. max: Vector3;
  22521. } | AbstractMesh[]): Vector3;
  22522. /**
  22523. * Merge the array of meshes into a single mesh for performance reasons.
  22524. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22525. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22526. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22527. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22528. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22529. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22530. * @returns a new mesh
  22531. */
  22532. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22533. /** @hidden */
  22534. addInstance(instance: InstancedMesh): void;
  22535. /** @hidden */
  22536. removeInstance(instance: InstancedMesh): void;
  22537. }
  22538. }
  22539. declare module "babylonjs/Materials/material" {
  22540. import { IAnimatable } from "babylonjs/Misc/tools";
  22541. import { SmartArray } from "babylonjs/Misc/smartArray";
  22542. import { Observable } from "babylonjs/Misc/observable";
  22543. import { Nullable } from "babylonjs/types";
  22544. import { Scene } from "babylonjs/scene";
  22545. import { Matrix } from "babylonjs/Maths/math";
  22546. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22548. import { Mesh } from "babylonjs/Meshes/mesh";
  22549. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22550. import { Effect } from "babylonjs/Materials/effect";
  22551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22552. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22553. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22554. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22555. import { Animation } from "babylonjs/Animations/animation";
  22556. /**
  22557. * Base class for the main features of a material in Babylon.js
  22558. */
  22559. export class Material implements IAnimatable {
  22560. /**
  22561. * Returns the triangle fill mode
  22562. */
  22563. static readonly TriangleFillMode: number;
  22564. /**
  22565. * Returns the wireframe mode
  22566. */
  22567. static readonly WireFrameFillMode: number;
  22568. /**
  22569. * Returns the point fill mode
  22570. */
  22571. static readonly PointFillMode: number;
  22572. /**
  22573. * Returns the point list draw mode
  22574. */
  22575. static readonly PointListDrawMode: number;
  22576. /**
  22577. * Returns the line list draw mode
  22578. */
  22579. static readonly LineListDrawMode: number;
  22580. /**
  22581. * Returns the line loop draw mode
  22582. */
  22583. static readonly LineLoopDrawMode: number;
  22584. /**
  22585. * Returns the line strip draw mode
  22586. */
  22587. static readonly LineStripDrawMode: number;
  22588. /**
  22589. * Returns the triangle strip draw mode
  22590. */
  22591. static readonly TriangleStripDrawMode: number;
  22592. /**
  22593. * Returns the triangle fan draw mode
  22594. */
  22595. static readonly TriangleFanDrawMode: number;
  22596. /**
  22597. * Stores the clock-wise side orientation
  22598. */
  22599. static readonly ClockWiseSideOrientation: number;
  22600. /**
  22601. * Stores the counter clock-wise side orientation
  22602. */
  22603. static readonly CounterClockWiseSideOrientation: number;
  22604. /**
  22605. * The dirty texture flag value
  22606. */
  22607. static readonly TextureDirtyFlag: number;
  22608. /**
  22609. * The dirty light flag value
  22610. */
  22611. static readonly LightDirtyFlag: number;
  22612. /**
  22613. * The dirty fresnel flag value
  22614. */
  22615. static readonly FresnelDirtyFlag: number;
  22616. /**
  22617. * The dirty attribute flag value
  22618. */
  22619. static readonly AttributesDirtyFlag: number;
  22620. /**
  22621. * The dirty misc flag value
  22622. */
  22623. static readonly MiscDirtyFlag: number;
  22624. /**
  22625. * The all dirty flag value
  22626. */
  22627. static readonly AllDirtyFlag: number;
  22628. /**
  22629. * The ID of the material
  22630. */
  22631. id: string;
  22632. /**
  22633. * Gets or sets the unique id of the material
  22634. */
  22635. uniqueId: number;
  22636. /**
  22637. * The name of the material
  22638. */
  22639. name: string;
  22640. /**
  22641. * Gets or sets user defined metadata
  22642. */
  22643. metadata: any;
  22644. /**
  22645. * For internal use only. Please do not use.
  22646. */
  22647. reservedDataStore: any;
  22648. /**
  22649. * Specifies if the ready state should be checked on each call
  22650. */
  22651. checkReadyOnEveryCall: boolean;
  22652. /**
  22653. * Specifies if the ready state should be checked once
  22654. */
  22655. checkReadyOnlyOnce: boolean;
  22656. /**
  22657. * The state of the material
  22658. */
  22659. state: string;
  22660. /**
  22661. * The alpha value of the material
  22662. */
  22663. protected _alpha: number;
  22664. /**
  22665. * List of inspectable custom properties (used by the Inspector)
  22666. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22667. */
  22668. inspectableCustomProperties: IInspectable[];
  22669. /**
  22670. * Sets the alpha value of the material
  22671. */
  22672. /**
  22673. * Gets the alpha value of the material
  22674. */
  22675. alpha: number;
  22676. /**
  22677. * Specifies if back face culling is enabled
  22678. */
  22679. protected _backFaceCulling: boolean;
  22680. /**
  22681. * Sets the back-face culling state
  22682. */
  22683. /**
  22684. * Gets the back-face culling state
  22685. */
  22686. backFaceCulling: boolean;
  22687. /**
  22688. * Stores the value for side orientation
  22689. */
  22690. sideOrientation: number;
  22691. /**
  22692. * Callback triggered when the material is compiled
  22693. */
  22694. onCompiled: Nullable<(effect: Effect) => void>;
  22695. /**
  22696. * Callback triggered when an error occurs
  22697. */
  22698. onError: Nullable<(effect: Effect, errors: string) => void>;
  22699. /**
  22700. * Callback triggered to get the render target textures
  22701. */
  22702. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22703. /**
  22704. * Gets a boolean indicating that current material needs to register RTT
  22705. */
  22706. readonly hasRenderTargetTextures: boolean;
  22707. /**
  22708. * Specifies if the material should be serialized
  22709. */
  22710. doNotSerialize: boolean;
  22711. /**
  22712. * @hidden
  22713. */
  22714. _storeEffectOnSubMeshes: boolean;
  22715. /**
  22716. * Stores the animations for the material
  22717. */
  22718. animations: Nullable<Array<Animation>>;
  22719. /**
  22720. * An event triggered when the material is disposed
  22721. */
  22722. onDisposeObservable: Observable<Material>;
  22723. /**
  22724. * An observer which watches for dispose events
  22725. */
  22726. private _onDisposeObserver;
  22727. private _onUnBindObservable;
  22728. /**
  22729. * Called during a dispose event
  22730. */
  22731. onDispose: () => void;
  22732. private _onBindObservable;
  22733. /**
  22734. * An event triggered when the material is bound
  22735. */
  22736. readonly onBindObservable: Observable<AbstractMesh>;
  22737. /**
  22738. * An observer which watches for bind events
  22739. */
  22740. private _onBindObserver;
  22741. /**
  22742. * Called during a bind event
  22743. */
  22744. onBind: (Mesh: AbstractMesh) => void;
  22745. /**
  22746. * An event triggered when the material is unbound
  22747. */
  22748. readonly onUnBindObservable: Observable<Material>;
  22749. /**
  22750. * Stores the value of the alpha mode
  22751. */
  22752. private _alphaMode;
  22753. /**
  22754. * Sets the value of the alpha mode.
  22755. *
  22756. * | Value | Type | Description |
  22757. * | --- | --- | --- |
  22758. * | 0 | ALPHA_DISABLE | |
  22759. * | 1 | ALPHA_ADD | |
  22760. * | 2 | ALPHA_COMBINE | |
  22761. * | 3 | ALPHA_SUBTRACT | |
  22762. * | 4 | ALPHA_MULTIPLY | |
  22763. * | 5 | ALPHA_MAXIMIZED | |
  22764. * | 6 | ALPHA_ONEONE | |
  22765. * | 7 | ALPHA_PREMULTIPLIED | |
  22766. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22767. * | 9 | ALPHA_INTERPOLATE | |
  22768. * | 10 | ALPHA_SCREENMODE | |
  22769. *
  22770. */
  22771. /**
  22772. * Gets the value of the alpha mode
  22773. */
  22774. alphaMode: number;
  22775. /**
  22776. * Stores the state of the need depth pre-pass value
  22777. */
  22778. private _needDepthPrePass;
  22779. /**
  22780. * Sets the need depth pre-pass value
  22781. */
  22782. /**
  22783. * Gets the depth pre-pass value
  22784. */
  22785. needDepthPrePass: boolean;
  22786. /**
  22787. * Specifies if depth writing should be disabled
  22788. */
  22789. disableDepthWrite: boolean;
  22790. /**
  22791. * Specifies if depth writing should be forced
  22792. */
  22793. forceDepthWrite: boolean;
  22794. /**
  22795. * Specifies if there should be a separate pass for culling
  22796. */
  22797. separateCullingPass: boolean;
  22798. /**
  22799. * Stores the state specifing if fog should be enabled
  22800. */
  22801. private _fogEnabled;
  22802. /**
  22803. * Sets the state for enabling fog
  22804. */
  22805. /**
  22806. * Gets the value of the fog enabled state
  22807. */
  22808. fogEnabled: boolean;
  22809. /**
  22810. * Stores the size of points
  22811. */
  22812. pointSize: number;
  22813. /**
  22814. * Stores the z offset value
  22815. */
  22816. zOffset: number;
  22817. /**
  22818. * Gets a value specifying if wireframe mode is enabled
  22819. */
  22820. /**
  22821. * Sets the state of wireframe mode
  22822. */
  22823. wireframe: boolean;
  22824. /**
  22825. * Gets the value specifying if point clouds are enabled
  22826. */
  22827. /**
  22828. * Sets the state of point cloud mode
  22829. */
  22830. pointsCloud: boolean;
  22831. /**
  22832. * Gets the material fill mode
  22833. */
  22834. /**
  22835. * Sets the material fill mode
  22836. */
  22837. fillMode: number;
  22838. /**
  22839. * @hidden
  22840. * Stores the effects for the material
  22841. */
  22842. _effect: Nullable<Effect>;
  22843. /**
  22844. * @hidden
  22845. * Specifies if the material was previously ready
  22846. */
  22847. _wasPreviouslyReady: boolean;
  22848. /**
  22849. * Specifies if uniform buffers should be used
  22850. */
  22851. private _useUBO;
  22852. /**
  22853. * Stores a reference to the scene
  22854. */
  22855. private _scene;
  22856. /**
  22857. * Stores the fill mode state
  22858. */
  22859. private _fillMode;
  22860. /**
  22861. * Specifies if the depth write state should be cached
  22862. */
  22863. private _cachedDepthWriteState;
  22864. /**
  22865. * Stores the uniform buffer
  22866. */
  22867. protected _uniformBuffer: UniformBuffer;
  22868. /** @hidden */
  22869. _indexInSceneMaterialArray: number;
  22870. /** @hidden */
  22871. meshMap: Nullable<{
  22872. [id: string]: AbstractMesh | undefined;
  22873. }>;
  22874. /**
  22875. * Creates a material instance
  22876. * @param name defines the name of the material
  22877. * @param scene defines the scene to reference
  22878. * @param doNotAdd specifies if the material should be added to the scene
  22879. */
  22880. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22881. /**
  22882. * Returns a string representation of the current material
  22883. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22884. * @returns a string with material information
  22885. */
  22886. toString(fullDetails?: boolean): string;
  22887. /**
  22888. * Gets the class name of the material
  22889. * @returns a string with the class name of the material
  22890. */
  22891. getClassName(): string;
  22892. /**
  22893. * Specifies if updates for the material been locked
  22894. */
  22895. readonly isFrozen: boolean;
  22896. /**
  22897. * Locks updates for the material
  22898. */
  22899. freeze(): void;
  22900. /**
  22901. * Unlocks updates for the material
  22902. */
  22903. unfreeze(): void;
  22904. /**
  22905. * Specifies if the material is ready to be used
  22906. * @param mesh defines the mesh to check
  22907. * @param useInstances specifies if instances should be used
  22908. * @returns a boolean indicating if the material is ready to be used
  22909. */
  22910. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22911. /**
  22912. * Specifies that the submesh is ready to be used
  22913. * @param mesh defines the mesh to check
  22914. * @param subMesh defines which submesh to check
  22915. * @param useInstances specifies that instances should be used
  22916. * @returns a boolean indicating that the submesh is ready or not
  22917. */
  22918. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22919. /**
  22920. * Returns the material effect
  22921. * @returns the effect associated with the material
  22922. */
  22923. getEffect(): Nullable<Effect>;
  22924. /**
  22925. * Returns the current scene
  22926. * @returns a Scene
  22927. */
  22928. getScene(): Scene;
  22929. /**
  22930. * Specifies if the material will require alpha blending
  22931. * @returns a boolean specifying if alpha blending is needed
  22932. */
  22933. needAlphaBlending(): boolean;
  22934. /**
  22935. * Specifies if the mesh will require alpha blending
  22936. * @param mesh defines the mesh to check
  22937. * @returns a boolean specifying if alpha blending is needed for the mesh
  22938. */
  22939. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22940. /**
  22941. * Specifies if this material should be rendered in alpha test mode
  22942. * @returns a boolean specifying if an alpha test is needed.
  22943. */
  22944. needAlphaTesting(): boolean;
  22945. /**
  22946. * Gets the texture used for the alpha test
  22947. * @returns the texture to use for alpha testing
  22948. */
  22949. getAlphaTestTexture(): Nullable<BaseTexture>;
  22950. /**
  22951. * Marks the material to indicate that it needs to be re-calculated
  22952. */
  22953. markDirty(): void;
  22954. /** @hidden */
  22955. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22956. /**
  22957. * Binds the material to the mesh
  22958. * @param world defines the world transformation matrix
  22959. * @param mesh defines the mesh to bind the material to
  22960. */
  22961. bind(world: Matrix, mesh?: Mesh): void;
  22962. /**
  22963. * Binds the submesh to the material
  22964. * @param world defines the world transformation matrix
  22965. * @param mesh defines the mesh containing the submesh
  22966. * @param subMesh defines the submesh to bind the material to
  22967. */
  22968. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22969. /**
  22970. * Binds the world matrix to the material
  22971. * @param world defines the world transformation matrix
  22972. */
  22973. bindOnlyWorldMatrix(world: Matrix): void;
  22974. /**
  22975. * Binds the scene's uniform buffer to the effect.
  22976. * @param effect defines the effect to bind to the scene uniform buffer
  22977. * @param sceneUbo defines the uniform buffer storing scene data
  22978. */
  22979. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22980. /**
  22981. * Binds the view matrix to the effect
  22982. * @param effect defines the effect to bind the view matrix to
  22983. */
  22984. bindView(effect: Effect): void;
  22985. /**
  22986. * Binds the view projection matrix to the effect
  22987. * @param effect defines the effect to bind the view projection matrix to
  22988. */
  22989. bindViewProjection(effect: Effect): void;
  22990. /**
  22991. * Specifies if material alpha testing should be turned on for the mesh
  22992. * @param mesh defines the mesh to check
  22993. */
  22994. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22995. /**
  22996. * Processes to execute after binding the material to a mesh
  22997. * @param mesh defines the rendered mesh
  22998. */
  22999. protected _afterBind(mesh?: Mesh): void;
  23000. /**
  23001. * Unbinds the material from the mesh
  23002. */
  23003. unbind(): void;
  23004. /**
  23005. * Gets the active textures from the material
  23006. * @returns an array of textures
  23007. */
  23008. getActiveTextures(): BaseTexture[];
  23009. /**
  23010. * Specifies if the material uses a texture
  23011. * @param texture defines the texture to check against the material
  23012. * @returns a boolean specifying if the material uses the texture
  23013. */
  23014. hasTexture(texture: BaseTexture): boolean;
  23015. /**
  23016. * Makes a duplicate of the material, and gives it a new name
  23017. * @param name defines the new name for the duplicated material
  23018. * @returns the cloned material
  23019. */
  23020. clone(name: string): Nullable<Material>;
  23021. /**
  23022. * Gets the meshes bound to the material
  23023. * @returns an array of meshes bound to the material
  23024. */
  23025. getBindedMeshes(): AbstractMesh[];
  23026. /**
  23027. * Force shader compilation
  23028. * @param mesh defines the mesh associated with this material
  23029. * @param onCompiled defines a function to execute once the material is compiled
  23030. * @param options defines the options to configure the compilation
  23031. */
  23032. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23033. clipPlane: boolean;
  23034. }>): void;
  23035. /**
  23036. * Force shader compilation
  23037. * @param mesh defines the mesh that will use this material
  23038. * @param options defines additional options for compiling the shaders
  23039. * @returns a promise that resolves when the compilation completes
  23040. */
  23041. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23042. clipPlane: boolean;
  23043. }>): Promise<void>;
  23044. private static readonly _ImageProcessingDirtyCallBack;
  23045. private static readonly _TextureDirtyCallBack;
  23046. private static readonly _FresnelDirtyCallBack;
  23047. private static readonly _MiscDirtyCallBack;
  23048. private static readonly _LightsDirtyCallBack;
  23049. private static readonly _AttributeDirtyCallBack;
  23050. private static _FresnelAndMiscDirtyCallBack;
  23051. private static _TextureAndMiscDirtyCallBack;
  23052. private static readonly _DirtyCallbackArray;
  23053. private static readonly _RunDirtyCallBacks;
  23054. /**
  23055. * Marks a define in the material to indicate that it needs to be re-computed
  23056. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23057. */
  23058. markAsDirty(flag: number): void;
  23059. /**
  23060. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23061. * @param func defines a function which checks material defines against the submeshes
  23062. */
  23063. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23064. /**
  23065. * Indicates that image processing needs to be re-calculated for all submeshes
  23066. */
  23067. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23068. /**
  23069. * Indicates that textures need to be re-calculated for all submeshes
  23070. */
  23071. protected _markAllSubMeshesAsTexturesDirty(): void;
  23072. /**
  23073. * Indicates that fresnel needs to be re-calculated for all submeshes
  23074. */
  23075. protected _markAllSubMeshesAsFresnelDirty(): void;
  23076. /**
  23077. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23078. */
  23079. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23080. /**
  23081. * Indicates that lights need to be re-calculated for all submeshes
  23082. */
  23083. protected _markAllSubMeshesAsLightsDirty(): void;
  23084. /**
  23085. * Indicates that attributes need to be re-calculated for all submeshes
  23086. */
  23087. protected _markAllSubMeshesAsAttributesDirty(): void;
  23088. /**
  23089. * Indicates that misc needs to be re-calculated for all submeshes
  23090. */
  23091. protected _markAllSubMeshesAsMiscDirty(): void;
  23092. /**
  23093. * Indicates that textures and misc need to be re-calculated for all submeshes
  23094. */
  23095. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23096. /**
  23097. * Disposes the material
  23098. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23099. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23100. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23101. */
  23102. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23103. /** @hidden */
  23104. private releaseVertexArrayObject;
  23105. /**
  23106. * Serializes this material
  23107. * @returns the serialized material object
  23108. */
  23109. serialize(): any;
  23110. /**
  23111. * Creates a material from parsed material data
  23112. * @param parsedMaterial defines parsed material data
  23113. * @param scene defines the hosting scene
  23114. * @param rootUrl defines the root URL to use to load textures
  23115. * @returns a new material
  23116. */
  23117. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23118. }
  23119. }
  23120. declare module "babylonjs/Meshes/subMesh" {
  23121. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23122. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23123. import { Engine } from "babylonjs/Engines/engine";
  23124. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23125. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23126. import { Effect } from "babylonjs/Materials/effect";
  23127. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23128. import { Collider } from "babylonjs/Collisions/collider";
  23129. import { Material } from "babylonjs/Materials/material";
  23130. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23132. import { Mesh } from "babylonjs/Meshes/mesh";
  23133. import { Ray } from "babylonjs/Culling/ray";
  23134. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23135. /**
  23136. * Base class for submeshes
  23137. */
  23138. export class BaseSubMesh {
  23139. /** @hidden */
  23140. _materialDefines: Nullable<MaterialDefines>;
  23141. /** @hidden */
  23142. _materialEffect: Nullable<Effect>;
  23143. /**
  23144. * Gets associated effect
  23145. */
  23146. readonly effect: Nullable<Effect>;
  23147. /**
  23148. * Sets associated effect (effect used to render this submesh)
  23149. * @param effect defines the effect to associate with
  23150. * @param defines defines the set of defines used to compile this effect
  23151. */
  23152. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23153. }
  23154. /**
  23155. * Defines a subdivision inside a mesh
  23156. */
  23157. export class SubMesh extends BaseSubMesh implements ICullable {
  23158. /** the material index to use */
  23159. materialIndex: number;
  23160. /** vertex index start */
  23161. verticesStart: number;
  23162. /** vertices count */
  23163. verticesCount: number;
  23164. /** index start */
  23165. indexStart: number;
  23166. /** indices count */
  23167. indexCount: number;
  23168. /** @hidden */
  23169. _linesIndexCount: number;
  23170. private _mesh;
  23171. private _renderingMesh;
  23172. private _boundingInfo;
  23173. private _linesIndexBuffer;
  23174. /** @hidden */
  23175. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23176. /** @hidden */
  23177. _trianglePlanes: Plane[];
  23178. /** @hidden */
  23179. _lastColliderTransformMatrix: Nullable<Matrix>;
  23180. /** @hidden */
  23181. _renderId: number;
  23182. /** @hidden */
  23183. _alphaIndex: number;
  23184. /** @hidden */
  23185. _distanceToCamera: number;
  23186. /** @hidden */
  23187. _id: number;
  23188. private _currentMaterial;
  23189. /**
  23190. * Add a new submesh to a mesh
  23191. * @param materialIndex defines the material index to use
  23192. * @param verticesStart defines vertex index start
  23193. * @param verticesCount defines vertices count
  23194. * @param indexStart defines index start
  23195. * @param indexCount defines indices count
  23196. * @param mesh defines the parent mesh
  23197. * @param renderingMesh defines an optional rendering mesh
  23198. * @param createBoundingBox defines if bounding box should be created for this submesh
  23199. * @returns the new submesh
  23200. */
  23201. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23202. /**
  23203. * Creates a new submesh
  23204. * @param materialIndex defines the material index to use
  23205. * @param verticesStart defines vertex index start
  23206. * @param verticesCount defines vertices count
  23207. * @param indexStart defines index start
  23208. * @param indexCount defines indices count
  23209. * @param mesh defines the parent mesh
  23210. * @param renderingMesh defines an optional rendering mesh
  23211. * @param createBoundingBox defines if bounding box should be created for this submesh
  23212. */
  23213. constructor(
  23214. /** the material index to use */
  23215. materialIndex: number,
  23216. /** vertex index start */
  23217. verticesStart: number,
  23218. /** vertices count */
  23219. verticesCount: number,
  23220. /** index start */
  23221. indexStart: number,
  23222. /** indices count */
  23223. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23224. /**
  23225. * Returns true if this submesh covers the entire parent mesh
  23226. * @ignorenaming
  23227. */
  23228. readonly IsGlobal: boolean;
  23229. /**
  23230. * Returns the submesh BoudingInfo object
  23231. * @returns current bounding info (or mesh's one if the submesh is global)
  23232. */
  23233. getBoundingInfo(): BoundingInfo;
  23234. /**
  23235. * Sets the submesh BoundingInfo
  23236. * @param boundingInfo defines the new bounding info to use
  23237. * @returns the SubMesh
  23238. */
  23239. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23240. /**
  23241. * Returns the mesh of the current submesh
  23242. * @return the parent mesh
  23243. */
  23244. getMesh(): AbstractMesh;
  23245. /**
  23246. * Returns the rendering mesh of the submesh
  23247. * @returns the rendering mesh (could be different from parent mesh)
  23248. */
  23249. getRenderingMesh(): Mesh;
  23250. /**
  23251. * Returns the submesh material
  23252. * @returns null or the current material
  23253. */
  23254. getMaterial(): Nullable<Material>;
  23255. /**
  23256. * Sets a new updated BoundingInfo object to the submesh
  23257. * @param data defines an optional position array to use to determine the bounding info
  23258. * @returns the SubMesh
  23259. */
  23260. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23261. /** @hidden */
  23262. _checkCollision(collider: Collider): boolean;
  23263. /**
  23264. * Updates the submesh BoundingInfo
  23265. * @param world defines the world matrix to use to update the bounding info
  23266. * @returns the submesh
  23267. */
  23268. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23269. /**
  23270. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23271. * @param frustumPlanes defines the frustum planes
  23272. * @returns true if the submesh is intersecting with the frustum
  23273. */
  23274. isInFrustum(frustumPlanes: Plane[]): boolean;
  23275. /**
  23276. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23277. * @param frustumPlanes defines the frustum planes
  23278. * @returns true if the submesh is inside the frustum
  23279. */
  23280. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23281. /**
  23282. * Renders the submesh
  23283. * @param enableAlphaMode defines if alpha needs to be used
  23284. * @returns the submesh
  23285. */
  23286. render(enableAlphaMode: boolean): SubMesh;
  23287. /**
  23288. * @hidden
  23289. */
  23290. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23291. /**
  23292. * Checks if the submesh intersects with a ray
  23293. * @param ray defines the ray to test
  23294. * @returns true is the passed ray intersects the submesh bounding box
  23295. */
  23296. canIntersects(ray: Ray): boolean;
  23297. /**
  23298. * Intersects current submesh with a ray
  23299. * @param ray defines the ray to test
  23300. * @param positions defines mesh's positions array
  23301. * @param indices defines mesh's indices array
  23302. * @param fastCheck defines if only bounding info should be used
  23303. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23304. * @returns intersection info or null if no intersection
  23305. */
  23306. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23307. /** @hidden */
  23308. private _intersectLines;
  23309. /** @hidden */
  23310. private _intersectTriangles;
  23311. /** @hidden */
  23312. _rebuild(): void;
  23313. /**
  23314. * Creates a new submesh from the passed mesh
  23315. * @param newMesh defines the new hosting mesh
  23316. * @param newRenderingMesh defines an optional rendering mesh
  23317. * @returns the new submesh
  23318. */
  23319. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23320. /**
  23321. * Release associated resources
  23322. */
  23323. dispose(): void;
  23324. /**
  23325. * Gets the class name
  23326. * @returns the string "SubMesh".
  23327. */
  23328. getClassName(): string;
  23329. /**
  23330. * Creates a new submesh from indices data
  23331. * @param materialIndex the index of the main mesh material
  23332. * @param startIndex the index where to start the copy in the mesh indices array
  23333. * @param indexCount the number of indices to copy then from the startIndex
  23334. * @param mesh the main mesh to create the submesh from
  23335. * @param renderingMesh the optional rendering mesh
  23336. * @returns a new submesh
  23337. */
  23338. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23339. }
  23340. }
  23341. declare module "babylonjs/Meshes/geometry" {
  23342. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23343. import { Scene } from "babylonjs/scene";
  23344. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23345. import { Engine } from "babylonjs/Engines/engine";
  23346. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23347. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23348. import { Effect } from "babylonjs/Materials/effect";
  23349. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23350. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23351. import { Mesh } from "babylonjs/Meshes/mesh";
  23352. /**
  23353. * Class used to store geometry data (vertex buffers + index buffer)
  23354. */
  23355. export class Geometry implements IGetSetVerticesData {
  23356. /**
  23357. * Gets or sets the ID of the geometry
  23358. */
  23359. id: string;
  23360. /**
  23361. * Gets or sets the unique ID of the geometry
  23362. */
  23363. uniqueId: number;
  23364. /**
  23365. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23366. */
  23367. delayLoadState: number;
  23368. /**
  23369. * Gets the file containing the data to load when running in delay load state
  23370. */
  23371. delayLoadingFile: Nullable<string>;
  23372. /**
  23373. * Callback called when the geometry is updated
  23374. */
  23375. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23376. private _scene;
  23377. private _engine;
  23378. private _meshes;
  23379. private _totalVertices;
  23380. /** @hidden */
  23381. _indices: IndicesArray;
  23382. /** @hidden */
  23383. _vertexBuffers: {
  23384. [key: string]: VertexBuffer;
  23385. };
  23386. private _isDisposed;
  23387. private _extend;
  23388. private _boundingBias;
  23389. /** @hidden */
  23390. _delayInfo: Array<string>;
  23391. private _indexBuffer;
  23392. private _indexBufferIsUpdatable;
  23393. /** @hidden */
  23394. _boundingInfo: Nullable<BoundingInfo>;
  23395. /** @hidden */
  23396. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23397. /** @hidden */
  23398. _softwareSkinningFrameId: number;
  23399. private _vertexArrayObjects;
  23400. private _updatable;
  23401. /** @hidden */
  23402. _positions: Nullable<Vector3[]>;
  23403. /**
  23404. * 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
  23405. */
  23406. /**
  23407. * 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
  23408. */
  23409. boundingBias: Vector2;
  23410. /**
  23411. * Static function used to attach a new empty geometry to a mesh
  23412. * @param mesh defines the mesh to attach the geometry to
  23413. * @returns the new Geometry
  23414. */
  23415. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23416. /**
  23417. * Creates a new geometry
  23418. * @param id defines the unique ID
  23419. * @param scene defines the hosting scene
  23420. * @param vertexData defines the VertexData used to get geometry data
  23421. * @param updatable defines if geometry must be updatable (false by default)
  23422. * @param mesh defines the mesh that will be associated with the geometry
  23423. */
  23424. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23425. /**
  23426. * Gets the current extend of the geometry
  23427. */
  23428. readonly extend: {
  23429. minimum: Vector3;
  23430. maximum: Vector3;
  23431. };
  23432. /**
  23433. * Gets the hosting scene
  23434. * @returns the hosting Scene
  23435. */
  23436. getScene(): Scene;
  23437. /**
  23438. * Gets the hosting engine
  23439. * @returns the hosting Engine
  23440. */
  23441. getEngine(): Engine;
  23442. /**
  23443. * Defines if the geometry is ready to use
  23444. * @returns true if the geometry is ready to be used
  23445. */
  23446. isReady(): boolean;
  23447. /**
  23448. * Gets a value indicating that the geometry should not be serialized
  23449. */
  23450. readonly doNotSerialize: boolean;
  23451. /** @hidden */
  23452. _rebuild(): void;
  23453. /**
  23454. * Affects all geometry data in one call
  23455. * @param vertexData defines the geometry data
  23456. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23457. */
  23458. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23459. /**
  23460. * Set specific vertex data
  23461. * @param kind defines the data kind (Position, normal, etc...)
  23462. * @param data defines the vertex data to use
  23463. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23464. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23465. */
  23466. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23467. /**
  23468. * Removes a specific vertex data
  23469. * @param kind defines the data kind (Position, normal, etc...)
  23470. */
  23471. removeVerticesData(kind: string): void;
  23472. /**
  23473. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23474. * @param buffer defines the vertex buffer to use
  23475. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23476. */
  23477. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23478. /**
  23479. * Update a specific vertex buffer
  23480. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23481. * It will do nothing if the buffer is not updatable
  23482. * @param kind defines the data kind (Position, normal, etc...)
  23483. * @param data defines the data to use
  23484. * @param offset defines the offset in the target buffer where to store the data
  23485. * @param useBytes set to true if the offset is in bytes
  23486. */
  23487. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23488. /**
  23489. * Update a specific vertex buffer
  23490. * This function will create a new buffer if the current one is not updatable
  23491. * @param kind defines the data kind (Position, normal, etc...)
  23492. * @param data defines the data to use
  23493. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23494. */
  23495. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23496. private _updateBoundingInfo;
  23497. /** @hidden */
  23498. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23499. /**
  23500. * Gets total number of vertices
  23501. * @returns the total number of vertices
  23502. */
  23503. getTotalVertices(): number;
  23504. /**
  23505. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23506. * @param kind defines the data kind (Position, normal, etc...)
  23507. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23508. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23509. * @returns a float array containing vertex data
  23510. */
  23511. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23512. /**
  23513. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23514. * @param kind defines the data kind (Position, normal, etc...)
  23515. * @returns true if the vertex buffer with the specified kind is updatable
  23516. */
  23517. isVertexBufferUpdatable(kind: string): boolean;
  23518. /**
  23519. * Gets a specific vertex buffer
  23520. * @param kind defines the data kind (Position, normal, etc...)
  23521. * @returns a VertexBuffer
  23522. */
  23523. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23524. /**
  23525. * Returns all vertex buffers
  23526. * @return an object holding all vertex buffers indexed by kind
  23527. */
  23528. getVertexBuffers(): Nullable<{
  23529. [key: string]: VertexBuffer;
  23530. }>;
  23531. /**
  23532. * Gets a boolean indicating if specific vertex buffer is present
  23533. * @param kind defines the data kind (Position, normal, etc...)
  23534. * @returns true if data is present
  23535. */
  23536. isVerticesDataPresent(kind: string): boolean;
  23537. /**
  23538. * Gets a list of all attached data kinds (Position, normal, etc...)
  23539. * @returns a list of string containing all kinds
  23540. */
  23541. getVerticesDataKinds(): string[];
  23542. /**
  23543. * Update index buffer
  23544. * @param indices defines the indices to store in the index buffer
  23545. * @param offset defines the offset in the target buffer where to store the data
  23546. * @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)
  23547. */
  23548. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23549. /**
  23550. * Creates a new index buffer
  23551. * @param indices defines the indices to store in the index buffer
  23552. * @param totalVertices defines the total number of vertices (could be null)
  23553. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23554. */
  23555. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23556. /**
  23557. * Return the total number of indices
  23558. * @returns the total number of indices
  23559. */
  23560. getTotalIndices(): number;
  23561. /**
  23562. * Gets the index buffer array
  23563. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23564. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23565. * @returns the index buffer array
  23566. */
  23567. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23568. /**
  23569. * Gets the index buffer
  23570. * @return the index buffer
  23571. */
  23572. getIndexBuffer(): Nullable<DataBuffer>;
  23573. /** @hidden */
  23574. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23575. /**
  23576. * Release the associated resources for a specific mesh
  23577. * @param mesh defines the source mesh
  23578. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23579. */
  23580. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23581. /**
  23582. * Apply current geometry to a given mesh
  23583. * @param mesh defines the mesh to apply geometry to
  23584. */
  23585. applyToMesh(mesh: Mesh): void;
  23586. private _updateExtend;
  23587. private _applyToMesh;
  23588. private notifyUpdate;
  23589. /**
  23590. * Load the geometry if it was flagged as delay loaded
  23591. * @param scene defines the hosting scene
  23592. * @param onLoaded defines a callback called when the geometry is loaded
  23593. */
  23594. load(scene: Scene, onLoaded?: () => void): void;
  23595. private _queueLoad;
  23596. /**
  23597. * Invert the geometry to move from a right handed system to a left handed one.
  23598. */
  23599. toLeftHanded(): void;
  23600. /** @hidden */
  23601. _resetPointsArrayCache(): void;
  23602. /** @hidden */
  23603. _generatePointsArray(): boolean;
  23604. /**
  23605. * Gets a value indicating if the geometry is disposed
  23606. * @returns true if the geometry was disposed
  23607. */
  23608. isDisposed(): boolean;
  23609. private _disposeVertexArrayObjects;
  23610. /**
  23611. * Free all associated resources
  23612. */
  23613. dispose(): void;
  23614. /**
  23615. * Clone the current geometry into a new geometry
  23616. * @param id defines the unique ID of the new geometry
  23617. * @returns a new geometry object
  23618. */
  23619. copy(id: string): Geometry;
  23620. /**
  23621. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23622. * @return a JSON representation of the current geometry data (without the vertices data)
  23623. */
  23624. serialize(): any;
  23625. private toNumberArray;
  23626. /**
  23627. * Serialize all vertices data into a JSON oject
  23628. * @returns a JSON representation of the current geometry data
  23629. */
  23630. serializeVerticeData(): any;
  23631. /**
  23632. * Extracts a clone of a mesh geometry
  23633. * @param mesh defines the source mesh
  23634. * @param id defines the unique ID of the new geometry object
  23635. * @returns the new geometry object
  23636. */
  23637. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23638. /**
  23639. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23640. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23641. * Be aware Math.random() could cause collisions, but:
  23642. * "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"
  23643. * @returns a string containing a new GUID
  23644. */
  23645. static RandomId(): string;
  23646. /** @hidden */
  23647. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23648. private static _CleanMatricesWeights;
  23649. /**
  23650. * Create a new geometry from persisted data (Using .babylon file format)
  23651. * @param parsedVertexData defines the persisted data
  23652. * @param scene defines the hosting scene
  23653. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23654. * @returns the new geometry object
  23655. */
  23656. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23657. }
  23658. }
  23659. declare module "babylonjs/Meshes/mesh.vertexData" {
  23660. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23661. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23662. import { Geometry } from "babylonjs/Meshes/geometry";
  23663. import { Mesh } from "babylonjs/Meshes/mesh";
  23664. /**
  23665. * Define an interface for all classes that will get and set the data on vertices
  23666. */
  23667. export interface IGetSetVerticesData {
  23668. /**
  23669. * Gets a boolean indicating if specific vertex data is present
  23670. * @param kind defines the vertex data kind to use
  23671. * @returns true is data kind is present
  23672. */
  23673. isVerticesDataPresent(kind: string): boolean;
  23674. /**
  23675. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23676. * @param kind defines the data kind (Position, normal, etc...)
  23677. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23678. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23679. * @returns a float array containing vertex data
  23680. */
  23681. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23682. /**
  23683. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23684. * @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.
  23685. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23686. * @returns the indices array or an empty array if the mesh has no geometry
  23687. */
  23688. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23689. /**
  23690. * Set specific vertex data
  23691. * @param kind defines the data kind (Position, normal, etc...)
  23692. * @param data defines the vertex data to use
  23693. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23694. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23695. */
  23696. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23697. /**
  23698. * Update a specific associated vertex buffer
  23699. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23700. * - VertexBuffer.PositionKind
  23701. * - VertexBuffer.UVKind
  23702. * - VertexBuffer.UV2Kind
  23703. * - VertexBuffer.UV3Kind
  23704. * - VertexBuffer.UV4Kind
  23705. * - VertexBuffer.UV5Kind
  23706. * - VertexBuffer.UV6Kind
  23707. * - VertexBuffer.ColorKind
  23708. * - VertexBuffer.MatricesIndicesKind
  23709. * - VertexBuffer.MatricesIndicesExtraKind
  23710. * - VertexBuffer.MatricesWeightsKind
  23711. * - VertexBuffer.MatricesWeightsExtraKind
  23712. * @param data defines the data source
  23713. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23714. * @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)
  23715. */
  23716. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23717. /**
  23718. * Creates a new index buffer
  23719. * @param indices defines the indices to store in the index buffer
  23720. * @param totalVertices defines the total number of vertices (could be null)
  23721. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23722. */
  23723. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23724. }
  23725. /**
  23726. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23727. */
  23728. export class VertexData {
  23729. /**
  23730. * Mesh side orientation : usually the external or front surface
  23731. */
  23732. static readonly FRONTSIDE: number;
  23733. /**
  23734. * Mesh side orientation : usually the internal or back surface
  23735. */
  23736. static readonly BACKSIDE: number;
  23737. /**
  23738. * Mesh side orientation : both internal and external or front and back surfaces
  23739. */
  23740. static readonly DOUBLESIDE: number;
  23741. /**
  23742. * Mesh side orientation : by default, `FRONTSIDE`
  23743. */
  23744. static readonly DEFAULTSIDE: number;
  23745. /**
  23746. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23747. */
  23748. positions: Nullable<FloatArray>;
  23749. /**
  23750. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23751. */
  23752. normals: Nullable<FloatArray>;
  23753. /**
  23754. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23755. */
  23756. tangents: Nullable<FloatArray>;
  23757. /**
  23758. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23759. */
  23760. uvs: Nullable<FloatArray>;
  23761. /**
  23762. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23763. */
  23764. uvs2: Nullable<FloatArray>;
  23765. /**
  23766. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23767. */
  23768. uvs3: Nullable<FloatArray>;
  23769. /**
  23770. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23771. */
  23772. uvs4: Nullable<FloatArray>;
  23773. /**
  23774. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23775. */
  23776. uvs5: Nullable<FloatArray>;
  23777. /**
  23778. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23779. */
  23780. uvs6: Nullable<FloatArray>;
  23781. /**
  23782. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23783. */
  23784. colors: Nullable<FloatArray>;
  23785. /**
  23786. * 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).
  23787. */
  23788. matricesIndices: Nullable<FloatArray>;
  23789. /**
  23790. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23791. */
  23792. matricesWeights: Nullable<FloatArray>;
  23793. /**
  23794. * An array extending the number of possible indices
  23795. */
  23796. matricesIndicesExtra: Nullable<FloatArray>;
  23797. /**
  23798. * An array extending the number of possible weights when the number of indices is extended
  23799. */
  23800. matricesWeightsExtra: Nullable<FloatArray>;
  23801. /**
  23802. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23803. */
  23804. indices: Nullable<IndicesArray>;
  23805. /**
  23806. * Uses the passed data array to set the set the values for the specified kind of data
  23807. * @param data a linear array of floating numbers
  23808. * @param kind the type of data that is being set, eg positions, colors etc
  23809. */
  23810. set(data: FloatArray, kind: string): void;
  23811. /**
  23812. * Associates the vertexData to the passed Mesh.
  23813. * Sets it as updatable or not (default `false`)
  23814. * @param mesh the mesh the vertexData is applied to
  23815. * @param updatable when used and having the value true allows new data to update the vertexData
  23816. * @returns the VertexData
  23817. */
  23818. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23819. /**
  23820. * Associates the vertexData to the passed Geometry.
  23821. * Sets it as updatable or not (default `false`)
  23822. * @param geometry the geometry the vertexData is applied to
  23823. * @param updatable when used and having the value true allows new data to update the vertexData
  23824. * @returns VertexData
  23825. */
  23826. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23827. /**
  23828. * Updates the associated mesh
  23829. * @param mesh the mesh to be updated
  23830. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23831. * @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
  23832. * @returns VertexData
  23833. */
  23834. updateMesh(mesh: Mesh): VertexData;
  23835. /**
  23836. * Updates the associated geometry
  23837. * @param geometry the geometry to be updated
  23838. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23839. * @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
  23840. * @returns VertexData.
  23841. */
  23842. updateGeometry(geometry: Geometry): VertexData;
  23843. private _applyTo;
  23844. private _update;
  23845. /**
  23846. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23847. * @param matrix the transforming matrix
  23848. * @returns the VertexData
  23849. */
  23850. transform(matrix: Matrix): VertexData;
  23851. /**
  23852. * Merges the passed VertexData into the current one
  23853. * @param other the VertexData to be merged into the current one
  23854. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23855. * @returns the modified VertexData
  23856. */
  23857. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23858. private _mergeElement;
  23859. private _validate;
  23860. /**
  23861. * Serializes the VertexData
  23862. * @returns a serialized object
  23863. */
  23864. serialize(): any;
  23865. /**
  23866. * Extracts the vertexData from a mesh
  23867. * @param mesh the mesh from which to extract the VertexData
  23868. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23869. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23870. * @returns the object VertexData associated to the passed mesh
  23871. */
  23872. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23873. /**
  23874. * Extracts the vertexData from the geometry
  23875. * @param geometry the geometry from which to extract the VertexData
  23876. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23877. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23878. * @returns the object VertexData associated to the passed mesh
  23879. */
  23880. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23881. private static _ExtractFrom;
  23882. /**
  23883. * Creates the VertexData for a Ribbon
  23884. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23885. * * pathArray array of paths, each of which an array of successive Vector3
  23886. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23887. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23888. * * 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
  23889. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23890. * * 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)
  23891. * * 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)
  23892. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23893. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23894. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23895. * @returns the VertexData of the ribbon
  23896. */
  23897. static CreateRibbon(options: {
  23898. pathArray: Vector3[][];
  23899. closeArray?: boolean;
  23900. closePath?: boolean;
  23901. offset?: number;
  23902. sideOrientation?: number;
  23903. frontUVs?: Vector4;
  23904. backUVs?: Vector4;
  23905. invertUV?: boolean;
  23906. uvs?: Vector2[];
  23907. colors?: Color4[];
  23908. }): VertexData;
  23909. /**
  23910. * Creates the VertexData for a box
  23911. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23912. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23913. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23914. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23915. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23916. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23917. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23918. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23919. * * 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)
  23920. * * 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)
  23921. * @returns the VertexData of the box
  23922. */
  23923. static CreateBox(options: {
  23924. size?: number;
  23925. width?: number;
  23926. height?: number;
  23927. depth?: number;
  23928. faceUV?: Vector4[];
  23929. faceColors?: Color4[];
  23930. sideOrientation?: number;
  23931. frontUVs?: Vector4;
  23932. backUVs?: Vector4;
  23933. }): VertexData;
  23934. /**
  23935. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23936. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23937. * * segments sets the number of horizontal strips optional, default 32
  23938. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23939. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23940. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23941. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23942. * * 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
  23943. * * 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
  23944. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23945. * * 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)
  23946. * * 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)
  23947. * @returns the VertexData of the ellipsoid
  23948. */
  23949. static CreateSphere(options: {
  23950. segments?: number;
  23951. diameter?: number;
  23952. diameterX?: number;
  23953. diameterY?: number;
  23954. diameterZ?: number;
  23955. arc?: number;
  23956. slice?: number;
  23957. sideOrientation?: number;
  23958. frontUVs?: Vector4;
  23959. backUVs?: Vector4;
  23960. }): VertexData;
  23961. /**
  23962. * Creates the VertexData for a cylinder, cone or prism
  23963. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23964. * * height sets the height (y direction) of the cylinder, optional, default 2
  23965. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23966. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23967. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23968. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23969. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23970. * * 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
  23971. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23972. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23973. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23974. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23975. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23976. * * 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)
  23977. * * 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)
  23978. * @returns the VertexData of the cylinder, cone or prism
  23979. */
  23980. static CreateCylinder(options: {
  23981. height?: number;
  23982. diameterTop?: number;
  23983. diameterBottom?: number;
  23984. diameter?: number;
  23985. tessellation?: number;
  23986. subdivisions?: number;
  23987. arc?: number;
  23988. faceColors?: Color4[];
  23989. faceUV?: Vector4[];
  23990. hasRings?: boolean;
  23991. enclose?: boolean;
  23992. sideOrientation?: number;
  23993. frontUVs?: Vector4;
  23994. backUVs?: Vector4;
  23995. }): VertexData;
  23996. /**
  23997. * Creates the VertexData for a torus
  23998. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23999. * * diameter the diameter of the torus, optional default 1
  24000. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24001. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24002. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24003. * * 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)
  24004. * * 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)
  24005. * @returns the VertexData of the torus
  24006. */
  24007. static CreateTorus(options: {
  24008. diameter?: number;
  24009. thickness?: number;
  24010. tessellation?: number;
  24011. sideOrientation?: number;
  24012. frontUVs?: Vector4;
  24013. backUVs?: Vector4;
  24014. }): VertexData;
  24015. /**
  24016. * Creates the VertexData of the LineSystem
  24017. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24018. * - lines an array of lines, each line being an array of successive Vector3
  24019. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24020. * @returns the VertexData of the LineSystem
  24021. */
  24022. static CreateLineSystem(options: {
  24023. lines: Vector3[][];
  24024. colors?: Nullable<Color4[][]>;
  24025. }): VertexData;
  24026. /**
  24027. * Create the VertexData for a DashedLines
  24028. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24029. * - points an array successive Vector3
  24030. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24031. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24032. * - dashNb the intended total number of dashes, optional, default 200
  24033. * @returns the VertexData for the DashedLines
  24034. */
  24035. static CreateDashedLines(options: {
  24036. points: Vector3[];
  24037. dashSize?: number;
  24038. gapSize?: number;
  24039. dashNb?: number;
  24040. }): VertexData;
  24041. /**
  24042. * Creates the VertexData for a Ground
  24043. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24044. * - width the width (x direction) of the ground, optional, default 1
  24045. * - height the height (z direction) of the ground, optional, default 1
  24046. * - subdivisions the number of subdivisions per side, optional, default 1
  24047. * @returns the VertexData of the Ground
  24048. */
  24049. static CreateGround(options: {
  24050. width?: number;
  24051. height?: number;
  24052. subdivisions?: number;
  24053. subdivisionsX?: number;
  24054. subdivisionsY?: number;
  24055. }): VertexData;
  24056. /**
  24057. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24058. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24059. * * xmin the ground minimum X coordinate, optional, default -1
  24060. * * zmin the ground minimum Z coordinate, optional, default -1
  24061. * * xmax the ground maximum X coordinate, optional, default 1
  24062. * * zmax the ground maximum Z coordinate, optional, default 1
  24063. * * 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}
  24064. * * 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}
  24065. * @returns the VertexData of the TiledGround
  24066. */
  24067. static CreateTiledGround(options: {
  24068. xmin: number;
  24069. zmin: number;
  24070. xmax: number;
  24071. zmax: number;
  24072. subdivisions?: {
  24073. w: number;
  24074. h: number;
  24075. };
  24076. precision?: {
  24077. w: number;
  24078. h: number;
  24079. };
  24080. }): VertexData;
  24081. /**
  24082. * Creates the VertexData of the Ground designed from a heightmap
  24083. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24084. * * width the width (x direction) of the ground
  24085. * * height the height (z direction) of the ground
  24086. * * subdivisions the number of subdivisions per side
  24087. * * minHeight the minimum altitude on the ground, optional, default 0
  24088. * * maxHeight the maximum altitude on the ground, optional default 1
  24089. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24090. * * buffer the array holding the image color data
  24091. * * bufferWidth the width of image
  24092. * * bufferHeight the height of image
  24093. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24094. * @returns the VertexData of the Ground designed from a heightmap
  24095. */
  24096. static CreateGroundFromHeightMap(options: {
  24097. width: number;
  24098. height: number;
  24099. subdivisions: number;
  24100. minHeight: number;
  24101. maxHeight: number;
  24102. colorFilter: Color3;
  24103. buffer: Uint8Array;
  24104. bufferWidth: number;
  24105. bufferHeight: number;
  24106. alphaFilter: number;
  24107. }): VertexData;
  24108. /**
  24109. * Creates the VertexData for a Plane
  24110. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24111. * * size sets the width and height of the plane to the value of size, optional default 1
  24112. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24113. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24114. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24115. * * 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)
  24116. * * 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)
  24117. * @returns the VertexData of the box
  24118. */
  24119. static CreatePlane(options: {
  24120. size?: number;
  24121. width?: number;
  24122. height?: number;
  24123. sideOrientation?: number;
  24124. frontUVs?: Vector4;
  24125. backUVs?: Vector4;
  24126. }): VertexData;
  24127. /**
  24128. * Creates the VertexData of the Disc or regular Polygon
  24129. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24130. * * radius the radius of the disc, optional default 0.5
  24131. * * tessellation the number of polygon sides, optional, default 64
  24132. * * 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
  24133. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24134. * * 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)
  24135. * * 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)
  24136. * @returns the VertexData of the box
  24137. */
  24138. static CreateDisc(options: {
  24139. radius?: number;
  24140. tessellation?: number;
  24141. arc?: number;
  24142. sideOrientation?: number;
  24143. frontUVs?: Vector4;
  24144. backUVs?: Vector4;
  24145. }): VertexData;
  24146. /**
  24147. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24148. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24149. * @param polygon a mesh built from polygonTriangulation.build()
  24150. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24151. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24152. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24153. * @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)
  24154. * @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)
  24155. * @returns the VertexData of the Polygon
  24156. */
  24157. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24158. /**
  24159. * Creates the VertexData of the IcoSphere
  24160. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24161. * * radius the radius of the IcoSphere, optional default 1
  24162. * * radiusX allows stretching in the x direction, optional, default radius
  24163. * * radiusY allows stretching in the y direction, optional, default radius
  24164. * * radiusZ allows stretching in the z direction, optional, default radius
  24165. * * flat when true creates a flat shaded mesh, optional, default true
  24166. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24167. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24168. * * 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)
  24169. * * 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)
  24170. * @returns the VertexData of the IcoSphere
  24171. */
  24172. static CreateIcoSphere(options: {
  24173. radius?: number;
  24174. radiusX?: number;
  24175. radiusY?: number;
  24176. radiusZ?: number;
  24177. flat?: boolean;
  24178. subdivisions?: number;
  24179. sideOrientation?: number;
  24180. frontUVs?: Vector4;
  24181. backUVs?: Vector4;
  24182. }): VertexData;
  24183. /**
  24184. * Creates the VertexData for a Polyhedron
  24185. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24186. * * type provided types are:
  24187. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24188. * * 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)
  24189. * * size the size of the IcoSphere, optional default 1
  24190. * * sizeX allows stretching in the x direction, optional, default size
  24191. * * sizeY allows stretching in the y direction, optional, default size
  24192. * * sizeZ allows stretching in the z direction, optional, default size
  24193. * * 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
  24194. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24195. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24196. * * flat when true creates a flat shaded mesh, optional, default true
  24197. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24198. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24199. * * 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)
  24200. * * 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)
  24201. * @returns the VertexData of the Polyhedron
  24202. */
  24203. static CreatePolyhedron(options: {
  24204. type?: number;
  24205. size?: number;
  24206. sizeX?: number;
  24207. sizeY?: number;
  24208. sizeZ?: number;
  24209. custom?: any;
  24210. faceUV?: Vector4[];
  24211. faceColors?: Color4[];
  24212. flat?: boolean;
  24213. sideOrientation?: number;
  24214. frontUVs?: Vector4;
  24215. backUVs?: Vector4;
  24216. }): VertexData;
  24217. /**
  24218. * Creates the VertexData for a TorusKnot
  24219. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24220. * * radius the radius of the torus knot, optional, default 2
  24221. * * tube the thickness of the tube, optional, default 0.5
  24222. * * radialSegments the number of sides on each tube segments, optional, default 32
  24223. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24224. * * p the number of windings around the z axis, optional, default 2
  24225. * * q the number of windings around the x axis, optional, default 3
  24226. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24227. * * 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)
  24228. * * 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)
  24229. * @returns the VertexData of the Torus Knot
  24230. */
  24231. static CreateTorusKnot(options: {
  24232. radius?: number;
  24233. tube?: number;
  24234. radialSegments?: number;
  24235. tubularSegments?: number;
  24236. p?: number;
  24237. q?: number;
  24238. sideOrientation?: number;
  24239. frontUVs?: Vector4;
  24240. backUVs?: Vector4;
  24241. }): VertexData;
  24242. /**
  24243. * Compute normals for given positions and indices
  24244. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24245. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24246. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24247. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24248. * * facetNormals : optional array of facet normals (vector3)
  24249. * * facetPositions : optional array of facet positions (vector3)
  24250. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24251. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24252. * * bInfo : optional bounding info, required for facetPartitioning computation
  24253. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24254. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24255. * * useRightHandedSystem: optional boolean to for right handed system computation
  24256. * * depthSort : optional boolean to enable the facet depth sort computation
  24257. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24258. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24259. */
  24260. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24261. facetNormals?: any;
  24262. facetPositions?: any;
  24263. facetPartitioning?: any;
  24264. ratio?: number;
  24265. bInfo?: any;
  24266. bbSize?: Vector3;
  24267. subDiv?: any;
  24268. useRightHandedSystem?: boolean;
  24269. depthSort?: boolean;
  24270. distanceTo?: Vector3;
  24271. depthSortedFacets?: any;
  24272. }): void;
  24273. /** @hidden */
  24274. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24275. /**
  24276. * Applies VertexData created from the imported parameters to the geometry
  24277. * @param parsedVertexData the parsed data from an imported file
  24278. * @param geometry the geometry to apply the VertexData to
  24279. */
  24280. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24281. }
  24282. }
  24283. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24284. import { Nullable } from "babylonjs/types";
  24285. import { Scene } from "babylonjs/scene";
  24286. import { Vector4 } from "babylonjs/Maths/math";
  24287. import { Mesh } from "babylonjs/Meshes/mesh";
  24288. /**
  24289. * Class containing static functions to help procedurally build meshes
  24290. */
  24291. export class DiscBuilder {
  24292. /**
  24293. * Creates a plane polygonal mesh. By default, this is a disc
  24294. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24295. * * 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
  24296. * * 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
  24297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24300. * @param name defines the name of the mesh
  24301. * @param options defines the options used to create the mesh
  24302. * @param scene defines the hosting scene
  24303. * @returns the plane polygonal mesh
  24304. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24305. */
  24306. static CreateDisc(name: string, options: {
  24307. radius?: number;
  24308. tessellation?: number;
  24309. arc?: number;
  24310. updatable?: boolean;
  24311. sideOrientation?: number;
  24312. frontUVs?: Vector4;
  24313. backUVs?: Vector4;
  24314. }, scene?: Nullable<Scene>): Mesh;
  24315. }
  24316. }
  24317. declare module "babylonjs/Particles/solidParticleSystem" {
  24318. import { Vector3 } from "babylonjs/Maths/math";
  24319. import { Mesh } from "babylonjs/Meshes/mesh";
  24320. import { Scene, IDisposable } from "babylonjs/scene";
  24321. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24322. /**
  24323. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24324. *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.
  24325. * The SPS is also a particle system. It provides some methods to manage the particles.
  24326. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24327. *
  24328. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24329. */
  24330. export class SolidParticleSystem implements IDisposable {
  24331. /**
  24332. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24333. * Example : var p = SPS.particles[i];
  24334. */
  24335. particles: SolidParticle[];
  24336. /**
  24337. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24338. */
  24339. nbParticles: number;
  24340. /**
  24341. * If the particles must ever face the camera (default false). Useful for planar particles.
  24342. */
  24343. billboard: boolean;
  24344. /**
  24345. * Recompute normals when adding a shape
  24346. */
  24347. recomputeNormals: boolean;
  24348. /**
  24349. * This a counter ofr your own usage. It's not set by any SPS functions.
  24350. */
  24351. counter: number;
  24352. /**
  24353. * The SPS name. This name is also given to the underlying mesh.
  24354. */
  24355. name: string;
  24356. /**
  24357. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24358. */
  24359. mesh: Mesh;
  24360. /**
  24361. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24362. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24363. */
  24364. vars: any;
  24365. /**
  24366. * This array is populated when the SPS is set as 'pickable'.
  24367. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24368. * Each element of this array is an object `{idx: int, faceId: int}`.
  24369. * `idx` is the picked particle index in the `SPS.particles` array
  24370. * `faceId` is the picked face index counted within this particle.
  24371. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24372. */
  24373. pickedParticles: {
  24374. idx: number;
  24375. faceId: number;
  24376. }[];
  24377. /**
  24378. * This array is populated when `enableDepthSort` is set to true.
  24379. * Each element of this array is an instance of the class DepthSortedParticle.
  24380. */
  24381. depthSortedParticles: DepthSortedParticle[];
  24382. /**
  24383. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24384. * @hidden
  24385. */
  24386. _bSphereOnly: boolean;
  24387. /**
  24388. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24389. * @hidden
  24390. */
  24391. _bSphereRadiusFactor: number;
  24392. private _scene;
  24393. private _positions;
  24394. private _indices;
  24395. private _normals;
  24396. private _colors;
  24397. private _uvs;
  24398. private _indices32;
  24399. private _positions32;
  24400. private _normals32;
  24401. private _fixedNormal32;
  24402. private _colors32;
  24403. private _uvs32;
  24404. private _index;
  24405. private _updatable;
  24406. private _pickable;
  24407. private _isVisibilityBoxLocked;
  24408. private _alwaysVisible;
  24409. private _depthSort;
  24410. private _shapeCounter;
  24411. private _copy;
  24412. private _color;
  24413. private _computeParticleColor;
  24414. private _computeParticleTexture;
  24415. private _computeParticleRotation;
  24416. private _computeParticleVertex;
  24417. private _computeBoundingBox;
  24418. private _depthSortParticles;
  24419. private _camera;
  24420. private _mustUnrotateFixedNormals;
  24421. private _particlesIntersect;
  24422. private _needs32Bits;
  24423. /**
  24424. * Creates a SPS (Solid Particle System) object.
  24425. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24426. * @param scene (Scene) is the scene in which the SPS is added.
  24427. * @param options defines the options of the sps e.g.
  24428. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24429. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24430. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24431. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24432. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24433. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24434. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24435. */
  24436. constructor(name: string, scene: Scene, options?: {
  24437. updatable?: boolean;
  24438. isPickable?: boolean;
  24439. enableDepthSort?: boolean;
  24440. particleIntersection?: boolean;
  24441. boundingSphereOnly?: boolean;
  24442. bSphereRadiusFactor?: number;
  24443. });
  24444. /**
  24445. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24446. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24447. * @returns the created mesh
  24448. */
  24449. buildMesh(): Mesh;
  24450. /**
  24451. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24452. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24453. * Thus the particles generated from `digest()` have their property `position` set yet.
  24454. * @param mesh ( Mesh ) is the mesh to be digested
  24455. * @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
  24456. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24457. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24458. * @returns the current SPS
  24459. */
  24460. digest(mesh: Mesh, options?: {
  24461. facetNb?: number;
  24462. number?: number;
  24463. delta?: number;
  24464. }): SolidParticleSystem;
  24465. private _unrotateFixedNormals;
  24466. private _resetCopy;
  24467. private _meshBuilder;
  24468. private _posToShape;
  24469. private _uvsToShapeUV;
  24470. private _addParticle;
  24471. /**
  24472. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24473. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24474. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24475. * @param nb (positive integer) the number of particles to be created from this model
  24476. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24477. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24478. * @returns the number of shapes in the system
  24479. */
  24480. addShape(mesh: Mesh, nb: number, options?: {
  24481. positionFunction?: any;
  24482. vertexFunction?: any;
  24483. }): number;
  24484. private _rebuildParticle;
  24485. /**
  24486. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24487. * @returns the SPS.
  24488. */
  24489. rebuildMesh(): SolidParticleSystem;
  24490. /**
  24491. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24492. * This method calls `updateParticle()` for each particle of the SPS.
  24493. * For an animated SPS, it is usually called within the render loop.
  24494. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24495. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24496. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24497. * @returns the SPS.
  24498. */
  24499. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24500. /**
  24501. * Disposes the SPS.
  24502. */
  24503. dispose(): void;
  24504. /**
  24505. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24506. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24507. * @returns the SPS.
  24508. */
  24509. refreshVisibleSize(): SolidParticleSystem;
  24510. /**
  24511. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24512. * @param size the size (float) of the visibility box
  24513. * note : this doesn't lock the SPS mesh bounding box.
  24514. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24515. */
  24516. setVisibilityBox(size: number): void;
  24517. /**
  24518. * Gets whether the SPS as always visible or not
  24519. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24520. */
  24521. /**
  24522. * Sets the SPS as always visible or not
  24523. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24524. */
  24525. isAlwaysVisible: boolean;
  24526. /**
  24527. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24528. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24529. */
  24530. /**
  24531. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24532. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24533. */
  24534. isVisibilityBoxLocked: boolean;
  24535. /**
  24536. * Tells to `setParticles()` to compute the particle rotations or not.
  24537. * Default value : true. The SPS is faster when it's set to false.
  24538. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24539. */
  24540. /**
  24541. * Gets if `setParticles()` computes the particle rotations or not.
  24542. * Default value : true. The SPS is faster when it's set to false.
  24543. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24544. */
  24545. computeParticleRotation: boolean;
  24546. /**
  24547. * Tells to `setParticles()` to compute the particle colors or not.
  24548. * Default value : true. The SPS is faster when it's set to false.
  24549. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24550. */
  24551. /**
  24552. * Gets if `setParticles()` computes the particle colors or not.
  24553. * Default value : true. The SPS is faster when it's set to false.
  24554. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24555. */
  24556. computeParticleColor: boolean;
  24557. /**
  24558. * Gets if `setParticles()` computes the particle textures or not.
  24559. * Default value : true. The SPS is faster when it's set to false.
  24560. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24561. */
  24562. computeParticleTexture: boolean;
  24563. /**
  24564. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24565. * Default value : false. The SPS is faster when it's set to false.
  24566. * Note : the particle custom vertex positions aren't stored values.
  24567. */
  24568. /**
  24569. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24570. * Default value : false. The SPS is faster when it's set to false.
  24571. * Note : the particle custom vertex positions aren't stored values.
  24572. */
  24573. computeParticleVertex: boolean;
  24574. /**
  24575. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24576. */
  24577. /**
  24578. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24579. */
  24580. computeBoundingBox: boolean;
  24581. /**
  24582. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24583. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24584. * Default : `true`
  24585. */
  24586. /**
  24587. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24588. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24589. * Default : `true`
  24590. */
  24591. depthSortParticles: boolean;
  24592. /**
  24593. * This function does nothing. It may be overwritten to set all the particle first values.
  24594. * The SPS doesn't call this function, you may have to call it by your own.
  24595. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24596. */
  24597. initParticles(): void;
  24598. /**
  24599. * This function does nothing. It may be overwritten to recycle a particle.
  24600. * The SPS doesn't call this function, you may have to call it by your own.
  24601. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24602. * @param particle The particle to recycle
  24603. * @returns the recycled particle
  24604. */
  24605. recycleParticle(particle: SolidParticle): SolidParticle;
  24606. /**
  24607. * Updates a particle : this function should be overwritten by the user.
  24608. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24609. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24610. * @example : just set a particle position or velocity and recycle conditions
  24611. * @param particle The particle to update
  24612. * @returns the updated particle
  24613. */
  24614. updateParticle(particle: SolidParticle): SolidParticle;
  24615. /**
  24616. * Updates a vertex of a particle : it can be overwritten by the user.
  24617. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24618. * @param particle the current particle
  24619. * @param vertex the current index of the current particle
  24620. * @param pt the index of the current vertex in the particle shape
  24621. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24622. * @example : just set a vertex particle position
  24623. * @returns the updated vertex
  24624. */
  24625. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24626. /**
  24627. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24628. * This does nothing and may be overwritten by the user.
  24629. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24630. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24631. * @param update the boolean update value actually passed to setParticles()
  24632. */
  24633. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24634. /**
  24635. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24636. * This will be passed three parameters.
  24637. * This does nothing and may be overwritten by the user.
  24638. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24639. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24640. * @param update the boolean update value actually passed to setParticles()
  24641. */
  24642. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24643. }
  24644. }
  24645. declare module "babylonjs/Particles/solidParticle" {
  24646. import { Nullable } from "babylonjs/types";
  24647. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24648. import { Mesh } from "babylonjs/Meshes/mesh";
  24649. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24650. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24651. /**
  24652. * Represents one particle of a solid particle system.
  24653. */
  24654. export class SolidParticle {
  24655. /**
  24656. * particle global index
  24657. */
  24658. idx: number;
  24659. /**
  24660. * The color of the particle
  24661. */
  24662. color: Nullable<Color4>;
  24663. /**
  24664. * The world space position of the particle.
  24665. */
  24666. position: Vector3;
  24667. /**
  24668. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24669. */
  24670. rotation: Vector3;
  24671. /**
  24672. * The world space rotation quaternion of the particle.
  24673. */
  24674. rotationQuaternion: Nullable<Quaternion>;
  24675. /**
  24676. * The scaling of the particle.
  24677. */
  24678. scaling: Vector3;
  24679. /**
  24680. * The uvs of the particle.
  24681. */
  24682. uvs: Vector4;
  24683. /**
  24684. * The current speed of the particle.
  24685. */
  24686. velocity: Vector3;
  24687. /**
  24688. * The pivot point in the particle local space.
  24689. */
  24690. pivot: Vector3;
  24691. /**
  24692. * Must the particle be translated from its pivot point in its local space ?
  24693. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24694. * Default : false
  24695. */
  24696. translateFromPivot: boolean;
  24697. /**
  24698. * Is the particle active or not ?
  24699. */
  24700. alive: boolean;
  24701. /**
  24702. * Is the particle visible or not ?
  24703. */
  24704. isVisible: boolean;
  24705. /**
  24706. * Index of this particle in the global "positions" array (Internal use)
  24707. * @hidden
  24708. */
  24709. _pos: number;
  24710. /**
  24711. * @hidden Index of this particle in the global "indices" array (Internal use)
  24712. */
  24713. _ind: number;
  24714. /**
  24715. * @hidden ModelShape of this particle (Internal use)
  24716. */
  24717. _model: ModelShape;
  24718. /**
  24719. * ModelShape id of this particle
  24720. */
  24721. shapeId: number;
  24722. /**
  24723. * Index of the particle in its shape id (Internal use)
  24724. */
  24725. idxInShape: number;
  24726. /**
  24727. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24728. */
  24729. _modelBoundingInfo: BoundingInfo;
  24730. /**
  24731. * @hidden Particle BoundingInfo object (Internal use)
  24732. */
  24733. _boundingInfo: BoundingInfo;
  24734. /**
  24735. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24736. */
  24737. _sps: SolidParticleSystem;
  24738. /**
  24739. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24740. */
  24741. _stillInvisible: boolean;
  24742. /**
  24743. * @hidden Last computed particle rotation matrix
  24744. */
  24745. _rotationMatrix: number[];
  24746. /**
  24747. * Parent particle Id, if any.
  24748. * Default null.
  24749. */
  24750. parentId: Nullable<number>;
  24751. /**
  24752. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24753. * The possible values are :
  24754. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24755. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24756. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24757. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24758. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24759. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24760. * */
  24761. cullingStrategy: number;
  24762. /**
  24763. * @hidden Internal global position in the SPS.
  24764. */
  24765. _globalPosition: Vector3;
  24766. /**
  24767. * Creates a Solid Particle object.
  24768. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24769. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24770. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24771. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24772. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24773. * @param shapeId (integer) is the model shape identifier in the SPS.
  24774. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24775. * @param sps defines the sps it is associated to
  24776. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24777. */
  24778. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24779. /**
  24780. * Legacy support, changed scale to scaling
  24781. */
  24782. /**
  24783. * Legacy support, changed scale to scaling
  24784. */
  24785. scale: Vector3;
  24786. /**
  24787. * Legacy support, changed quaternion to rotationQuaternion
  24788. */
  24789. /**
  24790. * Legacy support, changed quaternion to rotationQuaternion
  24791. */
  24792. quaternion: Nullable<Quaternion>;
  24793. /**
  24794. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24795. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24796. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24797. * @returns true if it intersects
  24798. */
  24799. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24800. /**
  24801. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24802. * A particle is in the frustum if its bounding box intersects the frustum
  24803. * @param frustumPlanes defines the frustum to test
  24804. * @returns true if the particle is in the frustum planes
  24805. */
  24806. isInFrustum(frustumPlanes: Plane[]): boolean;
  24807. /**
  24808. * get the rotation matrix of the particle
  24809. * @hidden
  24810. */
  24811. getRotationMatrix(m: Matrix): void;
  24812. }
  24813. /**
  24814. * Represents the shape of the model used by one particle of a solid particle system.
  24815. * SPS internal tool, don't use it manually.
  24816. */
  24817. export class ModelShape {
  24818. /**
  24819. * The shape id
  24820. * @hidden
  24821. */
  24822. shapeID: number;
  24823. /**
  24824. * flat array of model positions (internal use)
  24825. * @hidden
  24826. */
  24827. _shape: Vector3[];
  24828. /**
  24829. * flat array of model UVs (internal use)
  24830. * @hidden
  24831. */
  24832. _shapeUV: number[];
  24833. /**
  24834. * length of the shape in the model indices array (internal use)
  24835. * @hidden
  24836. */
  24837. _indicesLength: number;
  24838. /**
  24839. * Custom position function (internal use)
  24840. * @hidden
  24841. */
  24842. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24843. /**
  24844. * Custom vertex function (internal use)
  24845. * @hidden
  24846. */
  24847. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24848. /**
  24849. * 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.
  24850. * SPS internal tool, don't use it manually.
  24851. * @hidden
  24852. */
  24853. 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>);
  24854. }
  24855. /**
  24856. * Represents a Depth Sorted Particle in the solid particle system.
  24857. */
  24858. export class DepthSortedParticle {
  24859. /**
  24860. * Index of the particle in the "indices" array
  24861. */
  24862. ind: number;
  24863. /**
  24864. * Length of the particle shape in the "indices" array
  24865. */
  24866. indicesLength: number;
  24867. /**
  24868. * Squared distance from the particle to the camera
  24869. */
  24870. sqDistance: number;
  24871. }
  24872. }
  24873. declare module "babylonjs/Meshes/abstractMesh" {
  24874. import { Observable } from "babylonjs/Misc/observable";
  24875. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24876. import { Camera } from "babylonjs/Cameras/camera";
  24877. import { Scene, IDisposable } from "babylonjs/scene";
  24878. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24879. import { Node } from "babylonjs/node";
  24880. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24881. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24882. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24883. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24884. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24885. import { Material } from "babylonjs/Materials/material";
  24886. import { Light } from "babylonjs/Lights/light";
  24887. import { Skeleton } from "babylonjs/Bones/skeleton";
  24888. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24889. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24890. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24891. import { Ray } from "babylonjs/Culling/ray";
  24892. import { Collider } from "babylonjs/Collisions/collider";
  24893. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24894. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24895. /**
  24896. * Class used to store all common mesh properties
  24897. */
  24898. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24899. /** No occlusion */
  24900. static OCCLUSION_TYPE_NONE: number;
  24901. /** Occlusion set to optimisitic */
  24902. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24903. /** Occlusion set to strict */
  24904. static OCCLUSION_TYPE_STRICT: number;
  24905. /** Use an accurante occlusion algorithm */
  24906. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24907. /** Use a conservative occlusion algorithm */
  24908. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24909. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24910. * Test order :
  24911. * Is the bounding sphere outside the frustum ?
  24912. * If not, are the bounding box vertices outside the frustum ?
  24913. * It not, then the cullable object is in the frustum.
  24914. */
  24915. static readonly CULLINGSTRATEGY_STANDARD: number;
  24916. /** Culling strategy : Bounding Sphere Only.
  24917. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24918. * It's also less accurate than the standard because some not visible objects can still be selected.
  24919. * Test : is the bounding sphere outside the frustum ?
  24920. * If not, then the cullable object is in the frustum.
  24921. */
  24922. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24923. /** Culling strategy : Optimistic Inclusion.
  24924. * This in an inclusion test first, then the standard exclusion test.
  24925. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24926. * 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.
  24927. * Anyway, it's as accurate as the standard strategy.
  24928. * Test :
  24929. * Is the cullable object bounding sphere center in the frustum ?
  24930. * If not, apply the default culling strategy.
  24931. */
  24932. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24933. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24934. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24935. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24936. * 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.
  24937. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24938. * Test :
  24939. * Is the cullable object bounding sphere center in the frustum ?
  24940. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24941. */
  24942. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24943. /**
  24944. * No billboard
  24945. */
  24946. static readonly BILLBOARDMODE_NONE: number;
  24947. /** Billboard on X axis */
  24948. static readonly BILLBOARDMODE_X: number;
  24949. /** Billboard on Y axis */
  24950. static readonly BILLBOARDMODE_Y: number;
  24951. /** Billboard on Z axis */
  24952. static readonly BILLBOARDMODE_Z: number;
  24953. /** Billboard on all axes */
  24954. static readonly BILLBOARDMODE_ALL: number;
  24955. private _facetData;
  24956. /**
  24957. * The culling strategy to use to check whether the mesh must be rendered or not.
  24958. * This value can be changed at any time and will be used on the next render mesh selection.
  24959. * The possible values are :
  24960. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24961. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24962. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24963. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24964. * Please read each static variable documentation to get details about the culling process.
  24965. * */
  24966. cullingStrategy: number;
  24967. /**
  24968. * Gets the number of facets in the mesh
  24969. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24970. */
  24971. readonly facetNb: number;
  24972. /**
  24973. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24975. */
  24976. partitioningSubdivisions: number;
  24977. /**
  24978. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24979. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24981. */
  24982. partitioningBBoxRatio: number;
  24983. /**
  24984. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24985. * Works only for updatable meshes.
  24986. * Doesn't work with multi-materials
  24987. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24988. */
  24989. mustDepthSortFacets: boolean;
  24990. /**
  24991. * The location (Vector3) where the facet depth sort must be computed from.
  24992. * By default, the active camera position.
  24993. * Used only when facet depth sort is enabled
  24994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24995. */
  24996. facetDepthSortFrom: Vector3;
  24997. /**
  24998. * gets a boolean indicating if facetData is enabled
  24999. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25000. */
  25001. readonly isFacetDataEnabled: boolean;
  25002. /** @hidden */
  25003. _updateNonUniformScalingState(value: boolean): boolean;
  25004. /**
  25005. * An event triggered when this mesh collides with another one
  25006. */
  25007. onCollideObservable: Observable<AbstractMesh>;
  25008. private _onCollideObserver;
  25009. /** Set a function to call when this mesh collides with another one */
  25010. onCollide: () => void;
  25011. /**
  25012. * An event triggered when the collision's position changes
  25013. */
  25014. onCollisionPositionChangeObservable: Observable<Vector3>;
  25015. private _onCollisionPositionChangeObserver;
  25016. /** Set a function to call when the collision's position changes */
  25017. onCollisionPositionChange: () => void;
  25018. /**
  25019. * An event triggered when material is changed
  25020. */
  25021. onMaterialChangedObservable: Observable<AbstractMesh>;
  25022. /**
  25023. * Gets or sets the orientation for POV movement & rotation
  25024. */
  25025. definedFacingForward: boolean;
  25026. /** @hidden */
  25027. _occlusionQuery: Nullable<WebGLQuery>;
  25028. private _visibility;
  25029. /** @hidden */
  25030. _isActive: boolean;
  25031. /** @hidden */
  25032. _onlyForInstances: boolean;
  25033. /** @hidden */
  25034. _renderingGroup: Nullable<RenderingGroup>;
  25035. /**
  25036. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25037. */
  25038. /**
  25039. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25040. */
  25041. visibility: number;
  25042. /** Gets or sets the alpha index used to sort transparent meshes
  25043. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25044. */
  25045. alphaIndex: number;
  25046. /**
  25047. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25048. */
  25049. isVisible: boolean;
  25050. /**
  25051. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25052. */
  25053. isPickable: boolean;
  25054. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25055. showSubMeshesBoundingBox: boolean;
  25056. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25057. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25058. */
  25059. isBlocker: boolean;
  25060. /**
  25061. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25062. */
  25063. enablePointerMoveEvents: boolean;
  25064. /**
  25065. * Specifies the rendering group id for this mesh (0 by default)
  25066. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25067. */
  25068. renderingGroupId: number;
  25069. private _material;
  25070. /** Gets or sets current material */
  25071. material: Nullable<Material>;
  25072. private _receiveShadows;
  25073. /**
  25074. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25075. * @see http://doc.babylonjs.com/babylon101/shadows
  25076. */
  25077. receiveShadows: boolean;
  25078. /** Defines color to use when rendering outline */
  25079. outlineColor: Color3;
  25080. /** Define width to use when rendering outline */
  25081. outlineWidth: number;
  25082. /** Defines color to use when rendering overlay */
  25083. overlayColor: Color3;
  25084. /** Defines alpha to use when rendering overlay */
  25085. overlayAlpha: number;
  25086. private _hasVertexAlpha;
  25087. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25088. hasVertexAlpha: boolean;
  25089. private _useVertexColors;
  25090. /** 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) */
  25091. useVertexColors: boolean;
  25092. private _computeBonesUsingShaders;
  25093. /**
  25094. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25095. */
  25096. computeBonesUsingShaders: boolean;
  25097. private _numBoneInfluencers;
  25098. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25099. numBoneInfluencers: number;
  25100. private _applyFog;
  25101. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25102. applyFog: boolean;
  25103. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25104. useOctreeForRenderingSelection: boolean;
  25105. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25106. useOctreeForPicking: boolean;
  25107. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25108. useOctreeForCollisions: boolean;
  25109. private _layerMask;
  25110. /**
  25111. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25112. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25113. */
  25114. layerMask: number;
  25115. /**
  25116. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25117. */
  25118. alwaysSelectAsActiveMesh: boolean;
  25119. /**
  25120. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25121. */
  25122. doNotSyncBoundingInfo: boolean;
  25123. /**
  25124. * Gets or sets the current action manager
  25125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25126. */
  25127. actionManager: Nullable<AbstractActionManager>;
  25128. private _checkCollisions;
  25129. private _collisionMask;
  25130. private _collisionGroup;
  25131. /**
  25132. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25133. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25134. */
  25135. ellipsoid: Vector3;
  25136. /**
  25137. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25138. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25139. */
  25140. ellipsoidOffset: Vector3;
  25141. private _collider;
  25142. private _oldPositionForCollisions;
  25143. private _diffPositionForCollisions;
  25144. /**
  25145. * Gets or sets a collision mask used to mask collisions (default is -1).
  25146. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25147. */
  25148. collisionMask: number;
  25149. /**
  25150. * Gets or sets the current collision group mask (-1 by default).
  25151. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25152. */
  25153. collisionGroup: number;
  25154. /**
  25155. * Defines edge width used when edgesRenderer is enabled
  25156. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25157. */
  25158. edgesWidth: number;
  25159. /**
  25160. * Defines edge color used when edgesRenderer is enabled
  25161. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25162. */
  25163. edgesColor: Color4;
  25164. /** @hidden */
  25165. _edgesRenderer: Nullable<IEdgesRenderer>;
  25166. /** @hidden */
  25167. _masterMesh: Nullable<AbstractMesh>;
  25168. /** @hidden */
  25169. _boundingInfo: Nullable<BoundingInfo>;
  25170. /** @hidden */
  25171. _renderId: number;
  25172. /**
  25173. * Gets or sets the list of subMeshes
  25174. * @see http://doc.babylonjs.com/how_to/multi_materials
  25175. */
  25176. subMeshes: SubMesh[];
  25177. /** @hidden */
  25178. _intersectionsInProgress: AbstractMesh[];
  25179. /** @hidden */
  25180. _unIndexed: boolean;
  25181. /** @hidden */
  25182. _lightSources: Light[];
  25183. /** Gets the list of lights affecting that mesh */
  25184. readonly lightSources: Light[];
  25185. /** @hidden */
  25186. readonly _positions: Nullable<Vector3[]>;
  25187. /** @hidden */
  25188. _waitingActions: Nullable<any>;
  25189. /** @hidden */
  25190. _waitingFreezeWorldMatrix: Nullable<boolean>;
  25191. private _skeleton;
  25192. /** @hidden */
  25193. _bonesTransformMatrices: Nullable<Float32Array>;
  25194. /**
  25195. * Gets or sets a skeleton to apply skining transformations
  25196. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25197. */
  25198. skeleton: Nullable<Skeleton>;
  25199. /**
  25200. * An event triggered when the mesh is rebuilt.
  25201. */
  25202. onRebuildObservable: Observable<AbstractMesh>;
  25203. /**
  25204. * Creates a new AbstractMesh
  25205. * @param name defines the name of the mesh
  25206. * @param scene defines the hosting scene
  25207. */
  25208. constructor(name: string, scene?: Nullable<Scene>);
  25209. /**
  25210. * Returns the string "AbstractMesh"
  25211. * @returns "AbstractMesh"
  25212. */
  25213. getClassName(): string;
  25214. /**
  25215. * Gets a string representation of the current mesh
  25216. * @param fullDetails defines a boolean indicating if full details must be included
  25217. * @returns a string representation of the current mesh
  25218. */
  25219. toString(fullDetails?: boolean): string;
  25220. /**
  25221. * @hidden
  25222. */
  25223. protected _getEffectiveParent(): Nullable<Node>;
  25224. /** @hidden */
  25225. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25226. /** @hidden */
  25227. _rebuild(): void;
  25228. /** @hidden */
  25229. _resyncLightSources(): void;
  25230. /** @hidden */
  25231. _resyncLighSource(light: Light): void;
  25232. /** @hidden */
  25233. _unBindEffect(): void;
  25234. /** @hidden */
  25235. _removeLightSource(light: Light): void;
  25236. private _markSubMeshesAsDirty;
  25237. /** @hidden */
  25238. _markSubMeshesAsLightDirty(): void;
  25239. /** @hidden */
  25240. _markSubMeshesAsAttributesDirty(): void;
  25241. /** @hidden */
  25242. _markSubMeshesAsMiscDirty(): void;
  25243. /**
  25244. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25245. */
  25246. scaling: Vector3;
  25247. /**
  25248. * Returns true if the mesh is blocked. Implemented by child classes
  25249. */
  25250. readonly isBlocked: boolean;
  25251. /**
  25252. * Returns the mesh itself by default. Implemented by child classes
  25253. * @param camera defines the camera to use to pick the right LOD level
  25254. * @returns the currentAbstractMesh
  25255. */
  25256. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25257. /**
  25258. * Returns 0 by default. Implemented by child classes
  25259. * @returns an integer
  25260. */
  25261. getTotalVertices(): number;
  25262. /**
  25263. * Returns a positive integer : the total number of indices in this mesh geometry.
  25264. * @returns the numner of indices or zero if the mesh has no geometry.
  25265. */
  25266. getTotalIndices(): number;
  25267. /**
  25268. * Returns null by default. Implemented by child classes
  25269. * @returns null
  25270. */
  25271. getIndices(): Nullable<IndicesArray>;
  25272. /**
  25273. * Returns the array of the requested vertex data kind. Implemented by child classes
  25274. * @param kind defines the vertex data kind to use
  25275. * @returns null
  25276. */
  25277. getVerticesData(kind: string): Nullable<FloatArray>;
  25278. /**
  25279. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25280. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25281. * Note that a new underlying VertexBuffer object is created each call.
  25282. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25283. * @param kind defines vertex data kind:
  25284. * * VertexBuffer.PositionKind
  25285. * * VertexBuffer.UVKind
  25286. * * VertexBuffer.UV2Kind
  25287. * * VertexBuffer.UV3Kind
  25288. * * VertexBuffer.UV4Kind
  25289. * * VertexBuffer.UV5Kind
  25290. * * VertexBuffer.UV6Kind
  25291. * * VertexBuffer.ColorKind
  25292. * * VertexBuffer.MatricesIndicesKind
  25293. * * VertexBuffer.MatricesIndicesExtraKind
  25294. * * VertexBuffer.MatricesWeightsKind
  25295. * * VertexBuffer.MatricesWeightsExtraKind
  25296. * @param data defines the data source
  25297. * @param updatable defines if the data must be flagged as updatable (or static)
  25298. * @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
  25299. * @returns the current mesh
  25300. */
  25301. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25302. /**
  25303. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25304. * If the mesh has no geometry, it is simply returned as it is.
  25305. * @param kind defines vertex data kind:
  25306. * * VertexBuffer.PositionKind
  25307. * * VertexBuffer.UVKind
  25308. * * VertexBuffer.UV2Kind
  25309. * * VertexBuffer.UV3Kind
  25310. * * VertexBuffer.UV4Kind
  25311. * * VertexBuffer.UV5Kind
  25312. * * VertexBuffer.UV6Kind
  25313. * * VertexBuffer.ColorKind
  25314. * * VertexBuffer.MatricesIndicesKind
  25315. * * VertexBuffer.MatricesIndicesExtraKind
  25316. * * VertexBuffer.MatricesWeightsKind
  25317. * * VertexBuffer.MatricesWeightsExtraKind
  25318. * @param data defines the data source
  25319. * @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
  25320. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25321. * @returns the current mesh
  25322. */
  25323. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25324. /**
  25325. * Sets the mesh indices,
  25326. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25327. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25328. * @param totalVertices Defines the total number of vertices
  25329. * @returns the current mesh
  25330. */
  25331. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25332. /**
  25333. * Gets a boolean indicating if specific vertex data is present
  25334. * @param kind defines the vertex data kind to use
  25335. * @returns true is data kind is present
  25336. */
  25337. isVerticesDataPresent(kind: string): boolean;
  25338. /**
  25339. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25340. * @returns a BoundingInfo
  25341. */
  25342. getBoundingInfo(): BoundingInfo;
  25343. /**
  25344. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25345. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25346. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25347. * @returns the current mesh
  25348. */
  25349. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25350. /**
  25351. * Overwrite the current bounding info
  25352. * @param boundingInfo defines the new bounding info
  25353. * @returns the current mesh
  25354. */
  25355. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25356. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25357. readonly useBones: boolean;
  25358. /** @hidden */
  25359. _preActivate(): void;
  25360. /** @hidden */
  25361. _preActivateForIntermediateRendering(renderId: number): void;
  25362. /** @hidden */
  25363. _activate(renderId: number): boolean;
  25364. /** @hidden */
  25365. _freeze(): void;
  25366. /** @hidden */
  25367. _unFreeze(): void;
  25368. /**
  25369. * Gets the current world matrix
  25370. * @returns a Matrix
  25371. */
  25372. getWorldMatrix(): Matrix;
  25373. /** @hidden */
  25374. _getWorldMatrixDeterminant(): number;
  25375. /**
  25376. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25377. */
  25378. readonly isAnInstance: boolean;
  25379. /**
  25380. * Perform relative position change from the point of view of behind the front of the mesh.
  25381. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25382. * Supports definition of mesh facing forward or backward
  25383. * @param amountRight defines the distance on the right axis
  25384. * @param amountUp defines the distance on the up axis
  25385. * @param amountForward defines the distance on the forward axis
  25386. * @returns the current mesh
  25387. */
  25388. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25389. /**
  25390. * Calculate relative position change from the point of view of behind the front of the mesh.
  25391. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25392. * Supports definition of mesh facing forward or backward
  25393. * @param amountRight defines the distance on the right axis
  25394. * @param amountUp defines the distance on the up axis
  25395. * @param amountForward defines the distance on the forward axis
  25396. * @returns the new displacement vector
  25397. */
  25398. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25399. /**
  25400. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25401. * Supports definition of mesh facing forward or backward
  25402. * @param flipBack defines the flip
  25403. * @param twirlClockwise defines the twirl
  25404. * @param tiltRight defines the tilt
  25405. * @returns the current mesh
  25406. */
  25407. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25408. /**
  25409. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25410. * Supports definition of mesh facing forward or backward.
  25411. * @param flipBack defines the flip
  25412. * @param twirlClockwise defines the twirl
  25413. * @param tiltRight defines the tilt
  25414. * @returns the new rotation vector
  25415. */
  25416. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25417. /**
  25418. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25419. * This means the mesh underlying bounding box and sphere are recomputed.
  25420. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25421. * @returns the current mesh
  25422. */
  25423. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25424. /** @hidden */
  25425. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25426. /** @hidden */
  25427. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25428. /** @hidden */
  25429. _updateBoundingInfo(): AbstractMesh;
  25430. /** @hidden */
  25431. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25432. /** @hidden */
  25433. protected _afterComputeWorldMatrix(): void;
  25434. /** @hidden */
  25435. readonly _effectiveMesh: AbstractMesh;
  25436. /**
  25437. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25438. * A mesh is in the frustum if its bounding box intersects the frustum
  25439. * @param frustumPlanes defines the frustum to test
  25440. * @returns true if the mesh is in the frustum planes
  25441. */
  25442. isInFrustum(frustumPlanes: Plane[]): boolean;
  25443. /**
  25444. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25445. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25446. * @param frustumPlanes defines the frustum to test
  25447. * @returns true if the mesh is completely in the frustum planes
  25448. */
  25449. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25450. /**
  25451. * True if the mesh intersects another mesh or a SolidParticle object
  25452. * @param mesh defines a target mesh or SolidParticle to test
  25453. * @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)
  25454. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25455. * @returns true if there is an intersection
  25456. */
  25457. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25458. /**
  25459. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25460. * @param point defines the point to test
  25461. * @returns true if there is an intersection
  25462. */
  25463. intersectsPoint(point: Vector3): boolean;
  25464. /**
  25465. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25466. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25467. */
  25468. checkCollisions: boolean;
  25469. /**
  25470. * Gets Collider object used to compute collisions (not physics)
  25471. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25472. */
  25473. readonly collider: Nullable<Collider>;
  25474. /**
  25475. * Move the mesh using collision engine
  25476. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25477. * @param displacement defines the requested displacement vector
  25478. * @returns the current mesh
  25479. */
  25480. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25481. private _onCollisionPositionChange;
  25482. /** @hidden */
  25483. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25484. /** @hidden */
  25485. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25486. /** @hidden */
  25487. _checkCollision(collider: Collider): AbstractMesh;
  25488. /** @hidden */
  25489. _generatePointsArray(): boolean;
  25490. /**
  25491. * Checks if the passed Ray intersects with the mesh
  25492. * @param ray defines the ray to use
  25493. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25494. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25495. * @returns the picking info
  25496. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25497. */
  25498. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25499. /**
  25500. * Clones the current mesh
  25501. * @param name defines the mesh name
  25502. * @param newParent defines the new mesh parent
  25503. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25504. * @returns the new mesh
  25505. */
  25506. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25507. /**
  25508. * Disposes all the submeshes of the current meshnp
  25509. * @returns the current mesh
  25510. */
  25511. releaseSubMeshes(): AbstractMesh;
  25512. /**
  25513. * Releases resources associated with this abstract mesh.
  25514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25516. */
  25517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25518. /**
  25519. * Adds the passed mesh as a child to the current mesh
  25520. * @param mesh defines the child mesh
  25521. * @returns the current mesh
  25522. */
  25523. addChild(mesh: AbstractMesh): AbstractMesh;
  25524. /**
  25525. * Removes the passed mesh from the current mesh children list
  25526. * @param mesh defines the child mesh
  25527. * @returns the current mesh
  25528. */
  25529. removeChild(mesh: AbstractMesh): AbstractMesh;
  25530. /** @hidden */
  25531. private _initFacetData;
  25532. /**
  25533. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25534. * This method can be called within the render loop.
  25535. * 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
  25536. * @returns the current mesh
  25537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25538. */
  25539. updateFacetData(): AbstractMesh;
  25540. /**
  25541. * Returns the facetLocalNormals array.
  25542. * The normals are expressed in the mesh local spac
  25543. * @returns an array of Vector3
  25544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25545. */
  25546. getFacetLocalNormals(): Vector3[];
  25547. /**
  25548. * Returns the facetLocalPositions array.
  25549. * The facet positions are expressed in the mesh local space
  25550. * @returns an array of Vector3
  25551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25552. */
  25553. getFacetLocalPositions(): Vector3[];
  25554. /**
  25555. * Returns the facetLocalPartioning array
  25556. * @returns an array of array of numbers
  25557. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25558. */
  25559. getFacetLocalPartitioning(): number[][];
  25560. /**
  25561. * Returns the i-th facet position in the world system.
  25562. * This method allocates a new Vector3 per call
  25563. * @param i defines the facet index
  25564. * @returns a new Vector3
  25565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25566. */
  25567. getFacetPosition(i: number): Vector3;
  25568. /**
  25569. * Sets the reference Vector3 with the i-th facet position in the world system
  25570. * @param i defines the facet index
  25571. * @param ref defines the target vector
  25572. * @returns the current mesh
  25573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25574. */
  25575. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25576. /**
  25577. * Returns the i-th facet normal in the world system.
  25578. * This method allocates a new Vector3 per call
  25579. * @param i defines the facet index
  25580. * @returns a new Vector3
  25581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25582. */
  25583. getFacetNormal(i: number): Vector3;
  25584. /**
  25585. * Sets the reference Vector3 with the i-th facet normal in the world system
  25586. * @param i defines the facet index
  25587. * @param ref defines the target vector
  25588. * @returns the current mesh
  25589. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25590. */
  25591. getFacetNormalToRef(i: number, ref: Vector3): this;
  25592. /**
  25593. * 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)
  25594. * @param x defines x coordinate
  25595. * @param y defines y coordinate
  25596. * @param z defines z coordinate
  25597. * @returns the array of facet indexes
  25598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25599. */
  25600. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25601. /**
  25602. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25603. * @param projected sets as the (x,y,z) world projection on the facet
  25604. * @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
  25605. * @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
  25606. * @param x defines x coordinate
  25607. * @param y defines y coordinate
  25608. * @param z defines z coordinate
  25609. * @returns the face index if found (or null instead)
  25610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25611. */
  25612. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25613. /**
  25614. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25615. * @param projected sets as the (x,y,z) local projection on the facet
  25616. * @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
  25617. * @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
  25618. * @param x defines x coordinate
  25619. * @param y defines y coordinate
  25620. * @param z defines z coordinate
  25621. * @returns the face index if found (or null instead)
  25622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25623. */
  25624. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25625. /**
  25626. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25627. * @returns the parameters
  25628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25629. */
  25630. getFacetDataParameters(): any;
  25631. /**
  25632. * Disables the feature FacetData and frees the related memory
  25633. * @returns the current mesh
  25634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25635. */
  25636. disableFacetData(): AbstractMesh;
  25637. /**
  25638. * Updates the AbstractMesh indices array
  25639. * @param indices defines the data source
  25640. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25641. * @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)
  25642. * @returns the current mesh
  25643. */
  25644. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25645. /**
  25646. * Creates new normals data for the mesh
  25647. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25648. * @returns the current mesh
  25649. */
  25650. createNormals(updatable: boolean): AbstractMesh;
  25651. /**
  25652. * Align the mesh with a normal
  25653. * @param normal defines the normal to use
  25654. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25655. * @returns the current mesh
  25656. */
  25657. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25658. /** @hidden */
  25659. _checkOcclusionQuery(): boolean;
  25660. }
  25661. }
  25662. declare module "babylonjs/Actions/actionEvent" {
  25663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25664. import { Nullable } from "babylonjs/types";
  25665. import { Sprite } from "babylonjs/Sprites/sprite";
  25666. import { Scene } from "babylonjs/scene";
  25667. import { Vector2 } from "babylonjs/Maths/math";
  25668. /**
  25669. * Interface used to define ActionEvent
  25670. */
  25671. export interface IActionEvent {
  25672. /** The mesh or sprite that triggered the action */
  25673. source: any;
  25674. /** The X mouse cursor position at the time of the event */
  25675. pointerX: number;
  25676. /** The Y mouse cursor position at the time of the event */
  25677. pointerY: number;
  25678. /** The mesh that is currently pointed at (can be null) */
  25679. meshUnderPointer: Nullable<AbstractMesh>;
  25680. /** the original (browser) event that triggered the ActionEvent */
  25681. sourceEvent?: any;
  25682. /** additional data for the event */
  25683. additionalData?: any;
  25684. }
  25685. /**
  25686. * ActionEvent is the event being sent when an action is triggered.
  25687. */
  25688. export class ActionEvent implements IActionEvent {
  25689. /** The mesh or sprite that triggered the action */
  25690. source: any;
  25691. /** The X mouse cursor position at the time of the event */
  25692. pointerX: number;
  25693. /** The Y mouse cursor position at the time of the event */
  25694. pointerY: number;
  25695. /** The mesh that is currently pointed at (can be null) */
  25696. meshUnderPointer: Nullable<AbstractMesh>;
  25697. /** the original (browser) event that triggered the ActionEvent */
  25698. sourceEvent?: any;
  25699. /** additional data for the event */
  25700. additionalData?: any;
  25701. /**
  25702. * Creates a new ActionEvent
  25703. * @param source The mesh or sprite that triggered the action
  25704. * @param pointerX The X mouse cursor position at the time of the event
  25705. * @param pointerY The Y mouse cursor position at the time of the event
  25706. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25707. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25708. * @param additionalData additional data for the event
  25709. */
  25710. constructor(
  25711. /** The mesh or sprite that triggered the action */
  25712. source: any,
  25713. /** The X mouse cursor position at the time of the event */
  25714. pointerX: number,
  25715. /** The Y mouse cursor position at the time of the event */
  25716. pointerY: number,
  25717. /** The mesh that is currently pointed at (can be null) */
  25718. meshUnderPointer: Nullable<AbstractMesh>,
  25719. /** the original (browser) event that triggered the ActionEvent */
  25720. sourceEvent?: any,
  25721. /** additional data for the event */
  25722. additionalData?: any);
  25723. /**
  25724. * Helper function to auto-create an ActionEvent from a source mesh.
  25725. * @param source The source mesh that triggered the event
  25726. * @param evt The original (browser) event
  25727. * @param additionalData additional data for the event
  25728. * @returns the new ActionEvent
  25729. */
  25730. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25731. /**
  25732. * Helper function to auto-create an ActionEvent from a source sprite
  25733. * @param source The source sprite that triggered the event
  25734. * @param scene Scene associated with the sprite
  25735. * @param evt The original (browser) event
  25736. * @param additionalData additional data for the event
  25737. * @returns the new ActionEvent
  25738. */
  25739. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25740. /**
  25741. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25742. * @param scene the scene where the event occurred
  25743. * @param evt The original (browser) event
  25744. * @returns the new ActionEvent
  25745. */
  25746. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25747. /**
  25748. * Helper function to auto-create an ActionEvent from a primitive
  25749. * @param prim defines the target primitive
  25750. * @param pointerPos defines the pointer position
  25751. * @param evt The original (browser) event
  25752. * @param additionalData additional data for the event
  25753. * @returns the new ActionEvent
  25754. */
  25755. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25756. }
  25757. }
  25758. declare module "babylonjs/Actions/abstractActionManager" {
  25759. import { IDisposable } from "babylonjs/scene";
  25760. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25761. import { IAction } from "babylonjs/Actions/action";
  25762. import { Nullable } from "babylonjs/types";
  25763. /**
  25764. * Abstract class used to decouple action Manager from scene and meshes.
  25765. * Do not instantiate.
  25766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25767. */
  25768. export abstract class AbstractActionManager implements IDisposable {
  25769. /** Gets the list of active triggers */
  25770. static Triggers: {
  25771. [key: string]: number;
  25772. };
  25773. /** Gets the cursor to use when hovering items */
  25774. hoverCursor: string;
  25775. /** Gets the list of actions */
  25776. actions: IAction[];
  25777. /**
  25778. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25779. */
  25780. isRecursive: boolean;
  25781. /**
  25782. * Releases all associated resources
  25783. */
  25784. abstract dispose(): void;
  25785. /**
  25786. * Does this action manager has pointer triggers
  25787. */
  25788. abstract readonly hasPointerTriggers: boolean;
  25789. /**
  25790. * Does this action manager has pick triggers
  25791. */
  25792. abstract readonly hasPickTriggers: boolean;
  25793. /**
  25794. * Process a specific trigger
  25795. * @param trigger defines the trigger to process
  25796. * @param evt defines the event details to be processed
  25797. */
  25798. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25799. /**
  25800. * Does this action manager handles actions of any of the given triggers
  25801. * @param triggers defines the triggers to be tested
  25802. * @return a boolean indicating whether one (or more) of the triggers is handled
  25803. */
  25804. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25805. /**
  25806. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25807. * speed.
  25808. * @param triggerA defines the trigger to be tested
  25809. * @param triggerB defines the trigger to be tested
  25810. * @return a boolean indicating whether one (or more) of the triggers is handled
  25811. */
  25812. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25813. /**
  25814. * Does this action manager handles actions of a given trigger
  25815. * @param trigger defines the trigger to be tested
  25816. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25817. * @return whether the trigger is handled
  25818. */
  25819. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25820. /**
  25821. * Serialize this manager to a JSON object
  25822. * @param name defines the property name to store this manager
  25823. * @returns a JSON representation of this manager
  25824. */
  25825. abstract serialize(name: string): any;
  25826. /**
  25827. * Registers an action to this action manager
  25828. * @param action defines the action to be registered
  25829. * @return the action amended (prepared) after registration
  25830. */
  25831. abstract registerAction(action: IAction): Nullable<IAction>;
  25832. /**
  25833. * Unregisters an action to this action manager
  25834. * @param action defines the action to be unregistered
  25835. * @return a boolean indicating whether the action has been unregistered
  25836. */
  25837. abstract unregisterAction(action: IAction): Boolean;
  25838. /**
  25839. * Does exist one action manager with at least one trigger
  25840. **/
  25841. static readonly HasTriggers: boolean;
  25842. /**
  25843. * Does exist one action manager with at least one pick trigger
  25844. **/
  25845. static readonly HasPickTriggers: boolean;
  25846. /**
  25847. * Does exist one action manager that handles actions of a given trigger
  25848. * @param trigger defines the trigger to be tested
  25849. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25850. **/
  25851. static HasSpecificTrigger(trigger: number): boolean;
  25852. }
  25853. }
  25854. declare module "babylonjs/node" {
  25855. import { Scene } from "babylonjs/scene";
  25856. import { Nullable } from "babylonjs/types";
  25857. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25858. import { Engine } from "babylonjs/Engines/engine";
  25859. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25860. import { Observable } from "babylonjs/Misc/observable";
  25861. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25862. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25863. import { Animatable } from "babylonjs/Animations/animatable";
  25864. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25865. import { Animation } from "babylonjs/Animations/animation";
  25866. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25868. /**
  25869. * Defines how a node can be built from a string name.
  25870. */
  25871. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25872. /**
  25873. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25874. */
  25875. export class Node implements IBehaviorAware<Node> {
  25876. /** @hidden */
  25877. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25878. private static _NodeConstructors;
  25879. /**
  25880. * Add a new node constructor
  25881. * @param type defines the type name of the node to construct
  25882. * @param constructorFunc defines the constructor function
  25883. */
  25884. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25885. /**
  25886. * Returns a node constructor based on type name
  25887. * @param type defines the type name
  25888. * @param name defines the new node name
  25889. * @param scene defines the hosting scene
  25890. * @param options defines optional options to transmit to constructors
  25891. * @returns the new constructor or null
  25892. */
  25893. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25894. /**
  25895. * Gets or sets the name of the node
  25896. */
  25897. name: string;
  25898. /**
  25899. * Gets or sets the id of the node
  25900. */
  25901. id: string;
  25902. /**
  25903. * Gets or sets the unique id of the node
  25904. */
  25905. uniqueId: number;
  25906. /**
  25907. * Gets or sets a string used to store user defined state for the node
  25908. */
  25909. state: string;
  25910. /**
  25911. * Gets or sets an object used to store user defined information for the node
  25912. */
  25913. metadata: any;
  25914. /**
  25915. * For internal use only. Please do not use.
  25916. */
  25917. reservedDataStore: any;
  25918. /**
  25919. * List of inspectable custom properties (used by the Inspector)
  25920. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25921. */
  25922. inspectableCustomProperties: IInspectable[];
  25923. /**
  25924. * Gets or sets a boolean used to define if the node must be serialized
  25925. */
  25926. doNotSerialize: boolean;
  25927. /** @hidden */
  25928. _isDisposed: boolean;
  25929. /**
  25930. * Gets a list of Animations associated with the node
  25931. */
  25932. animations: import("babylonjs/Animations/animation").Animation[];
  25933. protected _ranges: {
  25934. [name: string]: Nullable<AnimationRange>;
  25935. };
  25936. /**
  25937. * Callback raised when the node is ready to be used
  25938. */
  25939. onReady: Nullable<(node: Node) => void>;
  25940. private _isEnabled;
  25941. private _isParentEnabled;
  25942. private _isReady;
  25943. /** @hidden */
  25944. _currentRenderId: number;
  25945. private _parentUpdateId;
  25946. /** @hidden */
  25947. _childUpdateId: number;
  25948. /** @hidden */
  25949. _waitingParentId: Nullable<string>;
  25950. /** @hidden */
  25951. _scene: Scene;
  25952. /** @hidden */
  25953. _cache: any;
  25954. private _parentNode;
  25955. private _children;
  25956. /** @hidden */
  25957. _worldMatrix: Matrix;
  25958. /** @hidden */
  25959. _worldMatrixDeterminant: number;
  25960. /** @hidden */
  25961. _worldMatrixDeterminantIsDirty: boolean;
  25962. /** @hidden */
  25963. private _sceneRootNodesIndex;
  25964. /**
  25965. * Gets a boolean indicating if the node has been disposed
  25966. * @returns true if the node was disposed
  25967. */
  25968. isDisposed(): boolean;
  25969. /**
  25970. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25971. * @see https://doc.babylonjs.com/how_to/parenting
  25972. */
  25973. parent: Nullable<Node>;
  25974. private addToSceneRootNodes;
  25975. private removeFromSceneRootNodes;
  25976. private _animationPropertiesOverride;
  25977. /**
  25978. * Gets or sets the animation properties override
  25979. */
  25980. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25981. /**
  25982. * Gets a string idenfifying the name of the class
  25983. * @returns "Node" string
  25984. */
  25985. getClassName(): string;
  25986. /** @hidden */
  25987. readonly _isNode: boolean;
  25988. /**
  25989. * An event triggered when the mesh is disposed
  25990. */
  25991. onDisposeObservable: Observable<Node>;
  25992. private _onDisposeObserver;
  25993. /**
  25994. * Sets a callback that will be raised when the node will be disposed
  25995. */
  25996. onDispose: () => void;
  25997. /**
  25998. * Creates a new Node
  25999. * @param name the name and id to be given to this node
  26000. * @param scene the scene this node will be added to
  26001. * @param addToRootNodes the node will be added to scene.rootNodes
  26002. */
  26003. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26004. /**
  26005. * Gets the scene of the node
  26006. * @returns a scene
  26007. */
  26008. getScene(): Scene;
  26009. /**
  26010. * Gets the engine of the node
  26011. * @returns a Engine
  26012. */
  26013. getEngine(): Engine;
  26014. private _behaviors;
  26015. /**
  26016. * Attach a behavior to the node
  26017. * @see http://doc.babylonjs.com/features/behaviour
  26018. * @param behavior defines the behavior to attach
  26019. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26020. * @returns the current Node
  26021. */
  26022. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26023. /**
  26024. * Remove an attached behavior
  26025. * @see http://doc.babylonjs.com/features/behaviour
  26026. * @param behavior defines the behavior to attach
  26027. * @returns the current Node
  26028. */
  26029. removeBehavior(behavior: Behavior<Node>): Node;
  26030. /**
  26031. * Gets the list of attached behaviors
  26032. * @see http://doc.babylonjs.com/features/behaviour
  26033. */
  26034. readonly behaviors: Behavior<Node>[];
  26035. /**
  26036. * Gets an attached behavior by name
  26037. * @param name defines the name of the behavior to look for
  26038. * @see http://doc.babylonjs.com/features/behaviour
  26039. * @returns null if behavior was not found else the requested behavior
  26040. */
  26041. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26042. /**
  26043. * Returns the latest update of the World matrix
  26044. * @returns a Matrix
  26045. */
  26046. getWorldMatrix(): Matrix;
  26047. /** @hidden */
  26048. _getWorldMatrixDeterminant(): number;
  26049. /**
  26050. * Returns directly the latest state of the mesh World matrix.
  26051. * A Matrix is returned.
  26052. */
  26053. readonly worldMatrixFromCache: Matrix;
  26054. /** @hidden */
  26055. _initCache(): void;
  26056. /** @hidden */
  26057. updateCache(force?: boolean): void;
  26058. /** @hidden */
  26059. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26060. /** @hidden */
  26061. _updateCache(ignoreParentClass?: boolean): void;
  26062. /** @hidden */
  26063. _isSynchronized(): boolean;
  26064. /** @hidden */
  26065. _markSyncedWithParent(): void;
  26066. /** @hidden */
  26067. isSynchronizedWithParent(): boolean;
  26068. /** @hidden */
  26069. isSynchronized(): boolean;
  26070. /**
  26071. * Is this node ready to be used/rendered
  26072. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26073. * @return true if the node is ready
  26074. */
  26075. isReady(completeCheck?: boolean): boolean;
  26076. /**
  26077. * Is this node enabled?
  26078. * 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
  26079. * @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
  26080. * @return whether this node (and its parent) is enabled
  26081. */
  26082. isEnabled(checkAncestors?: boolean): boolean;
  26083. /** @hidden */
  26084. protected _syncParentEnabledState(): void;
  26085. /**
  26086. * Set the enabled state of this node
  26087. * @param value defines the new enabled state
  26088. */
  26089. setEnabled(value: boolean): void;
  26090. /**
  26091. * Is this node a descendant of the given node?
  26092. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26093. * @param ancestor defines the parent node to inspect
  26094. * @returns a boolean indicating if this node is a descendant of the given node
  26095. */
  26096. isDescendantOf(ancestor: Node): boolean;
  26097. /** @hidden */
  26098. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26099. /**
  26100. * Will return all nodes that have this node as ascendant
  26101. * @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
  26102. * @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
  26103. * @return all children nodes of all types
  26104. */
  26105. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26106. /**
  26107. * Get all child-meshes of this node
  26108. * @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)
  26109. * @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
  26110. * @returns an array of AbstractMesh
  26111. */
  26112. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26113. /**
  26114. * Get all direct children of this node
  26115. * @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
  26116. * @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)
  26117. * @returns an array of Node
  26118. */
  26119. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26120. /** @hidden */
  26121. _setReady(state: boolean): void;
  26122. /**
  26123. * Get an animation by name
  26124. * @param name defines the name of the animation to look for
  26125. * @returns null if not found else the requested animation
  26126. */
  26127. getAnimationByName(name: string): Nullable<Animation>;
  26128. /**
  26129. * Creates an animation range for this node
  26130. * @param name defines the name of the range
  26131. * @param from defines the starting key
  26132. * @param to defines the end key
  26133. */
  26134. createAnimationRange(name: string, from: number, to: number): void;
  26135. /**
  26136. * Delete a specific animation range
  26137. * @param name defines the name of the range to delete
  26138. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26139. */
  26140. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26141. /**
  26142. * Get an animation range by name
  26143. * @param name defines the name of the animation range to look for
  26144. * @returns null if not found else the requested animation range
  26145. */
  26146. getAnimationRange(name: string): Nullable<AnimationRange>;
  26147. /**
  26148. * Gets the list of all animation ranges defined on this node
  26149. * @returns an array
  26150. */
  26151. getAnimationRanges(): Nullable<AnimationRange>[];
  26152. /**
  26153. * Will start the animation sequence
  26154. * @param name defines the range frames for animation sequence
  26155. * @param loop defines if the animation should loop (false by default)
  26156. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26157. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26158. * @returns the object created for this animation. If range does not exist, it will return null
  26159. */
  26160. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26161. /**
  26162. * Serialize animation ranges into a JSON compatible object
  26163. * @returns serialization object
  26164. */
  26165. serializeAnimationRanges(): any;
  26166. /**
  26167. * Computes the world matrix of the node
  26168. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26169. * @returns the world matrix
  26170. */
  26171. computeWorldMatrix(force?: boolean): Matrix;
  26172. /**
  26173. * Releases resources associated with this node.
  26174. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26175. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26176. */
  26177. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26178. /**
  26179. * Parse animation range data from a serialization object and store them into a given node
  26180. * @param node defines where to store the animation ranges
  26181. * @param parsedNode defines the serialization object to read data from
  26182. * @param scene defines the hosting scene
  26183. */
  26184. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26185. /**
  26186. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26187. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26188. * @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
  26189. * @returns the new bounding vectors
  26190. */
  26191. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26192. min: Vector3;
  26193. max: Vector3;
  26194. };
  26195. }
  26196. }
  26197. declare module "babylonjs/Animations/animation" {
  26198. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26199. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26200. import { Nullable } from "babylonjs/types";
  26201. import { Scene } from "babylonjs/scene";
  26202. import { IAnimatable } from "babylonjs/Misc/tools";
  26203. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26204. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26205. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26206. import { Node } from "babylonjs/node";
  26207. import { Animatable } from "babylonjs/Animations/animatable";
  26208. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26209. /**
  26210. * @hidden
  26211. */
  26212. export class _IAnimationState {
  26213. key: number;
  26214. repeatCount: number;
  26215. workValue?: any;
  26216. loopMode?: number;
  26217. offsetValue?: any;
  26218. highLimitValue?: any;
  26219. }
  26220. /**
  26221. * Class used to store any kind of animation
  26222. */
  26223. export class Animation {
  26224. /**Name of the animation */
  26225. name: string;
  26226. /**Property to animate */
  26227. targetProperty: string;
  26228. /**The frames per second of the animation */
  26229. framePerSecond: number;
  26230. /**The data type of the animation */
  26231. dataType: number;
  26232. /**The loop mode of the animation */
  26233. loopMode?: number | undefined;
  26234. /**Specifies if blending should be enabled */
  26235. enableBlending?: boolean | undefined;
  26236. /**
  26237. * Use matrix interpolation instead of using direct key value when animating matrices
  26238. */
  26239. static AllowMatricesInterpolation: boolean;
  26240. /**
  26241. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26242. */
  26243. static AllowMatrixDecomposeForInterpolation: boolean;
  26244. /**
  26245. * Stores the key frames of the animation
  26246. */
  26247. private _keys;
  26248. /**
  26249. * Stores the easing function of the animation
  26250. */
  26251. private _easingFunction;
  26252. /**
  26253. * @hidden Internal use only
  26254. */
  26255. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26256. /**
  26257. * The set of event that will be linked to this animation
  26258. */
  26259. private _events;
  26260. /**
  26261. * Stores an array of target property paths
  26262. */
  26263. targetPropertyPath: string[];
  26264. /**
  26265. * Stores the blending speed of the animation
  26266. */
  26267. blendingSpeed: number;
  26268. /**
  26269. * Stores the animation ranges for the animation
  26270. */
  26271. private _ranges;
  26272. /**
  26273. * @hidden Internal use
  26274. */
  26275. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26276. /**
  26277. * Sets up an animation
  26278. * @param property The property to animate
  26279. * @param animationType The animation type to apply
  26280. * @param framePerSecond The frames per second of the animation
  26281. * @param easingFunction The easing function used in the animation
  26282. * @returns The created animation
  26283. */
  26284. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26285. /**
  26286. * Create and start an animation on a node
  26287. * @param name defines the name of the global animation that will be run on all nodes
  26288. * @param node defines the root node where the animation will take place
  26289. * @param targetProperty defines property to animate
  26290. * @param framePerSecond defines the number of frame per second yo use
  26291. * @param totalFrame defines the number of frames in total
  26292. * @param from defines the initial value
  26293. * @param to defines the final value
  26294. * @param loopMode defines which loop mode you want to use (off by default)
  26295. * @param easingFunction defines the easing function to use (linear by default)
  26296. * @param onAnimationEnd defines the callback to call when animation end
  26297. * @returns the animatable created for this animation
  26298. */
  26299. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26300. /**
  26301. * Create and start an animation on a node and its descendants
  26302. * @param name defines the name of the global animation that will be run on all nodes
  26303. * @param node defines the root node where the animation will take place
  26304. * @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
  26305. * @param targetProperty defines property to animate
  26306. * @param framePerSecond defines the number of frame per second to use
  26307. * @param totalFrame defines the number of frames in total
  26308. * @param from defines the initial value
  26309. * @param to defines the final value
  26310. * @param loopMode defines which loop mode you want to use (off by default)
  26311. * @param easingFunction defines the easing function to use (linear by default)
  26312. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26313. * @returns the list of animatables created for all nodes
  26314. * @example https://www.babylonjs-playground.com/#MH0VLI
  26315. */
  26316. 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[]>;
  26317. /**
  26318. * Creates a new animation, merges it with the existing animations and starts it
  26319. * @param name Name of the animation
  26320. * @param node Node which contains the scene that begins the animations
  26321. * @param targetProperty Specifies which property to animate
  26322. * @param framePerSecond The frames per second of the animation
  26323. * @param totalFrame The total number of frames
  26324. * @param from The frame at the beginning of the animation
  26325. * @param to The frame at the end of the animation
  26326. * @param loopMode Specifies the loop mode of the animation
  26327. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26328. * @param onAnimationEnd Callback to run once the animation is complete
  26329. * @returns Nullable animation
  26330. */
  26331. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26332. /**
  26333. * Transition property of an host to the target Value
  26334. * @param property The property to transition
  26335. * @param targetValue The target Value of the property
  26336. * @param host The object where the property to animate belongs
  26337. * @param scene Scene used to run the animation
  26338. * @param frameRate Framerate (in frame/s) to use
  26339. * @param transition The transition type we want to use
  26340. * @param duration The duration of the animation, in milliseconds
  26341. * @param onAnimationEnd Callback trigger at the end of the animation
  26342. * @returns Nullable animation
  26343. */
  26344. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26345. /**
  26346. * Return the array of runtime animations currently using this animation
  26347. */
  26348. readonly runtimeAnimations: RuntimeAnimation[];
  26349. /**
  26350. * Specifies if any of the runtime animations are currently running
  26351. */
  26352. readonly hasRunningRuntimeAnimations: boolean;
  26353. /**
  26354. * Initializes the animation
  26355. * @param name Name of the animation
  26356. * @param targetProperty Property to animate
  26357. * @param framePerSecond The frames per second of the animation
  26358. * @param dataType The data type of the animation
  26359. * @param loopMode The loop mode of the animation
  26360. * @param enableBlending Specifies if blending should be enabled
  26361. */
  26362. constructor(
  26363. /**Name of the animation */
  26364. name: string,
  26365. /**Property to animate */
  26366. targetProperty: string,
  26367. /**The frames per second of the animation */
  26368. framePerSecond: number,
  26369. /**The data type of the animation */
  26370. dataType: number,
  26371. /**The loop mode of the animation */
  26372. loopMode?: number | undefined,
  26373. /**Specifies if blending should be enabled */
  26374. enableBlending?: boolean | undefined);
  26375. /**
  26376. * Converts the animation to a string
  26377. * @param fullDetails support for multiple levels of logging within scene loading
  26378. * @returns String form of the animation
  26379. */
  26380. toString(fullDetails?: boolean): string;
  26381. /**
  26382. * Add an event to this animation
  26383. * @param event Event to add
  26384. */
  26385. addEvent(event: AnimationEvent): void;
  26386. /**
  26387. * Remove all events found at the given frame
  26388. * @param frame The frame to remove events from
  26389. */
  26390. removeEvents(frame: number): void;
  26391. /**
  26392. * Retrieves all the events from the animation
  26393. * @returns Events from the animation
  26394. */
  26395. getEvents(): AnimationEvent[];
  26396. /**
  26397. * Creates an animation range
  26398. * @param name Name of the animation range
  26399. * @param from Starting frame of the animation range
  26400. * @param to Ending frame of the animation
  26401. */
  26402. createRange(name: string, from: number, to: number): void;
  26403. /**
  26404. * Deletes an animation range by name
  26405. * @param name Name of the animation range to delete
  26406. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26407. */
  26408. deleteRange(name: string, deleteFrames?: boolean): void;
  26409. /**
  26410. * Gets the animation range by name, or null if not defined
  26411. * @param name Name of the animation range
  26412. * @returns Nullable animation range
  26413. */
  26414. getRange(name: string): Nullable<AnimationRange>;
  26415. /**
  26416. * Gets the key frames from the animation
  26417. * @returns The key frames of the animation
  26418. */
  26419. getKeys(): Array<IAnimationKey>;
  26420. /**
  26421. * Gets the highest frame rate of the animation
  26422. * @returns Highest frame rate of the animation
  26423. */
  26424. getHighestFrame(): number;
  26425. /**
  26426. * Gets the easing function of the animation
  26427. * @returns Easing function of the animation
  26428. */
  26429. getEasingFunction(): IEasingFunction;
  26430. /**
  26431. * Sets the easing function of the animation
  26432. * @param easingFunction A custom mathematical formula for animation
  26433. */
  26434. setEasingFunction(easingFunction: EasingFunction): void;
  26435. /**
  26436. * Interpolates a scalar linearly
  26437. * @param startValue Start value of the animation curve
  26438. * @param endValue End value of the animation curve
  26439. * @param gradient Scalar amount to interpolate
  26440. * @returns Interpolated scalar value
  26441. */
  26442. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26443. /**
  26444. * Interpolates a scalar cubically
  26445. * @param startValue Start value of the animation curve
  26446. * @param outTangent End tangent of the animation
  26447. * @param endValue End value of the animation curve
  26448. * @param inTangent Start tangent of the animation curve
  26449. * @param gradient Scalar amount to interpolate
  26450. * @returns Interpolated scalar value
  26451. */
  26452. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26453. /**
  26454. * Interpolates a quaternion using a spherical linear interpolation
  26455. * @param startValue Start value of the animation curve
  26456. * @param endValue End value of the animation curve
  26457. * @param gradient Scalar amount to interpolate
  26458. * @returns Interpolated quaternion value
  26459. */
  26460. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26461. /**
  26462. * Interpolates a quaternion cubically
  26463. * @param startValue Start value of the animation curve
  26464. * @param outTangent End tangent of the animation curve
  26465. * @param endValue End value of the animation curve
  26466. * @param inTangent Start tangent of the animation curve
  26467. * @param gradient Scalar amount to interpolate
  26468. * @returns Interpolated quaternion value
  26469. */
  26470. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26471. /**
  26472. * Interpolates a Vector3 linearl
  26473. * @param startValue Start value of the animation curve
  26474. * @param endValue End value of the animation curve
  26475. * @param gradient Scalar amount to interpolate
  26476. * @returns Interpolated scalar value
  26477. */
  26478. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26479. /**
  26480. * Interpolates a Vector3 cubically
  26481. * @param startValue Start value of the animation curve
  26482. * @param outTangent End tangent of the animation
  26483. * @param endValue End value of the animation curve
  26484. * @param inTangent Start tangent of the animation curve
  26485. * @param gradient Scalar amount to interpolate
  26486. * @returns InterpolatedVector3 value
  26487. */
  26488. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26489. /**
  26490. * Interpolates a Vector2 linearly
  26491. * @param startValue Start value of the animation curve
  26492. * @param endValue End value of the animation curve
  26493. * @param gradient Scalar amount to interpolate
  26494. * @returns Interpolated Vector2 value
  26495. */
  26496. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26497. /**
  26498. * Interpolates a Vector2 cubically
  26499. * @param startValue Start value of the animation curve
  26500. * @param outTangent End tangent of the animation
  26501. * @param endValue End value of the animation curve
  26502. * @param inTangent Start tangent of the animation curve
  26503. * @param gradient Scalar amount to interpolate
  26504. * @returns Interpolated Vector2 value
  26505. */
  26506. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26507. /**
  26508. * Interpolates a size linearly
  26509. * @param startValue Start value of the animation curve
  26510. * @param endValue End value of the animation curve
  26511. * @param gradient Scalar amount to interpolate
  26512. * @returns Interpolated Size value
  26513. */
  26514. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26515. /**
  26516. * Interpolates a Color3 linearly
  26517. * @param startValue Start value of the animation curve
  26518. * @param endValue End value of the animation curve
  26519. * @param gradient Scalar amount to interpolate
  26520. * @returns Interpolated Color3 value
  26521. */
  26522. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26523. /**
  26524. * @hidden Internal use only
  26525. */
  26526. _getKeyValue(value: any): any;
  26527. /**
  26528. * @hidden Internal use only
  26529. */
  26530. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26531. /**
  26532. * Defines the function to use to interpolate matrices
  26533. * @param startValue defines the start matrix
  26534. * @param endValue defines the end matrix
  26535. * @param gradient defines the gradient between both matrices
  26536. * @param result defines an optional target matrix where to store the interpolation
  26537. * @returns the interpolated matrix
  26538. */
  26539. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26540. /**
  26541. * Makes a copy of the animation
  26542. * @returns Cloned animation
  26543. */
  26544. clone(): Animation;
  26545. /**
  26546. * Sets the key frames of the animation
  26547. * @param values The animation key frames to set
  26548. */
  26549. setKeys(values: Array<IAnimationKey>): void;
  26550. /**
  26551. * Serializes the animation to an object
  26552. * @returns Serialized object
  26553. */
  26554. serialize(): any;
  26555. /**
  26556. * Float animation type
  26557. */
  26558. private static _ANIMATIONTYPE_FLOAT;
  26559. /**
  26560. * Vector3 animation type
  26561. */
  26562. private static _ANIMATIONTYPE_VECTOR3;
  26563. /**
  26564. * Quaternion animation type
  26565. */
  26566. private static _ANIMATIONTYPE_QUATERNION;
  26567. /**
  26568. * Matrix animation type
  26569. */
  26570. private static _ANIMATIONTYPE_MATRIX;
  26571. /**
  26572. * Color3 animation type
  26573. */
  26574. private static _ANIMATIONTYPE_COLOR3;
  26575. /**
  26576. * Vector2 animation type
  26577. */
  26578. private static _ANIMATIONTYPE_VECTOR2;
  26579. /**
  26580. * Size animation type
  26581. */
  26582. private static _ANIMATIONTYPE_SIZE;
  26583. /**
  26584. * Relative Loop Mode
  26585. */
  26586. private static _ANIMATIONLOOPMODE_RELATIVE;
  26587. /**
  26588. * Cycle Loop Mode
  26589. */
  26590. private static _ANIMATIONLOOPMODE_CYCLE;
  26591. /**
  26592. * Constant Loop Mode
  26593. */
  26594. private static _ANIMATIONLOOPMODE_CONSTANT;
  26595. /**
  26596. * Get the float animation type
  26597. */
  26598. static readonly ANIMATIONTYPE_FLOAT: number;
  26599. /**
  26600. * Get the Vector3 animation type
  26601. */
  26602. static readonly ANIMATIONTYPE_VECTOR3: number;
  26603. /**
  26604. * Get the Vector2 animation type
  26605. */
  26606. static readonly ANIMATIONTYPE_VECTOR2: number;
  26607. /**
  26608. * Get the Size animation type
  26609. */
  26610. static readonly ANIMATIONTYPE_SIZE: number;
  26611. /**
  26612. * Get the Quaternion animation type
  26613. */
  26614. static readonly ANIMATIONTYPE_QUATERNION: number;
  26615. /**
  26616. * Get the Matrix animation type
  26617. */
  26618. static readonly ANIMATIONTYPE_MATRIX: number;
  26619. /**
  26620. * Get the Color3 animation type
  26621. */
  26622. static readonly ANIMATIONTYPE_COLOR3: number;
  26623. /**
  26624. * Get the Relative Loop Mode
  26625. */
  26626. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26627. /**
  26628. * Get the Cycle Loop Mode
  26629. */
  26630. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26631. /**
  26632. * Get the Constant Loop Mode
  26633. */
  26634. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26635. /** @hidden */
  26636. static _UniversalLerp(left: any, right: any, amount: number): any;
  26637. /**
  26638. * Parses an animation object and creates an animation
  26639. * @param parsedAnimation Parsed animation object
  26640. * @returns Animation object
  26641. */
  26642. static Parse(parsedAnimation: any): Animation;
  26643. /**
  26644. * Appends the serialized animations from the source animations
  26645. * @param source Source containing the animations
  26646. * @param destination Target to store the animations
  26647. */
  26648. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26649. }
  26650. }
  26651. declare module "babylonjs/Materials/Textures/baseTexture" {
  26652. import { Observable } from "babylonjs/Misc/observable";
  26653. import { IAnimatable } from "babylonjs/Misc/tools";
  26654. import { Nullable } from "babylonjs/types";
  26655. import { Scene } from "babylonjs/scene";
  26656. import { Matrix, ISize } from "babylonjs/Maths/math";
  26657. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26658. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26659. /**
  26660. * Base class of all the textures in babylon.
  26661. * It groups all the common properties the materials, post process, lights... might need
  26662. * in order to make a correct use of the texture.
  26663. */
  26664. export class BaseTexture implements IAnimatable {
  26665. /**
  26666. * Default anisotropic filtering level for the application.
  26667. * It is set to 4 as a good tradeoff between perf and quality.
  26668. */
  26669. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26670. /**
  26671. * Gets or sets the unique id of the texture
  26672. */
  26673. uniqueId: number;
  26674. /**
  26675. * Define the name of the texture.
  26676. */
  26677. name: string;
  26678. /**
  26679. * Gets or sets an object used to store user defined information.
  26680. */
  26681. metadata: any;
  26682. /**
  26683. * For internal use only. Please do not use.
  26684. */
  26685. reservedDataStore: any;
  26686. private _hasAlpha;
  26687. /**
  26688. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26689. */
  26690. hasAlpha: boolean;
  26691. /**
  26692. * Defines if the alpha value should be determined via the rgb values.
  26693. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26694. */
  26695. getAlphaFromRGB: boolean;
  26696. /**
  26697. * Intensity or strength of the texture.
  26698. * It is commonly used by materials to fine tune the intensity of the texture
  26699. */
  26700. level: number;
  26701. /**
  26702. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26703. * This is part of the texture as textures usually maps to one uv set.
  26704. */
  26705. coordinatesIndex: number;
  26706. private _coordinatesMode;
  26707. /**
  26708. * How a texture is mapped.
  26709. *
  26710. * | Value | Type | Description |
  26711. * | ----- | ----------------------------------- | ----------- |
  26712. * | 0 | EXPLICIT_MODE | |
  26713. * | 1 | SPHERICAL_MODE | |
  26714. * | 2 | PLANAR_MODE | |
  26715. * | 3 | CUBIC_MODE | |
  26716. * | 4 | PROJECTION_MODE | |
  26717. * | 5 | SKYBOX_MODE | |
  26718. * | 6 | INVCUBIC_MODE | |
  26719. * | 7 | EQUIRECTANGULAR_MODE | |
  26720. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26721. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26722. */
  26723. coordinatesMode: number;
  26724. /**
  26725. * | Value | Type | Description |
  26726. * | ----- | ------------------ | ----------- |
  26727. * | 0 | CLAMP_ADDRESSMODE | |
  26728. * | 1 | WRAP_ADDRESSMODE | |
  26729. * | 2 | MIRROR_ADDRESSMODE | |
  26730. */
  26731. wrapU: number;
  26732. /**
  26733. * | Value | Type | Description |
  26734. * | ----- | ------------------ | ----------- |
  26735. * | 0 | CLAMP_ADDRESSMODE | |
  26736. * | 1 | WRAP_ADDRESSMODE | |
  26737. * | 2 | MIRROR_ADDRESSMODE | |
  26738. */
  26739. wrapV: number;
  26740. /**
  26741. * | Value | Type | Description |
  26742. * | ----- | ------------------ | ----------- |
  26743. * | 0 | CLAMP_ADDRESSMODE | |
  26744. * | 1 | WRAP_ADDRESSMODE | |
  26745. * | 2 | MIRROR_ADDRESSMODE | |
  26746. */
  26747. wrapR: number;
  26748. /**
  26749. * With compliant hardware and browser (supporting anisotropic filtering)
  26750. * this defines the level of anisotropic filtering in the texture.
  26751. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26752. */
  26753. anisotropicFilteringLevel: number;
  26754. /**
  26755. * Define if the texture is a cube texture or if false a 2d texture.
  26756. */
  26757. isCube: boolean;
  26758. /**
  26759. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26760. */
  26761. is3D: boolean;
  26762. /**
  26763. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26764. * HDR texture are usually stored in linear space.
  26765. * This only impacts the PBR and Background materials
  26766. */
  26767. gammaSpace: boolean;
  26768. /**
  26769. * Gets whether or not the texture contains RGBD data.
  26770. */
  26771. readonly isRGBD: boolean;
  26772. /**
  26773. * Is Z inverted in the texture (useful in a cube texture).
  26774. */
  26775. invertZ: boolean;
  26776. /**
  26777. * Are mip maps generated for this texture or not.
  26778. */
  26779. readonly noMipmap: boolean;
  26780. /**
  26781. * @hidden
  26782. */
  26783. lodLevelInAlpha: boolean;
  26784. /**
  26785. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26786. */
  26787. lodGenerationOffset: number;
  26788. /**
  26789. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26790. */
  26791. lodGenerationScale: number;
  26792. /**
  26793. * Define if the texture is a render target.
  26794. */
  26795. isRenderTarget: boolean;
  26796. /**
  26797. * Define the unique id of the texture in the scene.
  26798. */
  26799. readonly uid: string;
  26800. /**
  26801. * Return a string representation of the texture.
  26802. * @returns the texture as a string
  26803. */
  26804. toString(): string;
  26805. /**
  26806. * Get the class name of the texture.
  26807. * @returns "BaseTexture"
  26808. */
  26809. getClassName(): string;
  26810. /**
  26811. * Define the list of animation attached to the texture.
  26812. */
  26813. animations: import("babylonjs/Animations/animation").Animation[];
  26814. /**
  26815. * An event triggered when the texture is disposed.
  26816. */
  26817. onDisposeObservable: Observable<BaseTexture>;
  26818. private _onDisposeObserver;
  26819. /**
  26820. * Callback triggered when the texture has been disposed.
  26821. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26822. */
  26823. onDispose: () => void;
  26824. /**
  26825. * Define the current state of the loading sequence when in delayed load mode.
  26826. */
  26827. delayLoadState: number;
  26828. private _scene;
  26829. /** @hidden */
  26830. _texture: Nullable<InternalTexture>;
  26831. private _uid;
  26832. /**
  26833. * Define if the texture is preventinga material to render or not.
  26834. * If not and the texture is not ready, the engine will use a default black texture instead.
  26835. */
  26836. readonly isBlocking: boolean;
  26837. /**
  26838. * Instantiates a new BaseTexture.
  26839. * Base class of all the textures in babylon.
  26840. * It groups all the common properties the materials, post process, lights... might need
  26841. * in order to make a correct use of the texture.
  26842. * @param scene Define the scene the texture blongs to
  26843. */
  26844. constructor(scene: Nullable<Scene>);
  26845. /**
  26846. * Get the scene the texture belongs to.
  26847. * @returns the scene or null if undefined
  26848. */
  26849. getScene(): Nullable<Scene>;
  26850. /**
  26851. * Get the texture transform matrix used to offset tile the texture for istance.
  26852. * @returns the transformation matrix
  26853. */
  26854. getTextureMatrix(): Matrix;
  26855. /**
  26856. * Get the texture reflection matrix used to rotate/transform the reflection.
  26857. * @returns the reflection matrix
  26858. */
  26859. getReflectionTextureMatrix(): Matrix;
  26860. /**
  26861. * Get the underlying lower level texture from Babylon.
  26862. * @returns the insternal texture
  26863. */
  26864. getInternalTexture(): Nullable<InternalTexture>;
  26865. /**
  26866. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26867. * @returns true if ready or not blocking
  26868. */
  26869. isReadyOrNotBlocking(): boolean;
  26870. /**
  26871. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26872. * @returns true if fully ready
  26873. */
  26874. isReady(): boolean;
  26875. private _cachedSize;
  26876. /**
  26877. * Get the size of the texture.
  26878. * @returns the texture size.
  26879. */
  26880. getSize(): ISize;
  26881. /**
  26882. * Get the base size of the texture.
  26883. * It can be different from the size if the texture has been resized for POT for instance
  26884. * @returns the base size
  26885. */
  26886. getBaseSize(): ISize;
  26887. /**
  26888. * Update the sampling mode of the texture.
  26889. * Default is Trilinear mode.
  26890. *
  26891. * | Value | Type | Description |
  26892. * | ----- | ------------------ | ----------- |
  26893. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26894. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26895. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26896. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26897. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26898. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26899. * | 7 | NEAREST_LINEAR | |
  26900. * | 8 | NEAREST_NEAREST | |
  26901. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26902. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26903. * | 11 | LINEAR_LINEAR | |
  26904. * | 12 | LINEAR_NEAREST | |
  26905. *
  26906. * > _mag_: magnification filter (close to the viewer)
  26907. * > _min_: minification filter (far from the viewer)
  26908. * > _mip_: filter used between mip map levels
  26909. *@param samplingMode Define the new sampling mode of the texture
  26910. */
  26911. updateSamplingMode(samplingMode: number): void;
  26912. /**
  26913. * Scales the texture if is `canRescale()`
  26914. * @param ratio the resize factor we want to use to rescale
  26915. */
  26916. scale(ratio: number): void;
  26917. /**
  26918. * Get if the texture can rescale.
  26919. */
  26920. readonly canRescale: boolean;
  26921. /** @hidden */
  26922. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26923. /** @hidden */
  26924. _rebuild(): void;
  26925. /**
  26926. * Triggers the load sequence in delayed load mode.
  26927. */
  26928. delayLoad(): void;
  26929. /**
  26930. * Clones the texture.
  26931. * @returns the cloned texture
  26932. */
  26933. clone(): Nullable<BaseTexture>;
  26934. /**
  26935. * Get the texture underlying type (INT, FLOAT...)
  26936. */
  26937. readonly textureType: number;
  26938. /**
  26939. * Get the texture underlying format (RGB, RGBA...)
  26940. */
  26941. readonly textureFormat: number;
  26942. /**
  26943. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26944. * This will returns an RGBA array buffer containing either in values (0-255) or
  26945. * float values (0-1) depending of the underlying buffer type.
  26946. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26947. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26948. * @param buffer defines a user defined buffer to fill with data (can be null)
  26949. * @returns The Array buffer containing the pixels data.
  26950. */
  26951. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26952. /**
  26953. * Release and destroy the underlying lower level texture aka internalTexture.
  26954. */
  26955. releaseInternalTexture(): void;
  26956. /**
  26957. * Get the polynomial representation of the texture data.
  26958. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26959. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26960. */
  26961. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26962. /** @hidden */
  26963. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26964. /** @hidden */
  26965. readonly _lodTextureMid: Nullable<BaseTexture>;
  26966. /** @hidden */
  26967. readonly _lodTextureLow: Nullable<BaseTexture>;
  26968. /**
  26969. * Dispose the texture and release its associated resources.
  26970. */
  26971. dispose(): void;
  26972. /**
  26973. * Serialize the texture into a JSON representation that can be parsed later on.
  26974. * @returns the JSON representation of the texture
  26975. */
  26976. serialize(): any;
  26977. /**
  26978. * Helper function to be called back once a list of texture contains only ready textures.
  26979. * @param textures Define the list of textures to wait for
  26980. * @param callback Define the callback triggered once the entire list will be ready
  26981. */
  26982. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26983. }
  26984. }
  26985. declare module "babylonjs/Materials/uniformBuffer" {
  26986. import { Nullable, FloatArray } from "babylonjs/types";
  26987. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26988. import { Engine } from "babylonjs/Engines/engine";
  26989. import { Effect } from "babylonjs/Materials/effect";
  26990. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26991. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26992. /**
  26993. * Uniform buffer objects.
  26994. *
  26995. * Handles blocks of uniform on the GPU.
  26996. *
  26997. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26998. *
  26999. * For more information, please refer to :
  27000. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27001. */
  27002. export class UniformBuffer {
  27003. private _engine;
  27004. private _buffer;
  27005. private _data;
  27006. private _bufferData;
  27007. private _dynamic?;
  27008. private _uniformLocations;
  27009. private _uniformSizes;
  27010. private _uniformLocationPointer;
  27011. private _needSync;
  27012. private _noUBO;
  27013. private _currentEffect;
  27014. private static _MAX_UNIFORM_SIZE;
  27015. private static _tempBuffer;
  27016. /**
  27017. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27018. * This is dynamic to allow compat with webgl 1 and 2.
  27019. * You will need to pass the name of the uniform as well as the value.
  27020. */
  27021. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27022. /**
  27023. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27024. * This is dynamic to allow compat with webgl 1 and 2.
  27025. * You will need to pass the name of the uniform as well as the value.
  27026. */
  27027. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27028. /**
  27029. * Lambda to Update a single float in a uniform buffer.
  27030. * This is dynamic to allow compat with webgl 1 and 2.
  27031. * You will need to pass the name of the uniform as well as the value.
  27032. */
  27033. updateFloat: (name: string, x: number) => void;
  27034. /**
  27035. * Lambda to Update a vec2 of float in a uniform buffer.
  27036. * This is dynamic to allow compat with webgl 1 and 2.
  27037. * You will need to pass the name of the uniform as well as the value.
  27038. */
  27039. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27040. /**
  27041. * Lambda to Update a vec3 of float in a uniform buffer.
  27042. * This is dynamic to allow compat with webgl 1 and 2.
  27043. * You will need to pass the name of the uniform as well as the value.
  27044. */
  27045. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27046. /**
  27047. * Lambda to Update a vec4 of float in a uniform buffer.
  27048. * This is dynamic to allow compat with webgl 1 and 2.
  27049. * You will need to pass the name of the uniform as well as the value.
  27050. */
  27051. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27052. /**
  27053. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27054. * This is dynamic to allow compat with webgl 1 and 2.
  27055. * You will need to pass the name of the uniform as well as the value.
  27056. */
  27057. updateMatrix: (name: string, mat: Matrix) => void;
  27058. /**
  27059. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27060. * This is dynamic to allow compat with webgl 1 and 2.
  27061. * You will need to pass the name of the uniform as well as the value.
  27062. */
  27063. updateVector3: (name: string, vector: Vector3) => void;
  27064. /**
  27065. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27066. * This is dynamic to allow compat with webgl 1 and 2.
  27067. * You will need to pass the name of the uniform as well as the value.
  27068. */
  27069. updateVector4: (name: string, vector: Vector4) => void;
  27070. /**
  27071. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27072. * This is dynamic to allow compat with webgl 1 and 2.
  27073. * You will need to pass the name of the uniform as well as the value.
  27074. */
  27075. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27076. /**
  27077. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27078. * This is dynamic to allow compat with webgl 1 and 2.
  27079. * You will need to pass the name of the uniform as well as the value.
  27080. */
  27081. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27082. /**
  27083. * Instantiates a new Uniform buffer objects.
  27084. *
  27085. * Handles blocks of uniform on the GPU.
  27086. *
  27087. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27088. *
  27089. * For more information, please refer to :
  27090. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27091. * @param engine Define the engine the buffer is associated with
  27092. * @param data Define the data contained in the buffer
  27093. * @param dynamic Define if the buffer is updatable
  27094. */
  27095. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27096. /**
  27097. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27098. * or just falling back on setUniformXXX calls.
  27099. */
  27100. readonly useUbo: boolean;
  27101. /**
  27102. * Indicates if the WebGL underlying uniform buffer is in sync
  27103. * with the javascript cache data.
  27104. */
  27105. readonly isSync: boolean;
  27106. /**
  27107. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27108. * Also, a dynamic UniformBuffer will disable cache verification and always
  27109. * update the underlying WebGL uniform buffer to the GPU.
  27110. * @returns if Dynamic, otherwise false
  27111. */
  27112. isDynamic(): boolean;
  27113. /**
  27114. * The data cache on JS side.
  27115. * @returns the underlying data as a float array
  27116. */
  27117. getData(): Float32Array;
  27118. /**
  27119. * The underlying WebGL Uniform buffer.
  27120. * @returns the webgl buffer
  27121. */
  27122. getBuffer(): Nullable<DataBuffer>;
  27123. /**
  27124. * std140 layout specifies how to align data within an UBO structure.
  27125. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27126. * for specs.
  27127. */
  27128. private _fillAlignment;
  27129. /**
  27130. * Adds an uniform in the buffer.
  27131. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27132. * for the layout to be correct !
  27133. * @param name Name of the uniform, as used in the uniform block in the shader.
  27134. * @param size Data size, or data directly.
  27135. */
  27136. addUniform(name: string, size: number | number[]): void;
  27137. /**
  27138. * Adds a Matrix 4x4 to the uniform buffer.
  27139. * @param name Name of the uniform, as used in the uniform block in the shader.
  27140. * @param mat A 4x4 matrix.
  27141. */
  27142. addMatrix(name: string, mat: Matrix): void;
  27143. /**
  27144. * Adds a vec2 to the uniform buffer.
  27145. * @param name Name of the uniform, as used in the uniform block in the shader.
  27146. * @param x Define the x component value of the vec2
  27147. * @param y Define the y component value of the vec2
  27148. */
  27149. addFloat2(name: string, x: number, y: number): void;
  27150. /**
  27151. * Adds a vec3 to the uniform buffer.
  27152. * @param name Name of the uniform, as used in the uniform block in the shader.
  27153. * @param x Define the x component value of the vec3
  27154. * @param y Define the y component value of the vec3
  27155. * @param z Define the z component value of the vec3
  27156. */
  27157. addFloat3(name: string, x: number, y: number, z: number): void;
  27158. /**
  27159. * Adds a vec3 to the uniform buffer.
  27160. * @param name Name of the uniform, as used in the uniform block in the shader.
  27161. * @param color Define the vec3 from a Color
  27162. */
  27163. addColor3(name: string, color: Color3): void;
  27164. /**
  27165. * Adds a vec4 to the uniform buffer.
  27166. * @param name Name of the uniform, as used in the uniform block in the shader.
  27167. * @param color Define the rgb components from a Color
  27168. * @param alpha Define the a component of the vec4
  27169. */
  27170. addColor4(name: string, color: Color3, alpha: number): void;
  27171. /**
  27172. * Adds a vec3 to the uniform buffer.
  27173. * @param name Name of the uniform, as used in the uniform block in the shader.
  27174. * @param vector Define the vec3 components from a Vector
  27175. */
  27176. addVector3(name: string, vector: Vector3): void;
  27177. /**
  27178. * Adds a Matrix 3x3 to the uniform buffer.
  27179. * @param name Name of the uniform, as used in the uniform block in the shader.
  27180. */
  27181. addMatrix3x3(name: string): void;
  27182. /**
  27183. * Adds a Matrix 2x2 to the uniform buffer.
  27184. * @param name Name of the uniform, as used in the uniform block in the shader.
  27185. */
  27186. addMatrix2x2(name: string): void;
  27187. /**
  27188. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27189. */
  27190. create(): void;
  27191. /** @hidden */
  27192. _rebuild(): void;
  27193. /**
  27194. * Updates the WebGL Uniform Buffer on the GPU.
  27195. * If the `dynamic` flag is set to true, no cache comparison is done.
  27196. * Otherwise, the buffer will be updated only if the cache differs.
  27197. */
  27198. update(): void;
  27199. /**
  27200. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27201. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27202. * @param data Define the flattened data
  27203. * @param size Define the size of the data.
  27204. */
  27205. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27206. private _updateMatrix3x3ForUniform;
  27207. private _updateMatrix3x3ForEffect;
  27208. private _updateMatrix2x2ForEffect;
  27209. private _updateMatrix2x2ForUniform;
  27210. private _updateFloatForEffect;
  27211. private _updateFloatForUniform;
  27212. private _updateFloat2ForEffect;
  27213. private _updateFloat2ForUniform;
  27214. private _updateFloat3ForEffect;
  27215. private _updateFloat3ForUniform;
  27216. private _updateFloat4ForEffect;
  27217. private _updateFloat4ForUniform;
  27218. private _updateMatrixForEffect;
  27219. private _updateMatrixForUniform;
  27220. private _updateVector3ForEffect;
  27221. private _updateVector3ForUniform;
  27222. private _updateVector4ForEffect;
  27223. private _updateVector4ForUniform;
  27224. private _updateColor3ForEffect;
  27225. private _updateColor3ForUniform;
  27226. private _updateColor4ForEffect;
  27227. private _updateColor4ForUniform;
  27228. /**
  27229. * Sets a sampler uniform on the effect.
  27230. * @param name Define the name of the sampler.
  27231. * @param texture Define the texture to set in the sampler
  27232. */
  27233. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27234. /**
  27235. * Directly updates the value of the uniform in the cache AND on the GPU.
  27236. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27237. * @param data Define the flattened data
  27238. */
  27239. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27240. /**
  27241. * Binds this uniform buffer to an effect.
  27242. * @param effect Define the effect to bind the buffer to
  27243. * @param name Name of the uniform block in the shader.
  27244. */
  27245. bindToEffect(effect: Effect, name: string): void;
  27246. /**
  27247. * Disposes the uniform buffer.
  27248. */
  27249. dispose(): void;
  27250. }
  27251. }
  27252. declare module "babylonjs/Audio/analyser" {
  27253. import { Scene } from "babylonjs/scene";
  27254. /**
  27255. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27257. */
  27258. export class Analyser {
  27259. /**
  27260. * Gets or sets the smoothing
  27261. * @ignorenaming
  27262. */
  27263. SMOOTHING: number;
  27264. /**
  27265. * Gets or sets the FFT table size
  27266. * @ignorenaming
  27267. */
  27268. FFT_SIZE: number;
  27269. /**
  27270. * Gets or sets the bar graph amplitude
  27271. * @ignorenaming
  27272. */
  27273. BARGRAPHAMPLITUDE: number;
  27274. /**
  27275. * Gets or sets the position of the debug canvas
  27276. * @ignorenaming
  27277. */
  27278. DEBUGCANVASPOS: {
  27279. x: number;
  27280. y: number;
  27281. };
  27282. /**
  27283. * Gets or sets the debug canvas size
  27284. * @ignorenaming
  27285. */
  27286. DEBUGCANVASSIZE: {
  27287. width: number;
  27288. height: number;
  27289. };
  27290. private _byteFreqs;
  27291. private _byteTime;
  27292. private _floatFreqs;
  27293. private _webAudioAnalyser;
  27294. private _debugCanvas;
  27295. private _debugCanvasContext;
  27296. private _scene;
  27297. private _registerFunc;
  27298. private _audioEngine;
  27299. /**
  27300. * Creates a new analyser
  27301. * @param scene defines hosting scene
  27302. */
  27303. constructor(scene: Scene);
  27304. /**
  27305. * Get the number of data values you will have to play with for the visualization
  27306. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27307. * @returns a number
  27308. */
  27309. getFrequencyBinCount(): number;
  27310. /**
  27311. * Gets the current frequency data as a byte array
  27312. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27313. * @returns a Uint8Array
  27314. */
  27315. getByteFrequencyData(): Uint8Array;
  27316. /**
  27317. * Gets the current waveform as a byte array
  27318. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27319. * @returns a Uint8Array
  27320. */
  27321. getByteTimeDomainData(): Uint8Array;
  27322. /**
  27323. * Gets the current frequency data as a float array
  27324. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27325. * @returns a Float32Array
  27326. */
  27327. getFloatFrequencyData(): Float32Array;
  27328. /**
  27329. * Renders the debug canvas
  27330. */
  27331. drawDebugCanvas(): void;
  27332. /**
  27333. * Stops rendering the debug canvas and removes it
  27334. */
  27335. stopDebugCanvas(): void;
  27336. /**
  27337. * Connects two audio nodes
  27338. * @param inputAudioNode defines first node to connect
  27339. * @param outputAudioNode defines second node to connect
  27340. */
  27341. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27342. /**
  27343. * Releases all associated resources
  27344. */
  27345. dispose(): void;
  27346. }
  27347. }
  27348. declare module "babylonjs/Audio/audioEngine" {
  27349. import { IDisposable } from "babylonjs/scene";
  27350. import { Analyser } from "babylonjs/Audio/analyser";
  27351. import { Nullable } from "babylonjs/types";
  27352. import { Observable } from "babylonjs/Misc/observable";
  27353. /**
  27354. * This represents an audio engine and it is responsible
  27355. * to play, synchronize and analyse sounds throughout the application.
  27356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27357. */
  27358. export interface IAudioEngine extends IDisposable {
  27359. /**
  27360. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27361. */
  27362. readonly canUseWebAudio: boolean;
  27363. /**
  27364. * Gets the current AudioContext if available.
  27365. */
  27366. readonly audioContext: Nullable<AudioContext>;
  27367. /**
  27368. * The master gain node defines the global audio volume of your audio engine.
  27369. */
  27370. readonly masterGain: GainNode;
  27371. /**
  27372. * Gets whether or not mp3 are supported by your browser.
  27373. */
  27374. readonly isMP3supported: boolean;
  27375. /**
  27376. * Gets whether or not ogg are supported by your browser.
  27377. */
  27378. readonly isOGGsupported: boolean;
  27379. /**
  27380. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27381. * @ignoreNaming
  27382. */
  27383. WarnedWebAudioUnsupported: boolean;
  27384. /**
  27385. * Defines if the audio engine relies on a custom unlocked button.
  27386. * In this case, the embedded button will not be displayed.
  27387. */
  27388. useCustomUnlockedButton: boolean;
  27389. /**
  27390. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27391. */
  27392. readonly unlocked: boolean;
  27393. /**
  27394. * Event raised when audio has been unlocked on the browser.
  27395. */
  27396. onAudioUnlockedObservable: Observable<AudioEngine>;
  27397. /**
  27398. * Event raised when audio has been locked on the browser.
  27399. */
  27400. onAudioLockedObservable: Observable<AudioEngine>;
  27401. /**
  27402. * Flags the audio engine in Locked state.
  27403. * This happens due to new browser policies preventing audio to autoplay.
  27404. */
  27405. lock(): void;
  27406. /**
  27407. * Unlocks the audio engine once a user action has been done on the dom.
  27408. * This is helpful to resume play once browser policies have been satisfied.
  27409. */
  27410. unlock(): void;
  27411. }
  27412. /**
  27413. * This represents the default audio engine used in babylon.
  27414. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27416. */
  27417. export class AudioEngine implements IAudioEngine {
  27418. private _audioContext;
  27419. private _audioContextInitialized;
  27420. private _muteButton;
  27421. private _hostElement;
  27422. /**
  27423. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27424. */
  27425. canUseWebAudio: boolean;
  27426. /**
  27427. * The master gain node defines the global audio volume of your audio engine.
  27428. */
  27429. masterGain: GainNode;
  27430. /**
  27431. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27432. * @ignoreNaming
  27433. */
  27434. WarnedWebAudioUnsupported: boolean;
  27435. /**
  27436. * Gets whether or not mp3 are supported by your browser.
  27437. */
  27438. isMP3supported: boolean;
  27439. /**
  27440. * Gets whether or not ogg are supported by your browser.
  27441. */
  27442. isOGGsupported: boolean;
  27443. /**
  27444. * Gets whether audio has been unlocked on the device.
  27445. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27446. * a user interaction has happened.
  27447. */
  27448. unlocked: boolean;
  27449. /**
  27450. * Defines if the audio engine relies on a custom unlocked button.
  27451. * In this case, the embedded button will not be displayed.
  27452. */
  27453. useCustomUnlockedButton: boolean;
  27454. /**
  27455. * Event raised when audio has been unlocked on the browser.
  27456. */
  27457. onAudioUnlockedObservable: Observable<AudioEngine>;
  27458. /**
  27459. * Event raised when audio has been locked on the browser.
  27460. */
  27461. onAudioLockedObservable: Observable<AudioEngine>;
  27462. /**
  27463. * Gets the current AudioContext if available.
  27464. */
  27465. readonly audioContext: Nullable<AudioContext>;
  27466. private _connectedAnalyser;
  27467. /**
  27468. * Instantiates a new audio engine.
  27469. *
  27470. * There should be only one per page as some browsers restrict the number
  27471. * of audio contexts you can create.
  27472. * @param hostElement defines the host element where to display the mute icon if necessary
  27473. */
  27474. constructor(hostElement?: Nullable<HTMLElement>);
  27475. /**
  27476. * Flags the audio engine in Locked state.
  27477. * This happens due to new browser policies preventing audio to autoplay.
  27478. */
  27479. lock(): void;
  27480. /**
  27481. * Unlocks the audio engine once a user action has been done on the dom.
  27482. * This is helpful to resume play once browser policies have been satisfied.
  27483. */
  27484. unlock(): void;
  27485. private _resumeAudioContext;
  27486. private _initializeAudioContext;
  27487. private _tryToRun;
  27488. private _triggerRunningState;
  27489. private _triggerSuspendedState;
  27490. private _displayMuteButton;
  27491. private _moveButtonToTopLeft;
  27492. private _onResize;
  27493. private _hideMuteButton;
  27494. /**
  27495. * Destroy and release the resources associated with the audio ccontext.
  27496. */
  27497. dispose(): void;
  27498. /**
  27499. * Gets the global volume sets on the master gain.
  27500. * @returns the global volume if set or -1 otherwise
  27501. */
  27502. getGlobalVolume(): number;
  27503. /**
  27504. * Sets the global volume of your experience (sets on the master gain).
  27505. * @param newVolume Defines the new global volume of the application
  27506. */
  27507. setGlobalVolume(newVolume: number): void;
  27508. /**
  27509. * Connect the audio engine to an audio analyser allowing some amazing
  27510. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27512. * @param analyser The analyser to connect to the engine
  27513. */
  27514. connectToAnalyser(analyser: Analyser): void;
  27515. }
  27516. }
  27517. declare module "babylonjs/Loading/loadingScreen" {
  27518. /**
  27519. * Interface used to present a loading screen while loading a scene
  27520. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27521. */
  27522. export interface ILoadingScreen {
  27523. /**
  27524. * Function called to display the loading screen
  27525. */
  27526. displayLoadingUI: () => void;
  27527. /**
  27528. * Function called to hide the loading screen
  27529. */
  27530. hideLoadingUI: () => void;
  27531. /**
  27532. * Gets or sets the color to use for the background
  27533. */
  27534. loadingUIBackgroundColor: string;
  27535. /**
  27536. * Gets or sets the text to display while loading
  27537. */
  27538. loadingUIText: string;
  27539. }
  27540. /**
  27541. * Class used for the default loading screen
  27542. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27543. */
  27544. export class DefaultLoadingScreen implements ILoadingScreen {
  27545. private _renderingCanvas;
  27546. private _loadingText;
  27547. private _loadingDivBackgroundColor;
  27548. private _loadingDiv;
  27549. private _loadingTextDiv;
  27550. /**
  27551. * Creates a new default loading screen
  27552. * @param _renderingCanvas defines the canvas used to render the scene
  27553. * @param _loadingText defines the default text to display
  27554. * @param _loadingDivBackgroundColor defines the default background color
  27555. */
  27556. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27557. /**
  27558. * Function called to display the loading screen
  27559. */
  27560. displayLoadingUI(): void;
  27561. /**
  27562. * Function called to hide the loading screen
  27563. */
  27564. hideLoadingUI(): void;
  27565. /**
  27566. * Gets or sets the text to display while loading
  27567. */
  27568. loadingUIText: string;
  27569. /**
  27570. * Gets or sets the color to use for the background
  27571. */
  27572. loadingUIBackgroundColor: string;
  27573. private _resizeLoadingUI;
  27574. }
  27575. }
  27576. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27577. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27578. import { Engine } from "babylonjs/Engines/engine";
  27579. import { Nullable } from "babylonjs/types";
  27580. /** @hidden */
  27581. export class WebGLPipelineContext implements IPipelineContext {
  27582. engine: Engine;
  27583. program: Nullable<WebGLProgram>;
  27584. context?: WebGLRenderingContext;
  27585. vertexShader?: WebGLShader;
  27586. fragmentShader?: WebGLShader;
  27587. isParallelCompiled: boolean;
  27588. onCompiled?: () => void;
  27589. transformFeedback?: WebGLTransformFeedback | null;
  27590. readonly isAsync: boolean;
  27591. readonly isReady: boolean;
  27592. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27593. }
  27594. }
  27595. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27596. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27597. /** @hidden */
  27598. export class WebGLDataBuffer extends DataBuffer {
  27599. private _buffer;
  27600. constructor(resource: WebGLBuffer);
  27601. readonly underlyingResource: any;
  27602. }
  27603. }
  27604. declare module "babylonjs/Materials/Textures/videoTexture" {
  27605. import { Observable } from "babylonjs/Misc/observable";
  27606. import { Nullable } from "babylonjs/types";
  27607. import { Scene } from "babylonjs/scene";
  27608. import { Texture } from "babylonjs/Materials/Textures/texture";
  27609. /**
  27610. * Settings for finer control over video usage
  27611. */
  27612. export interface VideoTextureSettings {
  27613. /**
  27614. * Applies `autoplay` to video, if specified
  27615. */
  27616. autoPlay?: boolean;
  27617. /**
  27618. * Applies `loop` to video, if specified
  27619. */
  27620. loop?: boolean;
  27621. /**
  27622. * Automatically updates internal texture from video at every frame in the render loop
  27623. */
  27624. autoUpdateTexture: boolean;
  27625. /**
  27626. * Image src displayed during the video loading or until the user interacts with the video.
  27627. */
  27628. poster?: string;
  27629. }
  27630. /**
  27631. * If you want to display a video in your scene, this is the special texture for that.
  27632. * This special texture works similar to other textures, with the exception of a few parameters.
  27633. * @see https://doc.babylonjs.com/how_to/video_texture
  27634. */
  27635. export class VideoTexture extends Texture {
  27636. /**
  27637. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27638. */
  27639. readonly autoUpdateTexture: boolean;
  27640. /**
  27641. * The video instance used by the texture internally
  27642. */
  27643. readonly video: HTMLVideoElement;
  27644. private _onUserActionRequestedObservable;
  27645. /**
  27646. * Event triggerd when a dom action is required by the user to play the video.
  27647. * This happens due to recent changes in browser policies preventing video to auto start.
  27648. */
  27649. readonly onUserActionRequestedObservable: Observable<Texture>;
  27650. private _generateMipMaps;
  27651. private _engine;
  27652. private _stillImageCaptured;
  27653. private _displayingPosterTexture;
  27654. private _settings;
  27655. private _createInternalTextureOnEvent;
  27656. /**
  27657. * Creates a video texture.
  27658. * If you want to display a video in your scene, this is the special texture for that.
  27659. * This special texture works similar to other textures, with the exception of a few parameters.
  27660. * @see https://doc.babylonjs.com/how_to/video_texture
  27661. * @param name optional name, will detect from video source, if not defined
  27662. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27663. * @param scene is obviously the current scene.
  27664. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27665. * @param invertY is false by default but can be used to invert video on Y axis
  27666. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27667. * @param settings allows finer control over video usage
  27668. */
  27669. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27670. private _getName;
  27671. private _getVideo;
  27672. private _createInternalTexture;
  27673. private reset;
  27674. /**
  27675. * @hidden Internal method to initiate `update`.
  27676. */
  27677. _rebuild(): void;
  27678. /**
  27679. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27680. */
  27681. update(): void;
  27682. /**
  27683. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27684. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27685. */
  27686. updateTexture(isVisible: boolean): void;
  27687. protected _updateInternalTexture: () => void;
  27688. /**
  27689. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27690. * @param url New url.
  27691. */
  27692. updateURL(url: string): void;
  27693. /**
  27694. * Dispose the texture and release its associated resources.
  27695. */
  27696. dispose(): void;
  27697. /**
  27698. * Creates a video texture straight from a stream.
  27699. * @param scene Define the scene the texture should be created in
  27700. * @param stream Define the stream the texture should be created from
  27701. * @returns The created video texture as a promise
  27702. */
  27703. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27704. /**
  27705. * Creates a video texture straight from your WebCam video feed.
  27706. * @param scene Define the scene the texture should be created in
  27707. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27708. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27709. * @returns The created video texture as a promise
  27710. */
  27711. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27712. minWidth: number;
  27713. maxWidth: number;
  27714. minHeight: number;
  27715. maxHeight: number;
  27716. deviceId: string;
  27717. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27718. /**
  27719. * Creates a video texture straight from your WebCam video feed.
  27720. * @param scene Define the scene the texture should be created in
  27721. * @param onReady Define a callback to triggered once the texture will be ready
  27722. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27723. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27724. */
  27725. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27726. minWidth: number;
  27727. maxWidth: number;
  27728. minHeight: number;
  27729. maxHeight: number;
  27730. deviceId: string;
  27731. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27732. }
  27733. }
  27734. declare module "babylonjs/Engines/engine" {
  27735. import { Observable } from "babylonjs/Misc/observable";
  27736. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27737. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27738. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27739. import { Camera } from "babylonjs/Cameras/camera";
  27740. import { Scene } from "babylonjs/scene";
  27741. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27742. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27743. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27744. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27745. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27746. import { Material } from "babylonjs/Materials/material";
  27747. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27748. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27749. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27750. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27751. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27752. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27753. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27754. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27755. import { WebRequest } from "babylonjs/Misc/webRequest";
  27756. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27757. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27758. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27759. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27760. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27761. /**
  27762. * Interface for attribute information associated with buffer instanciation
  27763. */
  27764. export class InstancingAttributeInfo {
  27765. /**
  27766. * Index/offset of the attribute in the vertex shader
  27767. */
  27768. index: number;
  27769. /**
  27770. * size of the attribute, 1, 2, 3 or 4
  27771. */
  27772. attributeSize: number;
  27773. /**
  27774. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27775. * default is FLOAT
  27776. */
  27777. attribyteType: number;
  27778. /**
  27779. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27780. */
  27781. normalized: boolean;
  27782. /**
  27783. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27784. */
  27785. offset: number;
  27786. /**
  27787. * Name of the GLSL attribute, for debugging purpose only
  27788. */
  27789. attributeName: string;
  27790. }
  27791. /**
  27792. * Define options used to create a depth texture
  27793. */
  27794. export class DepthTextureCreationOptions {
  27795. /** Specifies whether or not a stencil should be allocated in the texture */
  27796. generateStencil?: boolean;
  27797. /** Specifies whether or not bilinear filtering is enable on the texture */
  27798. bilinearFiltering?: boolean;
  27799. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27800. comparisonFunction?: number;
  27801. /** Specifies if the created texture is a cube texture */
  27802. isCube?: boolean;
  27803. }
  27804. /**
  27805. * Class used to describe the capabilities of the engine relatively to the current browser
  27806. */
  27807. export class EngineCapabilities {
  27808. /** Maximum textures units per fragment shader */
  27809. maxTexturesImageUnits: number;
  27810. /** Maximum texture units per vertex shader */
  27811. maxVertexTextureImageUnits: number;
  27812. /** Maximum textures units in the entire pipeline */
  27813. maxCombinedTexturesImageUnits: number;
  27814. /** Maximum texture size */
  27815. maxTextureSize: number;
  27816. /** Maximum cube texture size */
  27817. maxCubemapTextureSize: number;
  27818. /** Maximum render texture size */
  27819. maxRenderTextureSize: number;
  27820. /** Maximum number of vertex attributes */
  27821. maxVertexAttribs: number;
  27822. /** Maximum number of varyings */
  27823. maxVaryingVectors: number;
  27824. /** Maximum number of uniforms per vertex shader */
  27825. maxVertexUniformVectors: number;
  27826. /** Maximum number of uniforms per fragment shader */
  27827. maxFragmentUniformVectors: number;
  27828. /** Defines if standard derivates (dx/dy) are supported */
  27829. standardDerivatives: boolean;
  27830. /** Defines if s3tc texture compression is supported */
  27831. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27832. /** Defines if pvrtc texture compression is supported */
  27833. pvrtc: any;
  27834. /** Defines if etc1 texture compression is supported */
  27835. etc1: any;
  27836. /** Defines if etc2 texture compression is supported */
  27837. etc2: any;
  27838. /** Defines if astc texture compression is supported */
  27839. astc: any;
  27840. /** Defines if float textures are supported */
  27841. textureFloat: boolean;
  27842. /** Defines if vertex array objects are supported */
  27843. vertexArrayObject: boolean;
  27844. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27845. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27846. /** Gets the maximum level of anisotropy supported */
  27847. maxAnisotropy: number;
  27848. /** Defines if instancing is supported */
  27849. instancedArrays: boolean;
  27850. /** Defines if 32 bits indices are supported */
  27851. uintIndices: boolean;
  27852. /** Defines if high precision shaders are supported */
  27853. highPrecisionShaderSupported: boolean;
  27854. /** Defines if depth reading in the fragment shader is supported */
  27855. fragmentDepthSupported: boolean;
  27856. /** Defines if float texture linear filtering is supported*/
  27857. textureFloatLinearFiltering: boolean;
  27858. /** Defines if rendering to float textures is supported */
  27859. textureFloatRender: boolean;
  27860. /** Defines if half float textures are supported*/
  27861. textureHalfFloat: boolean;
  27862. /** Defines if half float texture linear filtering is supported*/
  27863. textureHalfFloatLinearFiltering: boolean;
  27864. /** Defines if rendering to half float textures is supported */
  27865. textureHalfFloatRender: boolean;
  27866. /** Defines if textureLOD shader command is supported */
  27867. textureLOD: boolean;
  27868. /** Defines if draw buffers extension is supported */
  27869. drawBuffersExtension: boolean;
  27870. /** Defines if depth textures are supported */
  27871. depthTextureExtension: boolean;
  27872. /** Defines if float color buffer are supported */
  27873. colorBufferFloat: boolean;
  27874. /** Gets disjoint timer query extension (null if not supported) */
  27875. timerQuery: EXT_disjoint_timer_query;
  27876. /** Defines if timestamp can be used with timer query */
  27877. canUseTimestampForTimerQuery: boolean;
  27878. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27879. multiview: any;
  27880. /** Function used to let the system compiles shaders in background */
  27881. parallelShaderCompile: {
  27882. COMPLETION_STATUS_KHR: number;
  27883. };
  27884. }
  27885. /** Interface defining initialization parameters for Engine class */
  27886. export interface EngineOptions extends WebGLContextAttributes {
  27887. /**
  27888. * Defines if the engine should no exceed a specified device ratio
  27889. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27890. */
  27891. limitDeviceRatio?: number;
  27892. /**
  27893. * Defines if webvr should be enabled automatically
  27894. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27895. */
  27896. autoEnableWebVR?: boolean;
  27897. /**
  27898. * Defines if webgl2 should be turned off even if supported
  27899. * @see http://doc.babylonjs.com/features/webgl2
  27900. */
  27901. disableWebGL2Support?: boolean;
  27902. /**
  27903. * Defines if webaudio should be initialized as well
  27904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27905. */
  27906. audioEngine?: boolean;
  27907. /**
  27908. * Defines if animations should run using a deterministic lock step
  27909. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27910. */
  27911. deterministicLockstep?: boolean;
  27912. /** Defines the maximum steps to use with deterministic lock step mode */
  27913. lockstepMaxSteps?: number;
  27914. /**
  27915. * Defines that engine should ignore context lost events
  27916. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27917. */
  27918. doNotHandleContextLost?: boolean;
  27919. /**
  27920. * Defines that engine should ignore modifying touch action attribute and style
  27921. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27922. */
  27923. doNotHandleTouchAction?: boolean;
  27924. /**
  27925. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27926. */
  27927. useHighPrecisionFloats?: boolean;
  27928. }
  27929. /**
  27930. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27931. */
  27932. export class Engine {
  27933. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27934. static ExceptionList: ({
  27935. key: string;
  27936. capture: string;
  27937. captureConstraint: number;
  27938. targets: string[];
  27939. } | {
  27940. key: string;
  27941. capture: null;
  27942. captureConstraint: null;
  27943. targets: string[];
  27944. })[];
  27945. /** Gets the list of created engines */
  27946. static readonly Instances: Engine[];
  27947. /**
  27948. * Gets the latest created engine
  27949. */
  27950. static readonly LastCreatedEngine: Nullable<Engine>;
  27951. /**
  27952. * Gets the latest created scene
  27953. */
  27954. static readonly LastCreatedScene: Nullable<Scene>;
  27955. /**
  27956. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27957. * @param flag defines which part of the materials must be marked as dirty
  27958. * @param predicate defines a predicate used to filter which materials should be affected
  27959. */
  27960. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27961. /**
  27962. * Hidden
  27963. */
  27964. static _TextureLoaders: IInternalTextureLoader[];
  27965. /** Defines that alpha blending is disabled */
  27966. static readonly ALPHA_DISABLE: number;
  27967. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27968. static readonly ALPHA_ADD: number;
  27969. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27970. static readonly ALPHA_COMBINE: number;
  27971. /** Defines that alpha blending to DEST - SRC * DEST */
  27972. static readonly ALPHA_SUBTRACT: number;
  27973. /** Defines that alpha blending to SRC * DEST */
  27974. static readonly ALPHA_MULTIPLY: number;
  27975. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27976. static readonly ALPHA_MAXIMIZED: number;
  27977. /** Defines that alpha blending to SRC + DEST */
  27978. static readonly ALPHA_ONEONE: number;
  27979. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27980. static readonly ALPHA_PREMULTIPLIED: number;
  27981. /**
  27982. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27983. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27984. */
  27985. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27986. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27987. static readonly ALPHA_INTERPOLATE: number;
  27988. /**
  27989. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27990. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27991. */
  27992. static readonly ALPHA_SCREENMODE: number;
  27993. /** Defines that the ressource is not delayed*/
  27994. static readonly DELAYLOADSTATE_NONE: number;
  27995. /** Defines that the ressource was successfully delay loaded */
  27996. static readonly DELAYLOADSTATE_LOADED: number;
  27997. /** Defines that the ressource is currently delay loading */
  27998. static readonly DELAYLOADSTATE_LOADING: number;
  27999. /** Defines that the ressource is delayed and has not started loading */
  28000. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28001. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28002. static readonly NEVER: number;
  28003. /** 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 */
  28004. static readonly ALWAYS: number;
  28005. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28006. static readonly LESS: number;
  28007. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28008. static readonly EQUAL: number;
  28009. /** 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 */
  28010. static readonly LEQUAL: number;
  28011. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28012. static readonly GREATER: number;
  28013. /** 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 */
  28014. static readonly GEQUAL: number;
  28015. /** 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 */
  28016. static readonly NOTEQUAL: number;
  28017. /** Passed to stencilOperation to specify that stencil value must be kept */
  28018. static readonly KEEP: number;
  28019. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28020. static readonly REPLACE: number;
  28021. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28022. static readonly INCR: number;
  28023. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28024. static readonly DECR: number;
  28025. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28026. static readonly INVERT: number;
  28027. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28028. static readonly INCR_WRAP: number;
  28029. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28030. static readonly DECR_WRAP: number;
  28031. /** Texture is not repeating outside of 0..1 UVs */
  28032. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28033. /** Texture is repeating outside of 0..1 UVs */
  28034. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28035. /** Texture is repeating and mirrored */
  28036. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28037. /** ALPHA */
  28038. static readonly TEXTUREFORMAT_ALPHA: number;
  28039. /** LUMINANCE */
  28040. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28041. /** LUMINANCE_ALPHA */
  28042. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28043. /** RGB */
  28044. static readonly TEXTUREFORMAT_RGB: number;
  28045. /** RGBA */
  28046. static readonly TEXTUREFORMAT_RGBA: number;
  28047. /** RED */
  28048. static readonly TEXTUREFORMAT_RED: number;
  28049. /** RED (2nd reference) */
  28050. static readonly TEXTUREFORMAT_R: number;
  28051. /** RG */
  28052. static readonly TEXTUREFORMAT_RG: number;
  28053. /** RED_INTEGER */
  28054. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28055. /** RED_INTEGER (2nd reference) */
  28056. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28057. /** RG_INTEGER */
  28058. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28059. /** RGB_INTEGER */
  28060. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28061. /** RGBA_INTEGER */
  28062. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28063. /** UNSIGNED_BYTE */
  28064. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28065. /** UNSIGNED_BYTE (2nd reference) */
  28066. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28067. /** FLOAT */
  28068. static readonly TEXTURETYPE_FLOAT: number;
  28069. /** HALF_FLOAT */
  28070. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28071. /** BYTE */
  28072. static readonly TEXTURETYPE_BYTE: number;
  28073. /** SHORT */
  28074. static readonly TEXTURETYPE_SHORT: number;
  28075. /** UNSIGNED_SHORT */
  28076. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28077. /** INT */
  28078. static readonly TEXTURETYPE_INT: number;
  28079. /** UNSIGNED_INT */
  28080. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28081. /** UNSIGNED_SHORT_4_4_4_4 */
  28082. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28083. /** UNSIGNED_SHORT_5_5_5_1 */
  28084. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28085. /** UNSIGNED_SHORT_5_6_5 */
  28086. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28087. /** UNSIGNED_INT_2_10_10_10_REV */
  28088. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28089. /** UNSIGNED_INT_24_8 */
  28090. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28091. /** UNSIGNED_INT_10F_11F_11F_REV */
  28092. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28093. /** UNSIGNED_INT_5_9_9_9_REV */
  28094. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28095. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28096. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28097. /** nearest is mag = nearest and min = nearest and mip = linear */
  28098. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28099. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28100. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28101. /** Trilinear is mag = linear and min = linear and mip = linear */
  28102. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28103. /** nearest is mag = nearest and min = nearest and mip = linear */
  28104. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28105. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28106. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28107. /** Trilinear is mag = linear and min = linear and mip = linear */
  28108. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28109. /** mag = nearest and min = nearest and mip = nearest */
  28110. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28111. /** mag = nearest and min = linear and mip = nearest */
  28112. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28113. /** mag = nearest and min = linear and mip = linear */
  28114. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28115. /** mag = nearest and min = linear and mip = none */
  28116. static readonly TEXTURE_NEAREST_LINEAR: number;
  28117. /** mag = nearest and min = nearest and mip = none */
  28118. static readonly TEXTURE_NEAREST_NEAREST: number;
  28119. /** mag = linear and min = nearest and mip = nearest */
  28120. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28121. /** mag = linear and min = nearest and mip = linear */
  28122. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28123. /** mag = linear and min = linear and mip = none */
  28124. static readonly TEXTURE_LINEAR_LINEAR: number;
  28125. /** mag = linear and min = nearest and mip = none */
  28126. static readonly TEXTURE_LINEAR_NEAREST: number;
  28127. /** Explicit coordinates mode */
  28128. static readonly TEXTURE_EXPLICIT_MODE: number;
  28129. /** Spherical coordinates mode */
  28130. static readonly TEXTURE_SPHERICAL_MODE: number;
  28131. /** Planar coordinates mode */
  28132. static readonly TEXTURE_PLANAR_MODE: number;
  28133. /** Cubic coordinates mode */
  28134. static readonly TEXTURE_CUBIC_MODE: number;
  28135. /** Projection coordinates mode */
  28136. static readonly TEXTURE_PROJECTION_MODE: number;
  28137. /** Skybox coordinates mode */
  28138. static readonly TEXTURE_SKYBOX_MODE: number;
  28139. /** Inverse Cubic coordinates mode */
  28140. static readonly TEXTURE_INVCUBIC_MODE: number;
  28141. /** Equirectangular coordinates mode */
  28142. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28143. /** Equirectangular Fixed coordinates mode */
  28144. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28145. /** Equirectangular Fixed Mirrored coordinates mode */
  28146. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28147. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28148. static readonly SCALEMODE_FLOOR: number;
  28149. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28150. static readonly SCALEMODE_NEAREST: number;
  28151. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28152. static readonly SCALEMODE_CEILING: number;
  28153. /**
  28154. * Returns the current npm package of the sdk
  28155. */
  28156. static readonly NpmPackage: string;
  28157. /**
  28158. * Returns the current version of the framework
  28159. */
  28160. static readonly Version: string;
  28161. /**
  28162. * Returns a string describing the current engine
  28163. */
  28164. readonly description: string;
  28165. /**
  28166. * Gets or sets the epsilon value used by collision engine
  28167. */
  28168. static CollisionsEpsilon: number;
  28169. /**
  28170. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28171. */
  28172. static ShadersRepository: string;
  28173. /**
  28174. * Method called to create the default loading screen.
  28175. * This can be overriden in your own app.
  28176. * @param canvas The rendering canvas element
  28177. * @returns The loading screen
  28178. */
  28179. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28180. /**
  28181. * Method called to create the default rescale post process on each engine.
  28182. */
  28183. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28184. /**
  28185. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28186. */
  28187. forcePOTTextures: boolean;
  28188. /**
  28189. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28190. */
  28191. isFullscreen: boolean;
  28192. /**
  28193. * Gets a boolean indicating if the pointer is currently locked
  28194. */
  28195. isPointerLock: boolean;
  28196. /**
  28197. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28198. */
  28199. cullBackFaces: boolean;
  28200. /**
  28201. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28202. */
  28203. renderEvenInBackground: boolean;
  28204. /**
  28205. * Gets or sets a boolean indicating that cache can be kept between frames
  28206. */
  28207. preventCacheWipeBetweenFrames: boolean;
  28208. /**
  28209. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28210. **/
  28211. enableOfflineSupport: boolean;
  28212. /**
  28213. * 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)
  28214. **/
  28215. disableManifestCheck: boolean;
  28216. /**
  28217. * Gets the list of created scenes
  28218. */
  28219. scenes: Scene[];
  28220. /**
  28221. * Event raised when a new scene is created
  28222. */
  28223. onNewSceneAddedObservable: Observable<Scene>;
  28224. /**
  28225. * Gets the list of created postprocesses
  28226. */
  28227. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28228. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28229. validateShaderPrograms: boolean;
  28230. /**
  28231. * Observable event triggered each time the rendering canvas is resized
  28232. */
  28233. onResizeObservable: Observable<Engine>;
  28234. /**
  28235. * Observable event triggered each time the canvas loses focus
  28236. */
  28237. onCanvasBlurObservable: Observable<Engine>;
  28238. /**
  28239. * Observable event triggered each time the canvas gains focus
  28240. */
  28241. onCanvasFocusObservable: Observable<Engine>;
  28242. /**
  28243. * Observable event triggered each time the canvas receives pointerout event
  28244. */
  28245. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28246. /**
  28247. * Observable event triggered before each texture is initialized
  28248. */
  28249. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28250. /**
  28251. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28252. */
  28253. disableUniformBuffers: boolean;
  28254. /** @hidden */
  28255. _uniformBuffers: UniformBuffer[];
  28256. /**
  28257. * Gets a boolean indicating that the engine supports uniform buffers
  28258. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28259. */
  28260. readonly supportsUniformBuffers: boolean;
  28261. /**
  28262. * Observable raised when the engine begins a new frame
  28263. */
  28264. onBeginFrameObservable: Observable<Engine>;
  28265. /**
  28266. * If set, will be used to request the next animation frame for the render loop
  28267. */
  28268. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28269. /**
  28270. * Observable raised when the engine ends the current frame
  28271. */
  28272. onEndFrameObservable: Observable<Engine>;
  28273. /**
  28274. * Observable raised when the engine is about to compile a shader
  28275. */
  28276. onBeforeShaderCompilationObservable: Observable<Engine>;
  28277. /**
  28278. * Observable raised when the engine has jsut compiled a shader
  28279. */
  28280. onAfterShaderCompilationObservable: Observable<Engine>;
  28281. /** @hidden */
  28282. _gl: WebGLRenderingContext;
  28283. private _renderingCanvas;
  28284. private _windowIsBackground;
  28285. private _webGLVersion;
  28286. protected _highPrecisionShadersAllowed: boolean;
  28287. /** @hidden */
  28288. readonly _shouldUseHighPrecisionShader: boolean;
  28289. /**
  28290. * Gets a boolean indicating that only power of 2 textures are supported
  28291. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28292. */
  28293. readonly needPOTTextures: boolean;
  28294. /** @hidden */
  28295. _badOS: boolean;
  28296. /** @hidden */
  28297. _badDesktopOS: boolean;
  28298. /**
  28299. * Gets the audio engine
  28300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28301. * @ignorenaming
  28302. */
  28303. static audioEngine: IAudioEngine;
  28304. /**
  28305. * Default AudioEngine factory responsible of creating the Audio Engine.
  28306. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28307. */
  28308. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28309. /**
  28310. * Default offline support factory responsible of creating a tool used to store data locally.
  28311. * By default, this will create a Database object if the workload has been embedded.
  28312. */
  28313. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28314. private _onFocus;
  28315. private _onBlur;
  28316. private _onCanvasPointerOut;
  28317. private _onCanvasBlur;
  28318. private _onCanvasFocus;
  28319. private _onFullscreenChange;
  28320. private _onPointerLockChange;
  28321. private _hardwareScalingLevel;
  28322. /** @hidden */
  28323. _caps: EngineCapabilities;
  28324. private _pointerLockRequested;
  28325. private _isStencilEnable;
  28326. private _colorWrite;
  28327. private _loadingScreen;
  28328. /** @hidden */
  28329. _drawCalls: PerfCounter;
  28330. private _glVersion;
  28331. private _glRenderer;
  28332. private _glVendor;
  28333. private _videoTextureSupported;
  28334. private _renderingQueueLaunched;
  28335. private _activeRenderLoops;
  28336. private _deterministicLockstep;
  28337. private _lockstepMaxSteps;
  28338. /**
  28339. * Observable signaled when a context lost event is raised
  28340. */
  28341. onContextLostObservable: Observable<Engine>;
  28342. /**
  28343. * Observable signaled when a context restored event is raised
  28344. */
  28345. onContextRestoredObservable: Observable<Engine>;
  28346. private _onContextLost;
  28347. private _onContextRestored;
  28348. private _contextWasLost;
  28349. /** @hidden */
  28350. _doNotHandleContextLost: boolean;
  28351. /**
  28352. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28353. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28354. */
  28355. doNotHandleContextLost: boolean;
  28356. private _performanceMonitor;
  28357. private _fps;
  28358. private _deltaTime;
  28359. /**
  28360. * Turn this value on if you want to pause FPS computation when in background
  28361. */
  28362. disablePerformanceMonitorInBackground: boolean;
  28363. /**
  28364. * Gets the performance monitor attached to this engine
  28365. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28366. */
  28367. readonly performanceMonitor: PerformanceMonitor;
  28368. /**
  28369. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28370. */
  28371. disableVertexArrayObjects: boolean;
  28372. /** @hidden */
  28373. protected _depthCullingState: _DepthCullingState;
  28374. /** @hidden */
  28375. protected _stencilState: _StencilState;
  28376. /** @hidden */
  28377. protected _alphaState: _AlphaState;
  28378. /** @hidden */
  28379. protected _alphaMode: number;
  28380. /** @hidden */
  28381. _internalTexturesCache: InternalTexture[];
  28382. /** @hidden */
  28383. protected _activeChannel: number;
  28384. private _currentTextureChannel;
  28385. /** @hidden */
  28386. protected _boundTexturesCache: {
  28387. [key: string]: Nullable<InternalTexture>;
  28388. };
  28389. /** @hidden */
  28390. protected _currentEffect: Nullable<Effect>;
  28391. /** @hidden */
  28392. protected _currentProgram: Nullable<WebGLProgram>;
  28393. private _compiledEffects;
  28394. private _vertexAttribArraysEnabled;
  28395. /** @hidden */
  28396. protected _cachedViewport: Nullable<Viewport>;
  28397. private _cachedVertexArrayObject;
  28398. /** @hidden */
  28399. protected _cachedVertexBuffers: any;
  28400. /** @hidden */
  28401. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28402. /** @hidden */
  28403. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28404. /** @hidden */
  28405. _currentRenderTarget: Nullable<InternalTexture>;
  28406. private _uintIndicesCurrentlySet;
  28407. private _currentBoundBuffer;
  28408. /** @hidden */
  28409. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28410. private _currentBufferPointers;
  28411. private _currentInstanceLocations;
  28412. private _currentInstanceBuffers;
  28413. private _textureUnits;
  28414. /** @hidden */
  28415. _workingCanvas: Nullable<HTMLCanvasElement>;
  28416. /** @hidden */
  28417. _workingContext: Nullable<CanvasRenderingContext2D>;
  28418. private _rescalePostProcess;
  28419. private _dummyFramebuffer;
  28420. private _externalData;
  28421. /** @hidden */
  28422. _bindedRenderFunction: any;
  28423. private _vaoRecordInProgress;
  28424. private _mustWipeVertexAttributes;
  28425. private _emptyTexture;
  28426. private _emptyCubeTexture;
  28427. private _emptyTexture3D;
  28428. /** @hidden */
  28429. _frameHandler: number;
  28430. private _nextFreeTextureSlots;
  28431. private _maxSimultaneousTextures;
  28432. private _activeRequests;
  28433. private _texturesSupported;
  28434. /** @hidden */
  28435. _textureFormatInUse: Nullable<string>;
  28436. /**
  28437. * Gets the list of texture formats supported
  28438. */
  28439. readonly texturesSupported: Array<string>;
  28440. /**
  28441. * Gets the list of texture formats in use
  28442. */
  28443. readonly textureFormatInUse: Nullable<string>;
  28444. /**
  28445. * Gets the current viewport
  28446. */
  28447. readonly currentViewport: Nullable<Viewport>;
  28448. /**
  28449. * Gets the default empty texture
  28450. */
  28451. readonly emptyTexture: InternalTexture;
  28452. /**
  28453. * Gets the default empty 3D texture
  28454. */
  28455. readonly emptyTexture3D: InternalTexture;
  28456. /**
  28457. * Gets the default empty cube texture
  28458. */
  28459. readonly emptyCubeTexture: InternalTexture;
  28460. /**
  28461. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28462. */
  28463. readonly premultipliedAlpha: boolean;
  28464. /**
  28465. * Creates a new engine
  28466. * @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
  28467. * @param antialias defines enable antialiasing (default: false)
  28468. * @param options defines further options to be sent to the getContext() function
  28469. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28470. */
  28471. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28472. /**
  28473. * Initializes a webVR display and starts listening to display change events
  28474. * The onVRDisplayChangedObservable will be notified upon these changes
  28475. * @returns The onVRDisplayChangedObservable
  28476. */
  28477. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28478. /** @hidden */
  28479. _prepareVRComponent(): void;
  28480. /** @hidden */
  28481. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28482. /** @hidden */
  28483. _submitVRFrame(): void;
  28484. /**
  28485. * Call this function to leave webVR mode
  28486. * Will do nothing if webVR is not supported or if there is no webVR device
  28487. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28488. */
  28489. disableVR(): void;
  28490. /**
  28491. * Gets a boolean indicating that the system is in VR mode and is presenting
  28492. * @returns true if VR mode is engaged
  28493. */
  28494. isVRPresenting(): boolean;
  28495. /** @hidden */
  28496. _requestVRFrame(): void;
  28497. private _disableTouchAction;
  28498. private _rebuildInternalTextures;
  28499. private _rebuildEffects;
  28500. /**
  28501. * Gets a boolean indicating if all created effects are ready
  28502. * @returns true if all effects are ready
  28503. */
  28504. areAllEffectsReady(): boolean;
  28505. private _rebuildBuffers;
  28506. private _initGLContext;
  28507. /**
  28508. * Gets version of the current webGL context
  28509. */
  28510. readonly webGLVersion: number;
  28511. /**
  28512. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28513. */
  28514. readonly isStencilEnable: boolean;
  28515. /** @hidden */
  28516. _prepareWorkingCanvas(): void;
  28517. /**
  28518. * Reset the texture cache to empty state
  28519. */
  28520. resetTextureCache(): void;
  28521. /**
  28522. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28523. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28524. * @returns true if engine is in deterministic lock step mode
  28525. */
  28526. isDeterministicLockStep(): boolean;
  28527. /**
  28528. * Gets the max steps when engine is running in deterministic lock step
  28529. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28530. * @returns the max steps
  28531. */
  28532. getLockstepMaxSteps(): number;
  28533. /**
  28534. * Gets an object containing information about the current webGL context
  28535. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28536. */
  28537. getGlInfo(): {
  28538. vendor: string;
  28539. renderer: string;
  28540. version: string;
  28541. };
  28542. /**
  28543. * Gets current aspect ratio
  28544. * @param camera defines the camera to use to get the aspect ratio
  28545. * @param useScreen defines if screen size must be used (or the current render target if any)
  28546. * @returns a number defining the aspect ratio
  28547. */
  28548. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28549. /**
  28550. * Gets current screen aspect ratio
  28551. * @returns a number defining the aspect ratio
  28552. */
  28553. getScreenAspectRatio(): number;
  28554. /**
  28555. * Gets the current render width
  28556. * @param useScreen defines if screen size must be used (or the current render target if any)
  28557. * @returns a number defining the current render width
  28558. */
  28559. getRenderWidth(useScreen?: boolean): number;
  28560. /**
  28561. * Gets the current render height
  28562. * @param useScreen defines if screen size must be used (or the current render target if any)
  28563. * @returns a number defining the current render height
  28564. */
  28565. getRenderHeight(useScreen?: boolean): number;
  28566. /**
  28567. * Gets the HTML canvas attached with the current webGL context
  28568. * @returns a HTML canvas
  28569. */
  28570. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28571. /**
  28572. * Gets the client rect of the HTML canvas attached with the current webGL context
  28573. * @returns a client rectanglee
  28574. */
  28575. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28576. /**
  28577. * Defines the hardware scaling level.
  28578. * By default the hardware scaling level is computed from the window device ratio.
  28579. * 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.
  28580. * @param level defines the level to use
  28581. */
  28582. setHardwareScalingLevel(level: number): void;
  28583. /**
  28584. * Gets the current hardware scaling level.
  28585. * By default the hardware scaling level is computed from the window device ratio.
  28586. * 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.
  28587. * @returns a number indicating the current hardware scaling level
  28588. */
  28589. getHardwareScalingLevel(): number;
  28590. /**
  28591. * Gets the list of loaded textures
  28592. * @returns an array containing all loaded textures
  28593. */
  28594. getLoadedTexturesCache(): InternalTexture[];
  28595. /**
  28596. * Gets the object containing all engine capabilities
  28597. * @returns the EngineCapabilities object
  28598. */
  28599. getCaps(): EngineCapabilities;
  28600. /**
  28601. * Gets the current depth function
  28602. * @returns a number defining the depth function
  28603. */
  28604. getDepthFunction(): Nullable<number>;
  28605. /**
  28606. * Sets the current depth function
  28607. * @param depthFunc defines the function to use
  28608. */
  28609. setDepthFunction(depthFunc: number): void;
  28610. /**
  28611. * Sets the current depth function to GREATER
  28612. */
  28613. setDepthFunctionToGreater(): void;
  28614. /**
  28615. * Sets the current depth function to GEQUAL
  28616. */
  28617. setDepthFunctionToGreaterOrEqual(): void;
  28618. /**
  28619. * Sets the current depth function to LESS
  28620. */
  28621. setDepthFunctionToLess(): void;
  28622. private _cachedStencilBuffer;
  28623. private _cachedStencilFunction;
  28624. private _cachedStencilMask;
  28625. private _cachedStencilOperationPass;
  28626. private _cachedStencilOperationFail;
  28627. private _cachedStencilOperationDepthFail;
  28628. private _cachedStencilReference;
  28629. /**
  28630. * Caches the the state of the stencil buffer
  28631. */
  28632. cacheStencilState(): void;
  28633. /**
  28634. * Restores the state of the stencil buffer
  28635. */
  28636. restoreStencilState(): void;
  28637. /**
  28638. * Sets the current depth function to LEQUAL
  28639. */
  28640. setDepthFunctionToLessOrEqual(): void;
  28641. /**
  28642. * Gets a boolean indicating if stencil buffer is enabled
  28643. * @returns the current stencil buffer state
  28644. */
  28645. getStencilBuffer(): boolean;
  28646. /**
  28647. * Enable or disable the stencil buffer
  28648. * @param enable defines if the stencil buffer must be enabled or disabled
  28649. */
  28650. setStencilBuffer(enable: boolean): void;
  28651. /**
  28652. * Gets the current stencil mask
  28653. * @returns a number defining the new stencil mask to use
  28654. */
  28655. getStencilMask(): number;
  28656. /**
  28657. * Sets the current stencil mask
  28658. * @param mask defines the new stencil mask to use
  28659. */
  28660. setStencilMask(mask: number): void;
  28661. /**
  28662. * Gets the current stencil function
  28663. * @returns a number defining the stencil function to use
  28664. */
  28665. getStencilFunction(): number;
  28666. /**
  28667. * Gets the current stencil reference value
  28668. * @returns a number defining the stencil reference value to use
  28669. */
  28670. getStencilFunctionReference(): number;
  28671. /**
  28672. * Gets the current stencil mask
  28673. * @returns a number defining the stencil mask to use
  28674. */
  28675. getStencilFunctionMask(): number;
  28676. /**
  28677. * Sets the current stencil function
  28678. * @param stencilFunc defines the new stencil function to use
  28679. */
  28680. setStencilFunction(stencilFunc: number): void;
  28681. /**
  28682. * Sets the current stencil reference
  28683. * @param reference defines the new stencil reference to use
  28684. */
  28685. setStencilFunctionReference(reference: number): void;
  28686. /**
  28687. * Sets the current stencil mask
  28688. * @param mask defines the new stencil mask to use
  28689. */
  28690. setStencilFunctionMask(mask: number): void;
  28691. /**
  28692. * Gets the current stencil operation when stencil fails
  28693. * @returns a number defining stencil operation to use when stencil fails
  28694. */
  28695. getStencilOperationFail(): number;
  28696. /**
  28697. * Gets the current stencil operation when depth fails
  28698. * @returns a number defining stencil operation to use when depth fails
  28699. */
  28700. getStencilOperationDepthFail(): number;
  28701. /**
  28702. * Gets the current stencil operation when stencil passes
  28703. * @returns a number defining stencil operation to use when stencil passes
  28704. */
  28705. getStencilOperationPass(): number;
  28706. /**
  28707. * Sets the stencil operation to use when stencil fails
  28708. * @param operation defines the stencil operation to use when stencil fails
  28709. */
  28710. setStencilOperationFail(operation: number): void;
  28711. /**
  28712. * Sets the stencil operation to use when depth fails
  28713. * @param operation defines the stencil operation to use when depth fails
  28714. */
  28715. setStencilOperationDepthFail(operation: number): void;
  28716. /**
  28717. * Sets the stencil operation to use when stencil passes
  28718. * @param operation defines the stencil operation to use when stencil passes
  28719. */
  28720. setStencilOperationPass(operation: number): void;
  28721. /**
  28722. * Sets a boolean indicating if the dithering state is enabled or disabled
  28723. * @param value defines the dithering state
  28724. */
  28725. setDitheringState(value: boolean): void;
  28726. /**
  28727. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28728. * @param value defines the rasterizer state
  28729. */
  28730. setRasterizerState(value: boolean): void;
  28731. /**
  28732. * stop executing a render loop function and remove it from the execution array
  28733. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28734. */
  28735. stopRenderLoop(renderFunction?: () => void): void;
  28736. /** @hidden */
  28737. _renderLoop(): void;
  28738. /**
  28739. * Register and execute a render loop. The engine can have more than one render function
  28740. * @param renderFunction defines the function to continuously execute
  28741. */
  28742. runRenderLoop(renderFunction: () => void): void;
  28743. /**
  28744. * Toggle full screen mode
  28745. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28746. */
  28747. switchFullscreen(requestPointerLock: boolean): void;
  28748. /**
  28749. * Enters full screen mode
  28750. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28751. */
  28752. enterFullscreen(requestPointerLock: boolean): void;
  28753. /**
  28754. * Exits full screen mode
  28755. */
  28756. exitFullscreen(): void;
  28757. /**
  28758. * Clear the current render buffer or the current render target (if any is set up)
  28759. * @param color defines the color to use
  28760. * @param backBuffer defines if the back buffer must be cleared
  28761. * @param depth defines if the depth buffer must be cleared
  28762. * @param stencil defines if the stencil buffer must be cleared
  28763. */
  28764. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28765. /**
  28766. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28767. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28768. * @param y defines the y-coordinate of the corner of the clear rectangle
  28769. * @param width defines the width of the clear rectangle
  28770. * @param height defines the height of the clear rectangle
  28771. * @param clearColor defines the clear color
  28772. */
  28773. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28774. /**
  28775. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28776. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28777. * @param y defines the y-coordinate of the corner of the clear rectangle
  28778. * @param width defines the width of the clear rectangle
  28779. * @param height defines the height of the clear rectangle
  28780. */
  28781. enableScissor(x: number, y: number, width: number, height: number): void;
  28782. /**
  28783. * Disable previously set scissor test rectangle
  28784. */
  28785. disableScissor(): void;
  28786. private _viewportCached;
  28787. /** @hidden */
  28788. _viewport(x: number, y: number, width: number, height: number): void;
  28789. /**
  28790. * Set the WebGL's viewport
  28791. * @param viewport defines the viewport element to be used
  28792. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28793. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28794. */
  28795. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28796. /**
  28797. * Directly set the WebGL Viewport
  28798. * @param x defines the x coordinate of the viewport (in screen space)
  28799. * @param y defines the y coordinate of the viewport (in screen space)
  28800. * @param width defines the width of the viewport (in screen space)
  28801. * @param height defines the height of the viewport (in screen space)
  28802. * @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
  28803. */
  28804. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28805. /**
  28806. * Begin a new frame
  28807. */
  28808. beginFrame(): void;
  28809. /**
  28810. * Enf the current frame
  28811. */
  28812. endFrame(): void;
  28813. /**
  28814. * Resize the view according to the canvas' size
  28815. */
  28816. resize(): void;
  28817. /**
  28818. * Force a specific size of the canvas
  28819. * @param width defines the new canvas' width
  28820. * @param height defines the new canvas' height
  28821. */
  28822. setSize(width: number, height: number): void;
  28823. /**
  28824. * Binds the frame buffer to the specified texture.
  28825. * @param texture The texture to render to or null for the default canvas
  28826. * @param faceIndex The face of the texture to render to in case of cube texture
  28827. * @param requiredWidth The width of the target to render to
  28828. * @param requiredHeight The height of the target to render to
  28829. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28830. * @param depthStencilTexture The depth stencil texture to use to render
  28831. * @param lodLevel defines le lod level to bind to the frame buffer
  28832. */
  28833. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28834. /** @hidden */
  28835. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28836. /**
  28837. * Unbind the current render target texture from the webGL context
  28838. * @param texture defines the render target texture to unbind
  28839. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28840. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28841. */
  28842. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28843. /**
  28844. * Force the mipmap generation for the given render target texture
  28845. * @param texture defines the render target texture to use
  28846. */
  28847. generateMipMapsForCubemap(texture: InternalTexture): void;
  28848. /**
  28849. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28850. */
  28851. flushFramebuffer(): void;
  28852. /**
  28853. * Unbind the current render target and bind the default framebuffer
  28854. */
  28855. restoreDefaultFramebuffer(): void;
  28856. /**
  28857. * Create an uniform buffer
  28858. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28859. * @param elements defines the content of the uniform buffer
  28860. * @returns the webGL uniform buffer
  28861. */
  28862. createUniformBuffer(elements: FloatArray): DataBuffer;
  28863. /**
  28864. * Create a dynamic uniform buffer
  28865. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28866. * @param elements defines the content of the uniform buffer
  28867. * @returns the webGL uniform buffer
  28868. */
  28869. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28870. /**
  28871. * Update an existing uniform buffer
  28872. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28873. * @param uniformBuffer defines the target uniform buffer
  28874. * @param elements defines the content to update
  28875. * @param offset defines the offset in the uniform buffer where update should start
  28876. * @param count defines the size of the data to update
  28877. */
  28878. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28879. private _resetVertexBufferBinding;
  28880. /**
  28881. * Creates a vertex buffer
  28882. * @param data the data for the vertex buffer
  28883. * @returns the new WebGL static buffer
  28884. */
  28885. createVertexBuffer(data: DataArray): DataBuffer;
  28886. /**
  28887. * Creates a dynamic vertex buffer
  28888. * @param data the data for the dynamic vertex buffer
  28889. * @returns the new WebGL dynamic buffer
  28890. */
  28891. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28892. /**
  28893. * Update a dynamic index buffer
  28894. * @param indexBuffer defines the target index buffer
  28895. * @param indices defines the data to update
  28896. * @param offset defines the offset in the target index buffer where update should start
  28897. */
  28898. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28899. /**
  28900. * Updates a dynamic vertex buffer.
  28901. * @param vertexBuffer the vertex buffer to update
  28902. * @param data the data used to update the vertex buffer
  28903. * @param byteOffset the byte offset of the data
  28904. * @param byteLength the byte length of the data
  28905. */
  28906. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28907. private _resetIndexBufferBinding;
  28908. /**
  28909. * Creates a new index buffer
  28910. * @param indices defines the content of the index buffer
  28911. * @param updatable defines if the index buffer must be updatable
  28912. * @returns a new webGL buffer
  28913. */
  28914. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28915. /**
  28916. * Bind a webGL buffer to the webGL context
  28917. * @param buffer defines the buffer to bind
  28918. */
  28919. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28920. /**
  28921. * Bind an uniform buffer to the current webGL context
  28922. * @param buffer defines the buffer to bind
  28923. */
  28924. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28925. /**
  28926. * Bind a buffer to the current webGL context at a given location
  28927. * @param buffer defines the buffer to bind
  28928. * @param location defines the index where to bind the buffer
  28929. */
  28930. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28931. /**
  28932. * Bind a specific block at a given index in a specific shader program
  28933. * @param pipelineContext defines the pipeline context to use
  28934. * @param blockName defines the block name
  28935. * @param index defines the index where to bind the block
  28936. */
  28937. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28938. private bindIndexBuffer;
  28939. private bindBuffer;
  28940. /**
  28941. * update the bound buffer with the given data
  28942. * @param data defines the data to update
  28943. */
  28944. updateArrayBuffer(data: Float32Array): void;
  28945. private _vertexAttribPointer;
  28946. private _bindIndexBufferWithCache;
  28947. private _bindVertexBuffersAttributes;
  28948. /**
  28949. * Records a vertex array object
  28950. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28951. * @param vertexBuffers defines the list of vertex buffers to store
  28952. * @param indexBuffer defines the index buffer to store
  28953. * @param effect defines the effect to store
  28954. * @returns the new vertex array object
  28955. */
  28956. recordVertexArrayObject(vertexBuffers: {
  28957. [key: string]: VertexBuffer;
  28958. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28959. /**
  28960. * Bind a specific vertex array object
  28961. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28962. * @param vertexArrayObject defines the vertex array object to bind
  28963. * @param indexBuffer defines the index buffer to bind
  28964. */
  28965. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28966. /**
  28967. * Bind webGl buffers directly to the webGL context
  28968. * @param vertexBuffer defines the vertex buffer to bind
  28969. * @param indexBuffer defines the index buffer to bind
  28970. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28971. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28972. * @param effect defines the effect associated with the vertex buffer
  28973. */
  28974. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28975. private _unbindVertexArrayObject;
  28976. /**
  28977. * Bind a list of vertex buffers to the webGL context
  28978. * @param vertexBuffers defines the list of vertex buffers to bind
  28979. * @param indexBuffer defines the index buffer to bind
  28980. * @param effect defines the effect associated with the vertex buffers
  28981. */
  28982. bindBuffers(vertexBuffers: {
  28983. [key: string]: Nullable<VertexBuffer>;
  28984. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28985. /**
  28986. * Unbind all instance attributes
  28987. */
  28988. unbindInstanceAttributes(): void;
  28989. /**
  28990. * Release and free the memory of a vertex array object
  28991. * @param vao defines the vertex array object to delete
  28992. */
  28993. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28994. /** @hidden */
  28995. _releaseBuffer(buffer: DataBuffer): boolean;
  28996. /**
  28997. * Creates a webGL buffer to use with instanciation
  28998. * @param capacity defines the size of the buffer
  28999. * @returns the webGL buffer
  29000. */
  29001. createInstancesBuffer(capacity: number): DataBuffer;
  29002. /**
  29003. * Delete a webGL buffer used with instanciation
  29004. * @param buffer defines the webGL buffer to delete
  29005. */
  29006. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29007. /**
  29008. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29009. * @param instancesBuffer defines the webGL buffer to update and bind
  29010. * @param data defines the data to store in the buffer
  29011. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29012. */
  29013. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29014. /**
  29015. * Apply all cached states (depth, culling, stencil and alpha)
  29016. */
  29017. applyStates(): void;
  29018. /**
  29019. * Send a draw order
  29020. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29021. * @param indexStart defines the starting index
  29022. * @param indexCount defines the number of index to draw
  29023. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29024. */
  29025. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29026. /**
  29027. * Draw a list of points
  29028. * @param verticesStart defines the index of first vertex to draw
  29029. * @param verticesCount defines the count of vertices to draw
  29030. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29031. */
  29032. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29033. /**
  29034. * Draw a list of unindexed primitives
  29035. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29036. * @param verticesStart defines the index of first vertex to draw
  29037. * @param verticesCount defines the count of vertices to draw
  29038. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29039. */
  29040. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29041. /**
  29042. * Draw a list of indexed primitives
  29043. * @param fillMode defines the primitive to use
  29044. * @param indexStart defines the starting index
  29045. * @param indexCount defines the number of index to draw
  29046. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29047. */
  29048. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29049. /**
  29050. * Draw a list of unindexed primitives
  29051. * @param fillMode defines the primitive to use
  29052. * @param verticesStart defines the index of first vertex to draw
  29053. * @param verticesCount defines the count of vertices to draw
  29054. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29055. */
  29056. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29057. private _drawMode;
  29058. /** @hidden */
  29059. _releaseEffect(effect: Effect): void;
  29060. /** @hidden */
  29061. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29062. /**
  29063. * Create a new effect (used to store vertex/fragment shaders)
  29064. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29065. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29066. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29067. * @param samplers defines an array of string used to represent textures
  29068. * @param defines defines the string containing the defines to use to compile the shaders
  29069. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29070. * @param onCompiled defines a function to call when the effect creation is successful
  29071. * @param onError defines a function to call when the effect creation has failed
  29072. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29073. * @returns the new Effect
  29074. */
  29075. 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;
  29076. private _compileShader;
  29077. private _compileRawShader;
  29078. /**
  29079. * Directly creates a webGL program
  29080. * @param pipelineContext defines the pipeline context to attach to
  29081. * @param vertexCode defines the vertex shader code to use
  29082. * @param fragmentCode defines the fragment shader code to use
  29083. * @param context defines the webGL context to use (if not set, the current one will be used)
  29084. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29085. * @returns the new webGL program
  29086. */
  29087. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29088. /**
  29089. * Creates a webGL program
  29090. * @param pipelineContext defines the pipeline context to attach to
  29091. * @param vertexCode defines the vertex shader code to use
  29092. * @param fragmentCode defines the fragment shader code to use
  29093. * @param defines defines the string containing the defines to use to compile the shaders
  29094. * @param context defines the webGL context to use (if not set, the current one will be used)
  29095. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29096. * @returns the new webGL program
  29097. */
  29098. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29099. /**
  29100. * Creates a new pipeline context
  29101. * @returns the new pipeline
  29102. */
  29103. createPipelineContext(): WebGLPipelineContext;
  29104. private _createShaderProgram;
  29105. private _finalizePipelineContext;
  29106. /** @hidden */
  29107. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29108. /** @hidden */
  29109. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29110. /** @hidden */
  29111. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29112. /**
  29113. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29114. * @param pipelineContext defines the pipeline context to use
  29115. * @param uniformsNames defines the list of uniform names
  29116. * @returns an array of webGL uniform locations
  29117. */
  29118. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29119. /**
  29120. * Gets the lsit of active attributes for a given webGL program
  29121. * @param pipelineContext defines the pipeline context to use
  29122. * @param attributesNames defines the list of attribute names to get
  29123. * @returns an array of indices indicating the offset of each attribute
  29124. */
  29125. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29126. /**
  29127. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29128. * @param effect defines the effect to activate
  29129. */
  29130. enableEffect(effect: Nullable<Effect>): void;
  29131. /**
  29132. * Set the value of an uniform to an array of int32
  29133. * @param uniform defines the webGL uniform location where to store the value
  29134. * @param array defines the array of int32 to store
  29135. */
  29136. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29137. /**
  29138. * Set the value of an uniform to an array of int32 (stored as vec2)
  29139. * @param uniform defines the webGL uniform location where to store the value
  29140. * @param array defines the array of int32 to store
  29141. */
  29142. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29143. /**
  29144. * Set the value of an uniform to an array of int32 (stored as vec3)
  29145. * @param uniform defines the webGL uniform location where to store the value
  29146. * @param array defines the array of int32 to store
  29147. */
  29148. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29149. /**
  29150. * Set the value of an uniform to an array of int32 (stored as vec4)
  29151. * @param uniform defines the webGL uniform location where to store the value
  29152. * @param array defines the array of int32 to store
  29153. */
  29154. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29155. /**
  29156. * Set the value of an uniform to an array of float32
  29157. * @param uniform defines the webGL uniform location where to store the value
  29158. * @param array defines the array of float32 to store
  29159. */
  29160. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29161. /**
  29162. * Set the value of an uniform to an array of float32 (stored as vec2)
  29163. * @param uniform defines the webGL uniform location where to store the value
  29164. * @param array defines the array of float32 to store
  29165. */
  29166. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29167. /**
  29168. * Set the value of an uniform to an array of float32 (stored as vec3)
  29169. * @param uniform defines the webGL uniform location where to store the value
  29170. * @param array defines the array of float32 to store
  29171. */
  29172. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29173. /**
  29174. * Set the value of an uniform to an array of float32 (stored as vec4)
  29175. * @param uniform defines the webGL uniform location where to store the value
  29176. * @param array defines the array of float32 to store
  29177. */
  29178. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29179. /**
  29180. * Set the value of an uniform to an array of number
  29181. * @param uniform defines the webGL uniform location where to store the value
  29182. * @param array defines the array of number to store
  29183. */
  29184. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29185. /**
  29186. * Set the value of an uniform to an array of number (stored as vec2)
  29187. * @param uniform defines the webGL uniform location where to store the value
  29188. * @param array defines the array of number to store
  29189. */
  29190. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29191. /**
  29192. * Set the value of an uniform to an array of number (stored as vec3)
  29193. * @param uniform defines the webGL uniform location where to store the value
  29194. * @param array defines the array of number to store
  29195. */
  29196. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29197. /**
  29198. * Set the value of an uniform to an array of number (stored as vec4)
  29199. * @param uniform defines the webGL uniform location where to store the value
  29200. * @param array defines the array of number to store
  29201. */
  29202. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29203. /**
  29204. * Set the value of an uniform to an array of float32 (stored as matrices)
  29205. * @param uniform defines the webGL uniform location where to store the value
  29206. * @param matrices defines the array of float32 to store
  29207. */
  29208. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29209. /**
  29210. * Set the value of an uniform to a matrix
  29211. * @param uniform defines the webGL uniform location where to store the value
  29212. * @param matrix defines the matrix to store
  29213. */
  29214. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29215. /**
  29216. * Set the value of an uniform to a matrix (3x3)
  29217. * @param uniform defines the webGL uniform location where to store the value
  29218. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29219. */
  29220. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29221. /**
  29222. * Set the value of an uniform to a matrix (2x2)
  29223. * @param uniform defines the webGL uniform location where to store the value
  29224. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29225. */
  29226. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29227. /**
  29228. * Set the value of an uniform to a number (int)
  29229. * @param uniform defines the webGL uniform location where to store the value
  29230. * @param value defines the int number to store
  29231. */
  29232. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29233. /**
  29234. * Set the value of an uniform to a number (float)
  29235. * @param uniform defines the webGL uniform location where to store the value
  29236. * @param value defines the float number to store
  29237. */
  29238. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29239. /**
  29240. * Set the value of an uniform to a vec2
  29241. * @param uniform defines the webGL uniform location where to store the value
  29242. * @param x defines the 1st component of the value
  29243. * @param y defines the 2nd component of the value
  29244. */
  29245. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29246. /**
  29247. * Set the value of an uniform to a vec3
  29248. * @param uniform defines the webGL uniform location where to store the value
  29249. * @param x defines the 1st component of the value
  29250. * @param y defines the 2nd component of the value
  29251. * @param z defines the 3rd component of the value
  29252. */
  29253. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29254. /**
  29255. * Set the value of an uniform to a boolean
  29256. * @param uniform defines the webGL uniform location where to store the value
  29257. * @param bool defines the boolean to store
  29258. */
  29259. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29260. /**
  29261. * Set the value of an uniform to a vec4
  29262. * @param uniform defines the webGL uniform location where to store the value
  29263. * @param x defines the 1st component of the value
  29264. * @param y defines the 2nd component of the value
  29265. * @param z defines the 3rd component of the value
  29266. * @param w defines the 4th component of the value
  29267. */
  29268. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29269. /**
  29270. * Set the value of an uniform to a Color3
  29271. * @param uniform defines the webGL uniform location where to store the value
  29272. * @param color3 defines the color to store
  29273. */
  29274. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29275. /**
  29276. * Set the value of an uniform to a Color3 and an alpha value
  29277. * @param uniform defines the webGL uniform location where to store the value
  29278. * @param color3 defines the color to store
  29279. * @param alpha defines the alpha component to store
  29280. */
  29281. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29282. /**
  29283. * Sets a Color4 on a uniform variable
  29284. * @param uniform defines the uniform location
  29285. * @param color4 defines the value to be set
  29286. */
  29287. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29288. /**
  29289. * Set various states to the webGL context
  29290. * @param culling defines backface culling state
  29291. * @param zOffset defines the value to apply to zOffset (0 by default)
  29292. * @param force defines if states must be applied even if cache is up to date
  29293. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29294. */
  29295. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29296. /**
  29297. * Set the z offset to apply to current rendering
  29298. * @param value defines the offset to apply
  29299. */
  29300. setZOffset(value: number): void;
  29301. /**
  29302. * Gets the current value of the zOffset
  29303. * @returns the current zOffset state
  29304. */
  29305. getZOffset(): number;
  29306. /**
  29307. * Enable or disable depth buffering
  29308. * @param enable defines the state to set
  29309. */
  29310. setDepthBuffer(enable: boolean): void;
  29311. /**
  29312. * Gets a boolean indicating if depth writing is enabled
  29313. * @returns the current depth writing state
  29314. */
  29315. getDepthWrite(): boolean;
  29316. /**
  29317. * Enable or disable depth writing
  29318. * @param enable defines the state to set
  29319. */
  29320. setDepthWrite(enable: boolean): void;
  29321. /**
  29322. * Enable or disable color writing
  29323. * @param enable defines the state to set
  29324. */
  29325. setColorWrite(enable: boolean): void;
  29326. /**
  29327. * Gets a boolean indicating if color writing is enabled
  29328. * @returns the current color writing state
  29329. */
  29330. getColorWrite(): boolean;
  29331. /**
  29332. * Sets alpha constants used by some alpha blending modes
  29333. * @param r defines the red component
  29334. * @param g defines the green component
  29335. * @param b defines the blue component
  29336. * @param a defines the alpha component
  29337. */
  29338. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29339. /**
  29340. * Sets the current alpha mode
  29341. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29342. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29343. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29344. */
  29345. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29346. /**
  29347. * Gets the current alpha mode
  29348. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29349. * @returns the current alpha mode
  29350. */
  29351. getAlphaMode(): number;
  29352. /**
  29353. * Clears the list of texture accessible through engine.
  29354. * This can help preventing texture load conflict due to name collision.
  29355. */
  29356. clearInternalTexturesCache(): void;
  29357. /**
  29358. * Force the entire cache to be cleared
  29359. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29360. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29361. */
  29362. wipeCaches(bruteForce?: boolean): void;
  29363. /**
  29364. * Set the compressed texture format to use, based on the formats you have, and the formats
  29365. * supported by the hardware / browser.
  29366. *
  29367. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29368. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29369. * to API arguments needed to compressed textures. This puts the burden on the container
  29370. * generator to house the arcane code for determining these for current & future formats.
  29371. *
  29372. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29373. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29374. *
  29375. * Note: The result of this call is not taken into account when a texture is base64.
  29376. *
  29377. * @param formatsAvailable defines the list of those format families you have created
  29378. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29379. *
  29380. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29381. * @returns The extension selected.
  29382. */
  29383. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29384. /** @hidden */
  29385. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29386. min: number;
  29387. mag: number;
  29388. };
  29389. /** @hidden */
  29390. _createTexture(): WebGLTexture;
  29391. /**
  29392. * Usually called from Texture.ts.
  29393. * Passed information to create a WebGLTexture
  29394. * @param urlArg defines a value which contains one of the following:
  29395. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29396. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29397. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29398. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29399. * @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)
  29400. * @param scene needed for loading to the correct scene
  29401. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29402. * @param onLoad optional callback to be called upon successful completion
  29403. * @param onError optional callback to be called upon failure
  29404. * @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
  29405. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29406. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29407. * @param forcedExtension defines the extension to use to pick the right loader
  29408. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29409. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29410. */
  29411. 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;
  29412. private _rescaleTexture;
  29413. private _unpackFlipYCached;
  29414. /**
  29415. * In case you are sharing the context with other applications, it might
  29416. * be interested to not cache the unpack flip y state to ensure a consistent
  29417. * value would be set.
  29418. */
  29419. enableUnpackFlipYCached: boolean;
  29420. /** @hidden */
  29421. _unpackFlipY(value: boolean): void;
  29422. /** @hidden */
  29423. _getUnpackAlignement(): number;
  29424. /**
  29425. * Creates a dynamic texture
  29426. * @param width defines the width of the texture
  29427. * @param height defines the height of the texture
  29428. * @param generateMipMaps defines if the engine should generate the mip levels
  29429. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29430. * @returns the dynamic texture inside an InternalTexture
  29431. */
  29432. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29433. /**
  29434. * Update the sampling mode of a given texture
  29435. * @param samplingMode defines the required sampling mode
  29436. * @param texture defines the texture to update
  29437. */
  29438. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29439. /**
  29440. * Update the content of a dynamic texture
  29441. * @param texture defines the texture to update
  29442. * @param canvas defines the canvas containing the source
  29443. * @param invertY defines if data must be stored with Y axis inverted
  29444. * @param premulAlpha defines if alpha is stored as premultiplied
  29445. * @param format defines the format of the data
  29446. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29447. */
  29448. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29449. /**
  29450. * Update a video texture
  29451. * @param texture defines the texture to update
  29452. * @param video defines the video element to use
  29453. * @param invertY defines if data must be stored with Y axis inverted
  29454. */
  29455. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29456. /**
  29457. * Updates a depth texture Comparison Mode and Function.
  29458. * If the comparison Function is equal to 0, the mode will be set to none.
  29459. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29460. * @param texture The texture to set the comparison function for
  29461. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29462. */
  29463. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29464. /** @hidden */
  29465. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29466. width: number;
  29467. height: number;
  29468. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29469. /**
  29470. * Creates a depth stencil texture.
  29471. * This is only available in WebGL 2 or with the depth texture extension available.
  29472. * @param size The size of face edge in the texture.
  29473. * @param options The options defining the texture.
  29474. * @returns The texture
  29475. */
  29476. createDepthStencilTexture(size: number | {
  29477. width: number;
  29478. height: number;
  29479. }, options: DepthTextureCreationOptions): InternalTexture;
  29480. /**
  29481. * Creates a depth stencil texture.
  29482. * This is only available in WebGL 2 or with the depth texture extension available.
  29483. * @param size The size of face edge in the texture.
  29484. * @param options The options defining the texture.
  29485. * @returns The texture
  29486. */
  29487. private _createDepthStencilTexture;
  29488. /**
  29489. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29490. * @param renderTarget The render target to set the frame buffer for
  29491. */
  29492. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29493. /**
  29494. * Creates a new render target texture
  29495. * @param size defines the size of the texture
  29496. * @param options defines the options used to create the texture
  29497. * @returns a new render target texture stored in an InternalTexture
  29498. */
  29499. createRenderTargetTexture(size: number | {
  29500. width: number;
  29501. height: number;
  29502. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29503. /** @hidden */
  29504. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29505. /**
  29506. * Updates the sample count of a render target texture
  29507. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29508. * @param texture defines the texture to update
  29509. * @param samples defines the sample count to set
  29510. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29511. */
  29512. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29513. /** @hidden */
  29514. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29515. /** @hidden */
  29516. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29517. /** @hidden */
  29518. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29519. /** @hidden */
  29520. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29521. /**
  29522. * @hidden
  29523. */
  29524. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29525. private _prepareWebGLTextureContinuation;
  29526. private _prepareWebGLTexture;
  29527. /** @hidden */
  29528. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29529. /** @hidden */
  29530. _releaseFramebufferObjects(texture: InternalTexture): void;
  29531. /** @hidden */
  29532. _releaseTexture(texture: InternalTexture): void;
  29533. private setProgram;
  29534. private _boundUniforms;
  29535. /**
  29536. * Binds an effect to the webGL context
  29537. * @param effect defines the effect to bind
  29538. */
  29539. bindSamplers(effect: Effect): void;
  29540. private _activateCurrentTexture;
  29541. /** @hidden */
  29542. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29543. /** @hidden */
  29544. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29545. /**
  29546. * Sets a texture to the webGL context from a postprocess
  29547. * @param channel defines the channel to use
  29548. * @param postProcess defines the source postprocess
  29549. */
  29550. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29551. /**
  29552. * Binds the output of the passed in post process to the texture channel specified
  29553. * @param channel The channel the texture should be bound to
  29554. * @param postProcess The post process which's output should be bound
  29555. */
  29556. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29557. /**
  29558. * Unbind all textures from the webGL context
  29559. */
  29560. unbindAllTextures(): void;
  29561. /**
  29562. * Sets a texture to the according uniform.
  29563. * @param channel The texture channel
  29564. * @param uniform The uniform to set
  29565. * @param texture The texture to apply
  29566. */
  29567. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29568. /**
  29569. * Sets a depth stencil texture from a render target to the according uniform.
  29570. * @param channel The texture channel
  29571. * @param uniform The uniform to set
  29572. * @param texture The render target texture containing the depth stencil texture to apply
  29573. */
  29574. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29575. private _bindSamplerUniformToChannel;
  29576. private _getTextureWrapMode;
  29577. private _setTexture;
  29578. /**
  29579. * Sets an array of texture to the webGL context
  29580. * @param channel defines the channel where the texture array must be set
  29581. * @param uniform defines the associated uniform location
  29582. * @param textures defines the array of textures to bind
  29583. */
  29584. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29585. /** @hidden */
  29586. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29587. private _setTextureParameterFloat;
  29588. private _setTextureParameterInteger;
  29589. /**
  29590. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29591. * @param x defines the x coordinate of the rectangle where pixels must be read
  29592. * @param y defines the y coordinate of the rectangle where pixels must be read
  29593. * @param width defines the width of the rectangle where pixels must be read
  29594. * @param height defines the height of the rectangle where pixels must be read
  29595. * @returns a Uint8Array containing RGBA colors
  29596. */
  29597. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29598. /**
  29599. * Add an externaly attached data from its key.
  29600. * This method call will fail and return false, if such key already exists.
  29601. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29602. * @param key the unique key that identifies the data
  29603. * @param data the data object to associate to the key for this Engine instance
  29604. * @return true if no such key were already present and the data was added successfully, false otherwise
  29605. */
  29606. addExternalData<T>(key: string, data: T): boolean;
  29607. /**
  29608. * Get an externaly attached data from its key
  29609. * @param key the unique key that identifies the data
  29610. * @return the associated data, if present (can be null), or undefined if not present
  29611. */
  29612. getExternalData<T>(key: string): T;
  29613. /**
  29614. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29615. * @param key the unique key that identifies the data
  29616. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29617. * @return the associated data, can be null if the factory returned null.
  29618. */
  29619. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29620. /**
  29621. * Remove an externaly attached data from the Engine instance
  29622. * @param key the unique key that identifies the data
  29623. * @return true if the data was successfully removed, false if it doesn't exist
  29624. */
  29625. removeExternalData(key: string): boolean;
  29626. /**
  29627. * Unbind all vertex attributes from the webGL context
  29628. */
  29629. unbindAllAttributes(): void;
  29630. /**
  29631. * 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
  29632. */
  29633. releaseEffects(): void;
  29634. /**
  29635. * Dispose and release all associated resources
  29636. */
  29637. dispose(): void;
  29638. /**
  29639. * Display the loading screen
  29640. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29641. */
  29642. displayLoadingUI(): void;
  29643. /**
  29644. * Hide the loading screen
  29645. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29646. */
  29647. hideLoadingUI(): void;
  29648. /**
  29649. * Gets the current loading screen object
  29650. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29651. */
  29652. /**
  29653. * Sets the current loading screen object
  29654. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29655. */
  29656. loadingScreen: ILoadingScreen;
  29657. /**
  29658. * Sets the current loading screen text
  29659. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29660. */
  29661. loadingUIText: string;
  29662. /**
  29663. * Sets the current loading screen background color
  29664. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29665. */
  29666. loadingUIBackgroundColor: string;
  29667. /**
  29668. * Attach a new callback raised when context lost event is fired
  29669. * @param callback defines the callback to call
  29670. */
  29671. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29672. /**
  29673. * Attach a new callback raised when context restored event is fired
  29674. * @param callback defines the callback to call
  29675. */
  29676. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29677. /**
  29678. * Gets the source code of the vertex shader associated with a specific webGL program
  29679. * @param program defines the program to use
  29680. * @returns a string containing the source code of the vertex shader associated with the program
  29681. */
  29682. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29683. /**
  29684. * Gets the source code of the fragment shader associated with a specific webGL program
  29685. * @param program defines the program to use
  29686. * @returns a string containing the source code of the fragment shader associated with the program
  29687. */
  29688. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29689. /**
  29690. * Get the current error code of the webGL context
  29691. * @returns the error code
  29692. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29693. */
  29694. getError(): number;
  29695. /**
  29696. * Gets the current framerate
  29697. * @returns a number representing the framerate
  29698. */
  29699. getFps(): number;
  29700. /**
  29701. * Gets the time spent between current and previous frame
  29702. * @returns a number representing the delta time in ms
  29703. */
  29704. getDeltaTime(): number;
  29705. private _measureFps;
  29706. /** @hidden */
  29707. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29708. private _canRenderToFloatFramebuffer;
  29709. private _canRenderToHalfFloatFramebuffer;
  29710. private _canRenderToFramebuffer;
  29711. /** @hidden */
  29712. _getWebGLTextureType(type: number): number;
  29713. /** @hidden */
  29714. _getInternalFormat(format: number): number;
  29715. /** @hidden */
  29716. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29717. /** @hidden */
  29718. _getRGBAMultiSampleBufferFormat(type: number): number;
  29719. /** @hidden */
  29720. _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;
  29721. /** @hidden */
  29722. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29723. /**
  29724. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29725. * @returns true if the engine can be created
  29726. * @ignorenaming
  29727. */
  29728. static isSupported(): boolean;
  29729. }
  29730. }
  29731. declare module "babylonjs/Materials/effect" {
  29732. import { Observable } from "babylonjs/Misc/observable";
  29733. import { Nullable } from "babylonjs/types";
  29734. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29735. import { IDisposable } from "babylonjs/scene";
  29736. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29737. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29738. import { Engine } from "babylonjs/Engines/engine";
  29739. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29741. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29742. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29744. /**
  29745. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29746. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29747. */
  29748. export class EffectFallbacks {
  29749. private _defines;
  29750. private _currentRank;
  29751. private _maxRank;
  29752. private _mesh;
  29753. /**
  29754. * Removes the fallback from the bound mesh.
  29755. */
  29756. unBindMesh(): void;
  29757. /**
  29758. * Adds a fallback on the specified property.
  29759. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29760. * @param define The name of the define in the shader
  29761. */
  29762. addFallback(rank: number, define: string): void;
  29763. /**
  29764. * Sets the mesh to use CPU skinning when needing to fallback.
  29765. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29766. * @param mesh The mesh to use the fallbacks.
  29767. */
  29768. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29769. /**
  29770. * Checks to see if more fallbacks are still availible.
  29771. */
  29772. readonly isMoreFallbacks: boolean;
  29773. /**
  29774. * Removes the defines that shoould be removed when falling back.
  29775. * @param currentDefines defines the current define statements for the shader.
  29776. * @param effect defines the current effect we try to compile
  29777. * @returns The resulting defines with defines of the current rank removed.
  29778. */
  29779. reduce(currentDefines: string, effect: Effect): string;
  29780. }
  29781. /**
  29782. * Options to be used when creating an effect.
  29783. */
  29784. export class EffectCreationOptions {
  29785. /**
  29786. * Atrributes that will be used in the shader.
  29787. */
  29788. attributes: string[];
  29789. /**
  29790. * Uniform varible names that will be set in the shader.
  29791. */
  29792. uniformsNames: string[];
  29793. /**
  29794. * Uniform buffer varible names that will be set in the shader.
  29795. */
  29796. uniformBuffersNames: string[];
  29797. /**
  29798. * Sampler texture variable names that will be set in the shader.
  29799. */
  29800. samplers: string[];
  29801. /**
  29802. * Define statements that will be set in the shader.
  29803. */
  29804. defines: any;
  29805. /**
  29806. * Possible fallbacks for this effect to improve performance when needed.
  29807. */
  29808. fallbacks: Nullable<EffectFallbacks>;
  29809. /**
  29810. * Callback that will be called when the shader is compiled.
  29811. */
  29812. onCompiled: Nullable<(effect: Effect) => void>;
  29813. /**
  29814. * Callback that will be called if an error occurs during shader compilation.
  29815. */
  29816. onError: Nullable<(effect: Effect, errors: string) => void>;
  29817. /**
  29818. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29819. */
  29820. indexParameters: any;
  29821. /**
  29822. * Max number of lights that can be used in the shader.
  29823. */
  29824. maxSimultaneousLights: number;
  29825. /**
  29826. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29827. */
  29828. transformFeedbackVaryings: Nullable<string[]>;
  29829. }
  29830. /**
  29831. * Effect containing vertex and fragment shader that can be executed on an object.
  29832. */
  29833. export class Effect implements IDisposable {
  29834. /**
  29835. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29836. */
  29837. static ShadersRepository: string;
  29838. /**
  29839. * Name of the effect.
  29840. */
  29841. name: any;
  29842. /**
  29843. * String container all the define statements that should be set on the shader.
  29844. */
  29845. defines: string;
  29846. /**
  29847. * Callback that will be called when the shader is compiled.
  29848. */
  29849. onCompiled: Nullable<(effect: Effect) => void>;
  29850. /**
  29851. * Callback that will be called if an error occurs during shader compilation.
  29852. */
  29853. onError: Nullable<(effect: Effect, errors: string) => void>;
  29854. /**
  29855. * Callback that will be called when effect is bound.
  29856. */
  29857. onBind: Nullable<(effect: Effect) => void>;
  29858. /**
  29859. * Unique ID of the effect.
  29860. */
  29861. uniqueId: number;
  29862. /**
  29863. * Observable that will be called when the shader is compiled.
  29864. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29865. */
  29866. onCompileObservable: Observable<Effect>;
  29867. /**
  29868. * Observable that will be called if an error occurs during shader compilation.
  29869. */
  29870. onErrorObservable: Observable<Effect>;
  29871. /** @hidden */
  29872. _onBindObservable: Nullable<Observable<Effect>>;
  29873. /**
  29874. * Observable that will be called when effect is bound.
  29875. */
  29876. readonly onBindObservable: Observable<Effect>;
  29877. /** @hidden */
  29878. _bonesComputationForcedToCPU: boolean;
  29879. private static _uniqueIdSeed;
  29880. private _engine;
  29881. private _uniformBuffersNames;
  29882. private _uniformsNames;
  29883. private _samplerList;
  29884. private _samplers;
  29885. private _isReady;
  29886. private _compilationError;
  29887. private _attributesNames;
  29888. private _attributes;
  29889. private _uniforms;
  29890. /**
  29891. * Key for the effect.
  29892. * @hidden
  29893. */
  29894. _key: string;
  29895. private _indexParameters;
  29896. private _fallbacks;
  29897. private _vertexSourceCode;
  29898. private _fragmentSourceCode;
  29899. private _vertexSourceCodeOverride;
  29900. private _fragmentSourceCodeOverride;
  29901. private _transformFeedbackVaryings;
  29902. /**
  29903. * Compiled shader to webGL program.
  29904. * @hidden
  29905. */
  29906. _pipelineContext: IPipelineContext;
  29907. private _valueCache;
  29908. private static _baseCache;
  29909. /**
  29910. * Instantiates an effect.
  29911. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29912. * @param baseName Name of the effect.
  29913. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29914. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29915. * @param samplers List of sampler variables that will be passed to the shader.
  29916. * @param engine Engine to be used to render the effect
  29917. * @param defines Define statements to be added to the shader.
  29918. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29919. * @param onCompiled Callback that will be called when the shader is compiled.
  29920. * @param onError Callback that will be called if an error occurs during shader compilation.
  29921. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29922. */
  29923. 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);
  29924. /**
  29925. * Unique key for this effect
  29926. */
  29927. readonly key: string;
  29928. /**
  29929. * If the effect has been compiled and prepared.
  29930. * @returns if the effect is compiled and prepared.
  29931. */
  29932. isReady(): boolean;
  29933. /**
  29934. * The engine the effect was initialized with.
  29935. * @returns the engine.
  29936. */
  29937. getEngine(): Engine;
  29938. /**
  29939. * The pipeline context for this effect
  29940. * @returns the associated pipeline context
  29941. */
  29942. getPipelineContext(): IPipelineContext;
  29943. /**
  29944. * The set of names of attribute variables for the shader.
  29945. * @returns An array of attribute names.
  29946. */
  29947. getAttributesNames(): string[];
  29948. /**
  29949. * Returns the attribute at the given index.
  29950. * @param index The index of the attribute.
  29951. * @returns The location of the attribute.
  29952. */
  29953. getAttributeLocation(index: number): number;
  29954. /**
  29955. * Returns the attribute based on the name of the variable.
  29956. * @param name of the attribute to look up.
  29957. * @returns the attribute location.
  29958. */
  29959. getAttributeLocationByName(name: string): number;
  29960. /**
  29961. * The number of attributes.
  29962. * @returns the numnber of attributes.
  29963. */
  29964. getAttributesCount(): number;
  29965. /**
  29966. * Gets the index of a uniform variable.
  29967. * @param uniformName of the uniform to look up.
  29968. * @returns the index.
  29969. */
  29970. getUniformIndex(uniformName: string): number;
  29971. /**
  29972. * Returns the attribute based on the name of the variable.
  29973. * @param uniformName of the uniform to look up.
  29974. * @returns the location of the uniform.
  29975. */
  29976. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29977. /**
  29978. * Returns an array of sampler variable names
  29979. * @returns The array of sampler variable neames.
  29980. */
  29981. getSamplers(): string[];
  29982. /**
  29983. * The error from the last compilation.
  29984. * @returns the error string.
  29985. */
  29986. getCompilationError(): string;
  29987. /**
  29988. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29989. * @param func The callback to be used.
  29990. */
  29991. executeWhenCompiled(func: (effect: Effect) => void): void;
  29992. private _checkIsReady;
  29993. /** @hidden */
  29994. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29995. /** @hidden */
  29996. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29997. /** @hidden */
  29998. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29999. private _processShaderConversion;
  30000. private _processIncludes;
  30001. private _processPrecision;
  30002. /**
  30003. * Recompiles the webGL program
  30004. * @param vertexSourceCode The source code for the vertex shader.
  30005. * @param fragmentSourceCode The source code for the fragment shader.
  30006. * @param onCompiled Callback called when completed.
  30007. * @param onError Callback called on error.
  30008. * @hidden
  30009. */
  30010. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30011. /**
  30012. * Prepares the effect
  30013. * @hidden
  30014. */
  30015. _prepareEffect(): void;
  30016. /**
  30017. * Checks if the effect is supported. (Must be called after compilation)
  30018. */
  30019. readonly isSupported: boolean;
  30020. /**
  30021. * Binds a texture to the engine to be used as output of the shader.
  30022. * @param channel Name of the output variable.
  30023. * @param texture Texture to bind.
  30024. * @hidden
  30025. */
  30026. _bindTexture(channel: string, texture: InternalTexture): void;
  30027. /**
  30028. * Sets a texture on the engine to be used in the shader.
  30029. * @param channel Name of the sampler variable.
  30030. * @param texture Texture to set.
  30031. */
  30032. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30033. /**
  30034. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30035. * @param channel Name of the sampler variable.
  30036. * @param texture Texture to set.
  30037. */
  30038. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30039. /**
  30040. * Sets an array of textures on the engine to be used in the shader.
  30041. * @param channel Name of the variable.
  30042. * @param textures Textures to set.
  30043. */
  30044. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30045. /**
  30046. * 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)
  30047. * @param channel Name of the sampler variable.
  30048. * @param postProcess Post process to get the input texture from.
  30049. */
  30050. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30051. /**
  30052. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30053. * 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)
  30054. * @param channel Name of the sampler variable.
  30055. * @param postProcess Post process to get the output texture from.
  30056. */
  30057. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30058. /** @hidden */
  30059. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30060. /** @hidden */
  30061. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30062. /** @hidden */
  30063. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30064. /** @hidden */
  30065. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30066. /**
  30067. * Binds a buffer to a uniform.
  30068. * @param buffer Buffer to bind.
  30069. * @param name Name of the uniform variable to bind to.
  30070. */
  30071. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30072. /**
  30073. * Binds block to a uniform.
  30074. * @param blockName Name of the block to bind.
  30075. * @param index Index to bind.
  30076. */
  30077. bindUniformBlock(blockName: string, index: number): void;
  30078. /**
  30079. * Sets an interger value on a uniform variable.
  30080. * @param uniformName Name of the variable.
  30081. * @param value Value to be set.
  30082. * @returns this effect.
  30083. */
  30084. setInt(uniformName: string, value: number): Effect;
  30085. /**
  30086. * Sets an int array on a uniform variable.
  30087. * @param uniformName Name of the variable.
  30088. * @param array array to be set.
  30089. * @returns this effect.
  30090. */
  30091. setIntArray(uniformName: string, array: Int32Array): Effect;
  30092. /**
  30093. * 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)
  30094. * @param uniformName Name of the variable.
  30095. * @param array array to be set.
  30096. * @returns this effect.
  30097. */
  30098. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30099. /**
  30100. * 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)
  30101. * @param uniformName Name of the variable.
  30102. * @param array array to be set.
  30103. * @returns this effect.
  30104. */
  30105. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30106. /**
  30107. * 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)
  30108. * @param uniformName Name of the variable.
  30109. * @param array array to be set.
  30110. * @returns this effect.
  30111. */
  30112. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30113. /**
  30114. * Sets an float array on a uniform variable.
  30115. * @param uniformName Name of the variable.
  30116. * @param array array to be set.
  30117. * @returns this effect.
  30118. */
  30119. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30120. /**
  30121. * 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)
  30122. * @param uniformName Name of the variable.
  30123. * @param array array to be set.
  30124. * @returns this effect.
  30125. */
  30126. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30127. /**
  30128. * 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)
  30129. * @param uniformName Name of the variable.
  30130. * @param array array to be set.
  30131. * @returns this effect.
  30132. */
  30133. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30134. /**
  30135. * 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)
  30136. * @param uniformName Name of the variable.
  30137. * @param array array to be set.
  30138. * @returns this effect.
  30139. */
  30140. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30141. /**
  30142. * Sets an array on a uniform variable.
  30143. * @param uniformName Name of the variable.
  30144. * @param array array to be set.
  30145. * @returns this effect.
  30146. */
  30147. setArray(uniformName: string, array: number[]): Effect;
  30148. /**
  30149. * 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)
  30150. * @param uniformName Name of the variable.
  30151. * @param array array to be set.
  30152. * @returns this effect.
  30153. */
  30154. setArray2(uniformName: string, array: number[]): Effect;
  30155. /**
  30156. * 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)
  30157. * @param uniformName Name of the variable.
  30158. * @param array array to be set.
  30159. * @returns this effect.
  30160. */
  30161. setArray3(uniformName: string, array: number[]): Effect;
  30162. /**
  30163. * 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)
  30164. * @param uniformName Name of the variable.
  30165. * @param array array to be set.
  30166. * @returns this effect.
  30167. */
  30168. setArray4(uniformName: string, array: number[]): Effect;
  30169. /**
  30170. * Sets matrices on a uniform variable.
  30171. * @param uniformName Name of the variable.
  30172. * @param matrices matrices to be set.
  30173. * @returns this effect.
  30174. */
  30175. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30176. /**
  30177. * Sets matrix on a uniform variable.
  30178. * @param uniformName Name of the variable.
  30179. * @param matrix matrix to be set.
  30180. * @returns this effect.
  30181. */
  30182. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30183. /**
  30184. * 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)
  30185. * @param uniformName Name of the variable.
  30186. * @param matrix matrix to be set.
  30187. * @returns this effect.
  30188. */
  30189. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30190. /**
  30191. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30192. * @param uniformName Name of the variable.
  30193. * @param matrix matrix to be set.
  30194. * @returns this effect.
  30195. */
  30196. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30197. /**
  30198. * Sets a float on a uniform variable.
  30199. * @param uniformName Name of the variable.
  30200. * @param value value to be set.
  30201. * @returns this effect.
  30202. */
  30203. setFloat(uniformName: string, value: number): Effect;
  30204. /**
  30205. * Sets a boolean on a uniform variable.
  30206. * @param uniformName Name of the variable.
  30207. * @param bool value to be set.
  30208. * @returns this effect.
  30209. */
  30210. setBool(uniformName: string, bool: boolean): Effect;
  30211. /**
  30212. * Sets a Vector2 on a uniform variable.
  30213. * @param uniformName Name of the variable.
  30214. * @param vector2 vector2 to be set.
  30215. * @returns this effect.
  30216. */
  30217. setVector2(uniformName: string, vector2: Vector2): Effect;
  30218. /**
  30219. * Sets a float2 on a uniform variable.
  30220. * @param uniformName Name of the variable.
  30221. * @param x First float in float2.
  30222. * @param y Second float in float2.
  30223. * @returns this effect.
  30224. */
  30225. setFloat2(uniformName: string, x: number, y: number): Effect;
  30226. /**
  30227. * Sets a Vector3 on a uniform variable.
  30228. * @param uniformName Name of the variable.
  30229. * @param vector3 Value to be set.
  30230. * @returns this effect.
  30231. */
  30232. setVector3(uniformName: string, vector3: Vector3): Effect;
  30233. /**
  30234. * Sets a float3 on a uniform variable.
  30235. * @param uniformName Name of the variable.
  30236. * @param x First float in float3.
  30237. * @param y Second float in float3.
  30238. * @param z Third float in float3.
  30239. * @returns this effect.
  30240. */
  30241. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30242. /**
  30243. * Sets a Vector4 on a uniform variable.
  30244. * @param uniformName Name of the variable.
  30245. * @param vector4 Value to be set.
  30246. * @returns this effect.
  30247. */
  30248. setVector4(uniformName: string, vector4: Vector4): Effect;
  30249. /**
  30250. * Sets a float4 on a uniform variable.
  30251. * @param uniformName Name of the variable.
  30252. * @param x First float in float4.
  30253. * @param y Second float in float4.
  30254. * @param z Third float in float4.
  30255. * @param w Fourth float in float4.
  30256. * @returns this effect.
  30257. */
  30258. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30259. /**
  30260. * Sets a Color3 on a uniform variable.
  30261. * @param uniformName Name of the variable.
  30262. * @param color3 Value to be set.
  30263. * @returns this effect.
  30264. */
  30265. setColor3(uniformName: string, color3: Color3): Effect;
  30266. /**
  30267. * Sets a Color4 on a uniform variable.
  30268. * @param uniformName Name of the variable.
  30269. * @param color3 Value to be set.
  30270. * @param alpha Alpha value to be set.
  30271. * @returns this effect.
  30272. */
  30273. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30274. /**
  30275. * Sets a Color4 on a uniform variable
  30276. * @param uniformName defines the name of the variable
  30277. * @param color4 defines the value to be set
  30278. * @returns this effect.
  30279. */
  30280. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30281. /** Release all associated resources */
  30282. dispose(): void;
  30283. /**
  30284. * This function will add a new shader to the shader store
  30285. * @param name the name of the shader
  30286. * @param pixelShader optional pixel shader content
  30287. * @param vertexShader optional vertex shader content
  30288. */
  30289. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30290. /**
  30291. * Store of each shader (The can be looked up using effect.key)
  30292. */
  30293. static ShadersStore: {
  30294. [key: string]: string;
  30295. };
  30296. /**
  30297. * Store of each included file for a shader (The can be looked up using effect.key)
  30298. */
  30299. static IncludesShadersStore: {
  30300. [key: string]: string;
  30301. };
  30302. /**
  30303. * Resets the cache of effects.
  30304. */
  30305. static ResetCache(): void;
  30306. }
  30307. }
  30308. declare module "babylonjs/Materials/colorCurves" {
  30309. import { Effect } from "babylonjs/Materials/effect";
  30310. /**
  30311. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30312. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30313. * 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;
  30314. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30315. */
  30316. export class ColorCurves {
  30317. private _dirty;
  30318. private _tempColor;
  30319. private _globalCurve;
  30320. private _highlightsCurve;
  30321. private _midtonesCurve;
  30322. private _shadowsCurve;
  30323. private _positiveCurve;
  30324. private _negativeCurve;
  30325. private _globalHue;
  30326. private _globalDensity;
  30327. private _globalSaturation;
  30328. private _globalExposure;
  30329. /**
  30330. * Gets the global Hue value.
  30331. * 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).
  30332. */
  30333. /**
  30334. * Sets the global Hue value.
  30335. * 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).
  30336. */
  30337. globalHue: number;
  30338. /**
  30339. * Gets the global Density value.
  30340. * 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.
  30341. * Values less than zero provide a filter of opposite hue.
  30342. */
  30343. /**
  30344. * Sets the global Density value.
  30345. * 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.
  30346. * Values less than zero provide a filter of opposite hue.
  30347. */
  30348. globalDensity: number;
  30349. /**
  30350. * Gets the global Saturation value.
  30351. * 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.
  30352. */
  30353. /**
  30354. * Sets the global Saturation value.
  30355. * 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.
  30356. */
  30357. globalSaturation: number;
  30358. /**
  30359. * Gets the global Exposure value.
  30360. * 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.
  30361. */
  30362. /**
  30363. * Sets the global Exposure value.
  30364. * 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.
  30365. */
  30366. globalExposure: number;
  30367. private _highlightsHue;
  30368. private _highlightsDensity;
  30369. private _highlightsSaturation;
  30370. private _highlightsExposure;
  30371. /**
  30372. * Gets the highlights Hue value.
  30373. * 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).
  30374. */
  30375. /**
  30376. * Sets the highlights Hue value.
  30377. * 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).
  30378. */
  30379. highlightsHue: number;
  30380. /**
  30381. * Gets the highlights Density value.
  30382. * 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.
  30383. * Values less than zero provide a filter of opposite hue.
  30384. */
  30385. /**
  30386. * Sets the highlights Density value.
  30387. * 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.
  30388. * Values less than zero provide a filter of opposite hue.
  30389. */
  30390. highlightsDensity: number;
  30391. /**
  30392. * Gets the highlights Saturation value.
  30393. * 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.
  30394. */
  30395. /**
  30396. * Sets the highlights Saturation value.
  30397. * 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.
  30398. */
  30399. highlightsSaturation: number;
  30400. /**
  30401. * Gets the highlights Exposure value.
  30402. * 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.
  30403. */
  30404. /**
  30405. * Sets the highlights Exposure value.
  30406. * 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.
  30407. */
  30408. highlightsExposure: number;
  30409. private _midtonesHue;
  30410. private _midtonesDensity;
  30411. private _midtonesSaturation;
  30412. private _midtonesExposure;
  30413. /**
  30414. * Gets the midtones Hue value.
  30415. * 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).
  30416. */
  30417. /**
  30418. * Sets the midtones Hue value.
  30419. * 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).
  30420. */
  30421. midtonesHue: number;
  30422. /**
  30423. * Gets the midtones Density value.
  30424. * 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.
  30425. * Values less than zero provide a filter of opposite hue.
  30426. */
  30427. /**
  30428. * Sets the midtones Density value.
  30429. * 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.
  30430. * Values less than zero provide a filter of opposite hue.
  30431. */
  30432. midtonesDensity: number;
  30433. /**
  30434. * Gets the midtones Saturation value.
  30435. * 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.
  30436. */
  30437. /**
  30438. * Sets the midtones Saturation value.
  30439. * 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.
  30440. */
  30441. midtonesSaturation: number;
  30442. /**
  30443. * Gets the midtones Exposure value.
  30444. * 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.
  30445. */
  30446. /**
  30447. * Sets the midtones Exposure value.
  30448. * 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.
  30449. */
  30450. midtonesExposure: number;
  30451. private _shadowsHue;
  30452. private _shadowsDensity;
  30453. private _shadowsSaturation;
  30454. private _shadowsExposure;
  30455. /**
  30456. * Gets the shadows Hue value.
  30457. * 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).
  30458. */
  30459. /**
  30460. * Sets the shadows Hue value.
  30461. * 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).
  30462. */
  30463. shadowsHue: number;
  30464. /**
  30465. * Gets the shadows Density value.
  30466. * 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.
  30467. * Values less than zero provide a filter of opposite hue.
  30468. */
  30469. /**
  30470. * Sets the shadows Density value.
  30471. * 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.
  30472. * Values less than zero provide a filter of opposite hue.
  30473. */
  30474. shadowsDensity: number;
  30475. /**
  30476. * Gets the shadows Saturation value.
  30477. * 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.
  30478. */
  30479. /**
  30480. * Sets the shadows Saturation value.
  30481. * 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.
  30482. */
  30483. shadowsSaturation: number;
  30484. /**
  30485. * Gets the shadows Exposure value.
  30486. * 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.
  30487. */
  30488. /**
  30489. * Sets the shadows Exposure value.
  30490. * 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.
  30491. */
  30492. shadowsExposure: number;
  30493. /**
  30494. * Returns the class name
  30495. * @returns The class name
  30496. */
  30497. getClassName(): string;
  30498. /**
  30499. * Binds the color curves to the shader.
  30500. * @param colorCurves The color curve to bind
  30501. * @param effect The effect to bind to
  30502. * @param positiveUniform The positive uniform shader parameter
  30503. * @param neutralUniform The neutral uniform shader parameter
  30504. * @param negativeUniform The negative uniform shader parameter
  30505. */
  30506. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30507. /**
  30508. * Prepare the list of uniforms associated with the ColorCurves effects.
  30509. * @param uniformsList The list of uniforms used in the effect
  30510. */
  30511. static PrepareUniforms(uniformsList: string[]): void;
  30512. /**
  30513. * Returns color grading data based on a hue, density, saturation and exposure value.
  30514. * @param filterHue The hue of the color filter.
  30515. * @param filterDensity The density of the color filter.
  30516. * @param saturation The saturation.
  30517. * @param exposure The exposure.
  30518. * @param result The result data container.
  30519. */
  30520. private getColorGradingDataToRef;
  30521. /**
  30522. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30523. * @param value The input slider value in range [-100,100].
  30524. * @returns Adjusted value.
  30525. */
  30526. private static applyColorGradingSliderNonlinear;
  30527. /**
  30528. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30529. * @param hue The hue (H) input.
  30530. * @param saturation The saturation (S) input.
  30531. * @param brightness The brightness (B) input.
  30532. * @result An RGBA color represented as Vector4.
  30533. */
  30534. private static fromHSBToRef;
  30535. /**
  30536. * Returns a value clamped between min and max
  30537. * @param value The value to clamp
  30538. * @param min The minimum of value
  30539. * @param max The maximum of value
  30540. * @returns The clamped value.
  30541. */
  30542. private static clamp;
  30543. /**
  30544. * Clones the current color curve instance.
  30545. * @return The cloned curves
  30546. */
  30547. clone(): ColorCurves;
  30548. /**
  30549. * Serializes the current color curve instance to a json representation.
  30550. * @return a JSON representation
  30551. */
  30552. serialize(): any;
  30553. /**
  30554. * Parses the color curve from a json representation.
  30555. * @param source the JSON source to parse
  30556. * @return The parsed curves
  30557. */
  30558. static Parse(source: any): ColorCurves;
  30559. }
  30560. }
  30561. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30562. import { Observable } from "babylonjs/Misc/observable";
  30563. import { Nullable } from "babylonjs/types";
  30564. import { Color4 } from "babylonjs/Maths/math";
  30565. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30566. import { Effect } from "babylonjs/Materials/effect";
  30567. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30568. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30569. /**
  30570. * Interface to follow in your material defines to integrate easily the
  30571. * Image proccessing functions.
  30572. * @hidden
  30573. */
  30574. export interface IImageProcessingConfigurationDefines {
  30575. IMAGEPROCESSING: boolean;
  30576. VIGNETTE: boolean;
  30577. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30578. VIGNETTEBLENDMODEOPAQUE: boolean;
  30579. TONEMAPPING: boolean;
  30580. TONEMAPPING_ACES: boolean;
  30581. CONTRAST: boolean;
  30582. EXPOSURE: boolean;
  30583. COLORCURVES: boolean;
  30584. COLORGRADING: boolean;
  30585. COLORGRADING3D: boolean;
  30586. SAMPLER3DGREENDEPTH: boolean;
  30587. SAMPLER3DBGRMAP: boolean;
  30588. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30589. }
  30590. /**
  30591. * @hidden
  30592. */
  30593. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30594. IMAGEPROCESSING: boolean;
  30595. VIGNETTE: boolean;
  30596. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30597. VIGNETTEBLENDMODEOPAQUE: boolean;
  30598. TONEMAPPING: boolean;
  30599. TONEMAPPING_ACES: boolean;
  30600. CONTRAST: boolean;
  30601. COLORCURVES: boolean;
  30602. COLORGRADING: boolean;
  30603. COLORGRADING3D: boolean;
  30604. SAMPLER3DGREENDEPTH: boolean;
  30605. SAMPLER3DBGRMAP: boolean;
  30606. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30607. EXPOSURE: boolean;
  30608. constructor();
  30609. }
  30610. /**
  30611. * This groups together the common properties used for image processing either in direct forward pass
  30612. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30613. * or not.
  30614. */
  30615. export class ImageProcessingConfiguration {
  30616. /**
  30617. * Default tone mapping applied in BabylonJS.
  30618. */
  30619. static readonly TONEMAPPING_STANDARD: number;
  30620. /**
  30621. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30622. * to other engines rendering to increase portability.
  30623. */
  30624. static readonly TONEMAPPING_ACES: number;
  30625. /**
  30626. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30627. */
  30628. colorCurves: Nullable<ColorCurves>;
  30629. private _colorCurvesEnabled;
  30630. /**
  30631. * Gets wether the color curves effect is enabled.
  30632. */
  30633. /**
  30634. * Sets wether the color curves effect is enabled.
  30635. */
  30636. colorCurvesEnabled: boolean;
  30637. private _colorGradingTexture;
  30638. /**
  30639. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30640. */
  30641. /**
  30642. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30643. */
  30644. colorGradingTexture: Nullable<BaseTexture>;
  30645. private _colorGradingEnabled;
  30646. /**
  30647. * Gets wether the color grading effect is enabled.
  30648. */
  30649. /**
  30650. * Sets wether the color grading effect is enabled.
  30651. */
  30652. colorGradingEnabled: boolean;
  30653. private _colorGradingWithGreenDepth;
  30654. /**
  30655. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30656. */
  30657. /**
  30658. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30659. */
  30660. colorGradingWithGreenDepth: boolean;
  30661. private _colorGradingBGR;
  30662. /**
  30663. * Gets wether the color grading texture contains BGR values.
  30664. */
  30665. /**
  30666. * Sets wether the color grading texture contains BGR values.
  30667. */
  30668. colorGradingBGR: boolean;
  30669. /** @hidden */
  30670. _exposure: number;
  30671. /**
  30672. * Gets the Exposure used in the effect.
  30673. */
  30674. /**
  30675. * Sets the Exposure used in the effect.
  30676. */
  30677. exposure: number;
  30678. private _toneMappingEnabled;
  30679. /**
  30680. * Gets wether the tone mapping effect is enabled.
  30681. */
  30682. /**
  30683. * Sets wether the tone mapping effect is enabled.
  30684. */
  30685. toneMappingEnabled: boolean;
  30686. private _toneMappingType;
  30687. /**
  30688. * Gets the type of tone mapping effect.
  30689. */
  30690. /**
  30691. * Sets the type of tone mapping effect used in BabylonJS.
  30692. */
  30693. toneMappingType: number;
  30694. protected _contrast: number;
  30695. /**
  30696. * Gets the contrast used in the effect.
  30697. */
  30698. /**
  30699. * Sets the contrast used in the effect.
  30700. */
  30701. contrast: number;
  30702. /**
  30703. * Vignette stretch size.
  30704. */
  30705. vignetteStretch: number;
  30706. /**
  30707. * Vignette centre X Offset.
  30708. */
  30709. vignetteCentreX: number;
  30710. /**
  30711. * Vignette centre Y Offset.
  30712. */
  30713. vignetteCentreY: number;
  30714. /**
  30715. * Vignette weight or intensity of the vignette effect.
  30716. */
  30717. vignetteWeight: number;
  30718. /**
  30719. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30720. * if vignetteEnabled is set to true.
  30721. */
  30722. vignetteColor: Color4;
  30723. /**
  30724. * Camera field of view used by the Vignette effect.
  30725. */
  30726. vignetteCameraFov: number;
  30727. private _vignetteBlendMode;
  30728. /**
  30729. * Gets the vignette blend mode allowing different kind of effect.
  30730. */
  30731. /**
  30732. * Sets the vignette blend mode allowing different kind of effect.
  30733. */
  30734. vignetteBlendMode: number;
  30735. private _vignetteEnabled;
  30736. /**
  30737. * Gets wether the vignette effect is enabled.
  30738. */
  30739. /**
  30740. * Sets wether the vignette effect is enabled.
  30741. */
  30742. vignetteEnabled: boolean;
  30743. private _applyByPostProcess;
  30744. /**
  30745. * Gets wether the image processing is applied through a post process or not.
  30746. */
  30747. /**
  30748. * Sets wether the image processing is applied through a post process or not.
  30749. */
  30750. applyByPostProcess: boolean;
  30751. private _isEnabled;
  30752. /**
  30753. * Gets wether the image processing is enabled or not.
  30754. */
  30755. /**
  30756. * Sets wether the image processing is enabled or not.
  30757. */
  30758. isEnabled: boolean;
  30759. /**
  30760. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30761. */
  30762. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30763. /**
  30764. * Method called each time the image processing information changes requires to recompile the effect.
  30765. */
  30766. protected _updateParameters(): void;
  30767. /**
  30768. * Gets the current class name.
  30769. * @return "ImageProcessingConfiguration"
  30770. */
  30771. getClassName(): string;
  30772. /**
  30773. * Prepare the list of uniforms associated with the Image Processing effects.
  30774. * @param uniforms The list of uniforms used in the effect
  30775. * @param defines the list of defines currently in use
  30776. */
  30777. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30778. /**
  30779. * Prepare the list of samplers associated with the Image Processing effects.
  30780. * @param samplersList The list of uniforms used in the effect
  30781. * @param defines the list of defines currently in use
  30782. */
  30783. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30784. /**
  30785. * Prepare the list of defines associated to the shader.
  30786. * @param defines the list of defines to complete
  30787. * @param forPostProcess Define if we are currently in post process mode or not
  30788. */
  30789. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30790. /**
  30791. * Returns true if all the image processing information are ready.
  30792. * @returns True if ready, otherwise, false
  30793. */
  30794. isReady(): boolean;
  30795. /**
  30796. * Binds the image processing to the shader.
  30797. * @param effect The effect to bind to
  30798. * @param aspectRatio Define the current aspect ratio of the effect
  30799. */
  30800. bind(effect: Effect, aspectRatio?: number): void;
  30801. /**
  30802. * Clones the current image processing instance.
  30803. * @return The cloned image processing
  30804. */
  30805. clone(): ImageProcessingConfiguration;
  30806. /**
  30807. * Serializes the current image processing instance to a json representation.
  30808. * @return a JSON representation
  30809. */
  30810. serialize(): any;
  30811. /**
  30812. * Parses the image processing from a json representation.
  30813. * @param source the JSON source to parse
  30814. * @return The parsed image processing
  30815. */
  30816. static Parse(source: any): ImageProcessingConfiguration;
  30817. private static _VIGNETTEMODE_MULTIPLY;
  30818. private static _VIGNETTEMODE_OPAQUE;
  30819. /**
  30820. * Used to apply the vignette as a mix with the pixel color.
  30821. */
  30822. static readonly VIGNETTEMODE_MULTIPLY: number;
  30823. /**
  30824. * Used to apply the vignette as a replacement of the pixel color.
  30825. */
  30826. static readonly VIGNETTEMODE_OPAQUE: number;
  30827. }
  30828. }
  30829. declare module "babylonjs/Materials/fresnelParameters" {
  30830. import { Color3 } from "babylonjs/Maths/math";
  30831. /**
  30832. * This represents all the required information to add a fresnel effect on a material:
  30833. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30834. */
  30835. export class FresnelParameters {
  30836. private _isEnabled;
  30837. /**
  30838. * Define if the fresnel effect is enable or not.
  30839. */
  30840. isEnabled: boolean;
  30841. /**
  30842. * Define the color used on edges (grazing angle)
  30843. */
  30844. leftColor: Color3;
  30845. /**
  30846. * Define the color used on center
  30847. */
  30848. rightColor: Color3;
  30849. /**
  30850. * Define bias applied to computed fresnel term
  30851. */
  30852. bias: number;
  30853. /**
  30854. * Defined the power exponent applied to fresnel term
  30855. */
  30856. power: number;
  30857. /**
  30858. * Clones the current fresnel and its valuues
  30859. * @returns a clone fresnel configuration
  30860. */
  30861. clone(): FresnelParameters;
  30862. /**
  30863. * Serializes the current fresnel parameters to a JSON representation.
  30864. * @return the JSON serialization
  30865. */
  30866. serialize(): any;
  30867. /**
  30868. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30869. * @param parsedFresnelParameters Define the JSON representation
  30870. * @returns the parsed parameters
  30871. */
  30872. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30873. }
  30874. }
  30875. declare module "babylonjs/Misc/decorators" {
  30876. import { Nullable } from "babylonjs/types";
  30877. import { Scene } from "babylonjs/scene";
  30878. import { IAnimatable } from "babylonjs/Misc/tools";
  30879. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30880. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30881. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30882. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30883. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30884. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30885. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30886. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30887. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30888. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30889. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30890. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30891. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30892. /**
  30893. * Decorator used to define property that can be serialized as reference to a camera
  30894. * @param sourceName defines the name of the property to decorate
  30895. */
  30896. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30897. /**
  30898. * Class used to help serialization objects
  30899. */
  30900. export class SerializationHelper {
  30901. /** hidden */
  30902. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30903. /** hidden */
  30904. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30905. /** hidden */
  30906. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30907. /** hidden */
  30908. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30909. /**
  30910. * Appends the serialized animations from the source animations
  30911. * @param source Source containing the animations
  30912. * @param destination Target to store the animations
  30913. */
  30914. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30915. /**
  30916. * Static function used to serialized a specific entity
  30917. * @param entity defines the entity to serialize
  30918. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30919. * @returns a JSON compatible object representing the serialization of the entity
  30920. */
  30921. static Serialize<T>(entity: T, serializationObject?: any): any;
  30922. /**
  30923. * Creates a new entity from a serialization data object
  30924. * @param creationFunction defines a function used to instanciated the new entity
  30925. * @param source defines the source serialization data
  30926. * @param scene defines the hosting scene
  30927. * @param rootUrl defines the root url for resources
  30928. * @returns a new entity
  30929. */
  30930. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30931. /**
  30932. * Clones an object
  30933. * @param creationFunction defines the function used to instanciate the new object
  30934. * @param source defines the source object
  30935. * @returns the cloned object
  30936. */
  30937. static Clone<T>(creationFunction: () => T, source: T): T;
  30938. /**
  30939. * Instanciates a new object based on a source one (some data will be shared between both object)
  30940. * @param creationFunction defines the function used to instanciate the new object
  30941. * @param source defines the source object
  30942. * @returns the new object
  30943. */
  30944. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30945. }
  30946. }
  30947. declare module "babylonjs/Cameras/camera" {
  30948. import { SmartArray } from "babylonjs/Misc/smartArray";
  30949. import { Observable } from "babylonjs/Misc/observable";
  30950. import { Nullable } from "babylonjs/types";
  30951. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30952. import { Scene } from "babylonjs/scene";
  30953. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30954. import { Node } from "babylonjs/node";
  30955. import { Mesh } from "babylonjs/Meshes/mesh";
  30956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30957. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30958. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30959. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30960. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30961. import { Ray } from "babylonjs/Culling/ray";
  30962. /**
  30963. * This is the base class of all the camera used in the application.
  30964. * @see http://doc.babylonjs.com/features/cameras
  30965. */
  30966. export class Camera extends Node {
  30967. /** @hidden */
  30968. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30969. /**
  30970. * This is the default projection mode used by the cameras.
  30971. * It helps recreating a feeling of perspective and better appreciate depth.
  30972. * This is the best way to simulate real life cameras.
  30973. */
  30974. static readonly PERSPECTIVE_CAMERA: number;
  30975. /**
  30976. * This helps creating camera with an orthographic mode.
  30977. * 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.
  30978. */
  30979. static readonly ORTHOGRAPHIC_CAMERA: number;
  30980. /**
  30981. * This is the default FOV mode for perspective cameras.
  30982. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30983. */
  30984. static readonly FOVMODE_VERTICAL_FIXED: number;
  30985. /**
  30986. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30987. */
  30988. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30989. /**
  30990. * This specifies ther is no need for a camera rig.
  30991. * Basically only one eye is rendered corresponding to the camera.
  30992. */
  30993. static readonly RIG_MODE_NONE: number;
  30994. /**
  30995. * Simulates a camera Rig with one blue eye and one red eye.
  30996. * This can be use with 3d blue and red glasses.
  30997. */
  30998. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30999. /**
  31000. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31001. */
  31002. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31003. /**
  31004. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31005. */
  31006. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31007. /**
  31008. * Defines that both eyes of the camera will be rendered over under each other.
  31009. */
  31010. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31011. /**
  31012. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31013. */
  31014. static readonly RIG_MODE_VR: number;
  31015. /**
  31016. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31017. */
  31018. static readonly RIG_MODE_WEBVR: number;
  31019. /**
  31020. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31021. */
  31022. static readonly RIG_MODE_CUSTOM: number;
  31023. /**
  31024. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31025. */
  31026. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31027. /**
  31028. * Define the input manager associated with the camera.
  31029. */
  31030. inputs: CameraInputsManager<Camera>;
  31031. /** @hidden */
  31032. _position: Vector3;
  31033. /**
  31034. * Define the current local position of the camera in the scene
  31035. */
  31036. position: Vector3;
  31037. /**
  31038. * The vector the camera should consider as up.
  31039. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31040. */
  31041. upVector: Vector3;
  31042. /**
  31043. * Define the current limit on the left side for an orthographic camera
  31044. * In scene unit
  31045. */
  31046. orthoLeft: Nullable<number>;
  31047. /**
  31048. * Define the current limit on the right side for an orthographic camera
  31049. * In scene unit
  31050. */
  31051. orthoRight: Nullable<number>;
  31052. /**
  31053. * Define the current limit on the bottom side for an orthographic camera
  31054. * In scene unit
  31055. */
  31056. orthoBottom: Nullable<number>;
  31057. /**
  31058. * Define the current limit on the top side for an orthographic camera
  31059. * In scene unit
  31060. */
  31061. orthoTop: Nullable<number>;
  31062. /**
  31063. * Field Of View is set in Radians. (default is 0.8)
  31064. */
  31065. fov: number;
  31066. /**
  31067. * Define the minimum distance the camera can see from.
  31068. * This is important to note that the depth buffer are not infinite and the closer it starts
  31069. * the more your scene might encounter depth fighting issue.
  31070. */
  31071. minZ: number;
  31072. /**
  31073. * Define the maximum distance the camera can see to.
  31074. * This is important to note that the depth buffer are not infinite and the further it end
  31075. * the more your scene might encounter depth fighting issue.
  31076. */
  31077. maxZ: number;
  31078. /**
  31079. * Define the default inertia of the camera.
  31080. * This helps giving a smooth feeling to the camera movement.
  31081. */
  31082. inertia: number;
  31083. /**
  31084. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31085. */
  31086. mode: number;
  31087. /**
  31088. * Define wether the camera is intermediate.
  31089. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31090. */
  31091. isIntermediate: boolean;
  31092. /**
  31093. * Define the viewport of the camera.
  31094. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31095. */
  31096. viewport: Viewport;
  31097. /**
  31098. * Restricts the camera to viewing objects with the same layerMask.
  31099. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31100. */
  31101. layerMask: number;
  31102. /**
  31103. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31104. */
  31105. fovMode: number;
  31106. /**
  31107. * Rig mode of the camera.
  31108. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31109. * This is normally controlled byt the camera themselves as internal use.
  31110. */
  31111. cameraRigMode: number;
  31112. /**
  31113. * Defines the distance between both "eyes" in case of a RIG
  31114. */
  31115. interaxialDistance: number;
  31116. /**
  31117. * Defines if stereoscopic rendering is done side by side or over under.
  31118. */
  31119. isStereoscopicSideBySide: boolean;
  31120. /**
  31121. * 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
  31122. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31123. * else in the scene.
  31124. */
  31125. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31126. /**
  31127. * When set, the camera will render to this render target instead of the default canvas
  31128. */
  31129. outputRenderTarget: Nullable<RenderTargetTexture>;
  31130. /**
  31131. * Observable triggered when the camera view matrix has changed.
  31132. */
  31133. onViewMatrixChangedObservable: Observable<Camera>;
  31134. /**
  31135. * Observable triggered when the camera Projection matrix has changed.
  31136. */
  31137. onProjectionMatrixChangedObservable: Observable<Camera>;
  31138. /**
  31139. * Observable triggered when the inputs have been processed.
  31140. */
  31141. onAfterCheckInputsObservable: Observable<Camera>;
  31142. /**
  31143. * Observable triggered when reset has been called and applied to the camera.
  31144. */
  31145. onRestoreStateObservable: Observable<Camera>;
  31146. /** @hidden */
  31147. _cameraRigParams: any;
  31148. /** @hidden */
  31149. _rigCameras: Camera[];
  31150. /** @hidden */
  31151. _rigPostProcess: Nullable<PostProcess>;
  31152. protected _webvrViewMatrix: Matrix;
  31153. /** @hidden */
  31154. _skipRendering: boolean;
  31155. /** @hidden */
  31156. _projectionMatrix: Matrix;
  31157. /** @hidden */
  31158. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31159. /** @hidden */
  31160. _activeMeshes: SmartArray<AbstractMesh>;
  31161. protected _globalPosition: Vector3;
  31162. /** hidden */
  31163. _computedViewMatrix: Matrix;
  31164. private _doNotComputeProjectionMatrix;
  31165. private _transformMatrix;
  31166. private _frustumPlanes;
  31167. private _refreshFrustumPlanes;
  31168. private _storedFov;
  31169. private _stateStored;
  31170. /**
  31171. * Instantiates a new camera object.
  31172. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31173. * @see http://doc.babylonjs.com/features/cameras
  31174. * @param name Defines the name of the camera in the scene
  31175. * @param position Defines the position of the camera
  31176. * @param scene Defines the scene the camera belongs too
  31177. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31178. */
  31179. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31180. /**
  31181. * Store current camera state (fov, position, etc..)
  31182. * @returns the camera
  31183. */
  31184. storeState(): Camera;
  31185. /**
  31186. * Restores the camera state values if it has been stored. You must call storeState() first
  31187. */
  31188. protected _restoreStateValues(): boolean;
  31189. /**
  31190. * Restored camera state. You must call storeState() first.
  31191. * @returns true if restored and false otherwise
  31192. */
  31193. restoreState(): boolean;
  31194. /**
  31195. * Gets the class name of the camera.
  31196. * @returns the class name
  31197. */
  31198. getClassName(): string;
  31199. /** @hidden */
  31200. readonly _isCamera: boolean;
  31201. /**
  31202. * Gets a string representation of the camera useful for debug purpose.
  31203. * @param fullDetails Defines that a more verboe level of logging is required
  31204. * @returns the string representation
  31205. */
  31206. toString(fullDetails?: boolean): string;
  31207. /**
  31208. * Gets the current world space position of the camera.
  31209. */
  31210. readonly globalPosition: Vector3;
  31211. /**
  31212. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31213. * @returns the active meshe list
  31214. */
  31215. getActiveMeshes(): SmartArray<AbstractMesh>;
  31216. /**
  31217. * Check wether a mesh is part of the current active mesh list of the camera
  31218. * @param mesh Defines the mesh to check
  31219. * @returns true if active, false otherwise
  31220. */
  31221. isActiveMesh(mesh: Mesh): boolean;
  31222. /**
  31223. * Is this camera ready to be used/rendered
  31224. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31225. * @return true if the camera is ready
  31226. */
  31227. isReady(completeCheck?: boolean): boolean;
  31228. /** @hidden */
  31229. _initCache(): void;
  31230. /** @hidden */
  31231. _updateCache(ignoreParentClass?: boolean): void;
  31232. /** @hidden */
  31233. _isSynchronized(): boolean;
  31234. /** @hidden */
  31235. _isSynchronizedViewMatrix(): boolean;
  31236. /** @hidden */
  31237. _isSynchronizedProjectionMatrix(): boolean;
  31238. /**
  31239. * Attach the input controls to a specific dom element to get the input from.
  31240. * @param element Defines the element the controls should be listened from
  31241. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31242. */
  31243. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31244. /**
  31245. * Detach the current controls from the specified dom element.
  31246. * @param element Defines the element to stop listening the inputs from
  31247. */
  31248. detachControl(element: HTMLElement): void;
  31249. /**
  31250. * Update the camera state according to the different inputs gathered during the frame.
  31251. */
  31252. update(): void;
  31253. /** @hidden */
  31254. _checkInputs(): void;
  31255. /** @hidden */
  31256. readonly rigCameras: Camera[];
  31257. /**
  31258. * Gets the post process used by the rig cameras
  31259. */
  31260. readonly rigPostProcess: Nullable<PostProcess>;
  31261. /**
  31262. * Internal, gets the first post proces.
  31263. * @returns the first post process to be run on this camera.
  31264. */
  31265. _getFirstPostProcess(): Nullable<PostProcess>;
  31266. private _cascadePostProcessesToRigCams;
  31267. /**
  31268. * Attach a post process to the camera.
  31269. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31270. * @param postProcess The post process to attach to the camera
  31271. * @param insertAt The position of the post process in case several of them are in use in the scene
  31272. * @returns the position the post process has been inserted at
  31273. */
  31274. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31275. /**
  31276. * Detach a post process to the camera.
  31277. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31278. * @param postProcess The post process to detach from the camera
  31279. */
  31280. detachPostProcess(postProcess: PostProcess): void;
  31281. /**
  31282. * Gets the current world matrix of the camera
  31283. */
  31284. getWorldMatrix(): Matrix;
  31285. /** @hidden */
  31286. _getViewMatrix(): Matrix;
  31287. /**
  31288. * Gets the current view matrix of the camera.
  31289. * @param force forces the camera to recompute the matrix without looking at the cached state
  31290. * @returns the view matrix
  31291. */
  31292. getViewMatrix(force?: boolean): Matrix;
  31293. /**
  31294. * Freeze the projection matrix.
  31295. * It will prevent the cache check of the camera projection compute and can speed up perf
  31296. * if no parameter of the camera are meant to change
  31297. * @param projection Defines manually a projection if necessary
  31298. */
  31299. freezeProjectionMatrix(projection?: Matrix): void;
  31300. /**
  31301. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31302. */
  31303. unfreezeProjectionMatrix(): void;
  31304. /**
  31305. * Gets the current projection matrix of the camera.
  31306. * @param force forces the camera to recompute the matrix without looking at the cached state
  31307. * @returns the projection matrix
  31308. */
  31309. getProjectionMatrix(force?: boolean): Matrix;
  31310. /**
  31311. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31312. * @returns a Matrix
  31313. */
  31314. getTransformationMatrix(): Matrix;
  31315. private _updateFrustumPlanes;
  31316. /**
  31317. * Checks if a cullable object (mesh...) is in the camera frustum
  31318. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31319. * @param target The object to check
  31320. * @returns true if the object is in frustum otherwise false
  31321. */
  31322. isInFrustum(target: ICullable): boolean;
  31323. /**
  31324. * Checks if a cullable object (mesh...) is in the camera frustum
  31325. * Unlike isInFrustum this cheks the full bounding box
  31326. * @param target The object to check
  31327. * @returns true if the object is in frustum otherwise false
  31328. */
  31329. isCompletelyInFrustum(target: ICullable): boolean;
  31330. /**
  31331. * Gets a ray in the forward direction from the camera.
  31332. * @param length Defines the length of the ray to create
  31333. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31334. * @param origin Defines the start point of the ray which defaults to the camera position
  31335. * @returns the forward ray
  31336. */
  31337. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31338. /**
  31339. * Releases resources associated with this node.
  31340. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31341. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31342. */
  31343. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31344. /** @hidden */
  31345. _isLeftCamera: boolean;
  31346. /**
  31347. * Gets the left camera of a rig setup in case of Rigged Camera
  31348. */
  31349. readonly isLeftCamera: boolean;
  31350. /** @hidden */
  31351. _isRightCamera: boolean;
  31352. /**
  31353. * Gets the right camera of a rig setup in case of Rigged Camera
  31354. */
  31355. readonly isRightCamera: boolean;
  31356. /**
  31357. * Gets the left camera of a rig setup in case of Rigged Camera
  31358. */
  31359. readonly leftCamera: Nullable<FreeCamera>;
  31360. /**
  31361. * Gets the right camera of a rig setup in case of Rigged Camera
  31362. */
  31363. readonly rightCamera: Nullable<FreeCamera>;
  31364. /**
  31365. * Gets the left camera target of a rig setup in case of Rigged Camera
  31366. * @returns the target position
  31367. */
  31368. getLeftTarget(): Nullable<Vector3>;
  31369. /**
  31370. * Gets the right camera target of a rig setup in case of Rigged Camera
  31371. * @returns the target position
  31372. */
  31373. getRightTarget(): Nullable<Vector3>;
  31374. /**
  31375. * @hidden
  31376. */
  31377. setCameraRigMode(mode: number, rigParams: any): void;
  31378. /** @hidden */
  31379. static _setStereoscopicRigMode(camera: Camera): void;
  31380. /** @hidden */
  31381. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31382. /** @hidden */
  31383. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31384. /** @hidden */
  31385. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31386. /** @hidden */
  31387. _getVRProjectionMatrix(): Matrix;
  31388. protected _updateCameraRotationMatrix(): void;
  31389. protected _updateWebVRCameraRotationMatrix(): void;
  31390. /**
  31391. * This function MUST be overwritten by the different WebVR cameras available.
  31392. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31393. * @hidden
  31394. */
  31395. _getWebVRProjectionMatrix(): Matrix;
  31396. /**
  31397. * This function MUST be overwritten by the different WebVR cameras available.
  31398. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31399. * @hidden
  31400. */
  31401. _getWebVRViewMatrix(): Matrix;
  31402. /** @hidden */
  31403. setCameraRigParameter(name: string, value: any): void;
  31404. /**
  31405. * needs to be overridden by children so sub has required properties to be copied
  31406. * @hidden
  31407. */
  31408. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31409. /**
  31410. * May need to be overridden by children
  31411. * @hidden
  31412. */
  31413. _updateRigCameras(): void;
  31414. /** @hidden */
  31415. _setupInputs(): void;
  31416. /**
  31417. * Serialiaze the camera setup to a json represention
  31418. * @returns the JSON representation
  31419. */
  31420. serialize(): any;
  31421. /**
  31422. * Clones the current camera.
  31423. * @param name The cloned camera name
  31424. * @returns the cloned camera
  31425. */
  31426. clone(name: string): Camera;
  31427. /**
  31428. * Gets the direction of the camera relative to a given local axis.
  31429. * @param localAxis Defines the reference axis to provide a relative direction.
  31430. * @return the direction
  31431. */
  31432. getDirection(localAxis: Vector3): Vector3;
  31433. /**
  31434. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31435. * @param localAxis Defines the reference axis to provide a relative direction.
  31436. * @param result Defines the vector to store the result in
  31437. */
  31438. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31439. /**
  31440. * Gets a camera constructor for a given camera type
  31441. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31442. * @param name The name of the camera the result will be able to instantiate
  31443. * @param scene The scene the result will construct the camera in
  31444. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31445. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31446. * @returns a factory method to construc the camera
  31447. */
  31448. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31449. /**
  31450. * Compute the world matrix of the camera.
  31451. * @returns the camera workd matrix
  31452. */
  31453. computeWorldMatrix(): Matrix;
  31454. /**
  31455. * Parse a JSON and creates the camera from the parsed information
  31456. * @param parsedCamera The JSON to parse
  31457. * @param scene The scene to instantiate the camera in
  31458. * @returns the newly constructed camera
  31459. */
  31460. static Parse(parsedCamera: any, scene: Scene): Camera;
  31461. }
  31462. }
  31463. declare module "babylonjs/Misc/tools" {
  31464. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31465. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31466. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31467. import { Observable } from "babylonjs/Misc/observable";
  31468. import { DomManagement } from "babylonjs/Misc/domManagement";
  31469. import { WebRequest } from "babylonjs/Misc/webRequest";
  31470. import { Camera } from "babylonjs/Cameras/camera";
  31471. import { Engine } from "babylonjs/Engines/engine";
  31472. import { Animation } from "babylonjs/Animations/animation";
  31473. /**
  31474. * Interface for any object that can request an animation frame
  31475. */
  31476. export interface ICustomAnimationFrameRequester {
  31477. /**
  31478. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31479. */
  31480. renderFunction?: Function;
  31481. /**
  31482. * Called to request the next frame to render to
  31483. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31484. */
  31485. requestAnimationFrame: Function;
  31486. /**
  31487. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31488. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31489. */
  31490. requestID?: number;
  31491. }
  31492. /**
  31493. * Interface containing an array of animations
  31494. */
  31495. export interface IAnimatable {
  31496. /**
  31497. * Array of animations
  31498. */
  31499. animations: Nullable<Array<Animation>>;
  31500. }
  31501. /** Interface used by value gradients (color, factor, ...) */
  31502. export interface IValueGradient {
  31503. /**
  31504. * Gets or sets the gradient value (between 0 and 1)
  31505. */
  31506. gradient: number;
  31507. }
  31508. /** Class used to store color4 gradient */
  31509. export class ColorGradient implements IValueGradient {
  31510. /**
  31511. * Gets or sets the gradient value (between 0 and 1)
  31512. */
  31513. gradient: number;
  31514. /**
  31515. * Gets or sets first associated color
  31516. */
  31517. color1: Color4;
  31518. /**
  31519. * Gets or sets second associated color
  31520. */
  31521. color2?: Color4;
  31522. /**
  31523. * Will get a color picked randomly between color1 and color2.
  31524. * If color2 is undefined then color1 will be used
  31525. * @param result defines the target Color4 to store the result in
  31526. */
  31527. getColorToRef(result: Color4): void;
  31528. }
  31529. /** Class used to store color 3 gradient */
  31530. export class Color3Gradient implements IValueGradient {
  31531. /**
  31532. * Gets or sets the gradient value (between 0 and 1)
  31533. */
  31534. gradient: number;
  31535. /**
  31536. * Gets or sets the associated color
  31537. */
  31538. color: Color3;
  31539. }
  31540. /** Class used to store factor gradient */
  31541. export class FactorGradient implements IValueGradient {
  31542. /**
  31543. * Gets or sets the gradient value (between 0 and 1)
  31544. */
  31545. gradient: number;
  31546. /**
  31547. * Gets or sets first associated factor
  31548. */
  31549. factor1: number;
  31550. /**
  31551. * Gets or sets second associated factor
  31552. */
  31553. factor2?: number;
  31554. /**
  31555. * Will get a number picked randomly between factor1 and factor2.
  31556. * If factor2 is undefined then factor1 will be used
  31557. * @returns the picked number
  31558. */
  31559. getFactor(): number;
  31560. }
  31561. /**
  31562. * @ignore
  31563. * Application error to support additional information when loading a file
  31564. */
  31565. export class LoadFileError extends Error {
  31566. /** defines the optional web request */
  31567. request?: WebRequest | undefined;
  31568. private static _setPrototypeOf;
  31569. /**
  31570. * Creates a new LoadFileError
  31571. * @param message defines the message of the error
  31572. * @param request defines the optional web request
  31573. */
  31574. constructor(message: string,
  31575. /** defines the optional web request */
  31576. request?: WebRequest | undefined);
  31577. }
  31578. /**
  31579. * Class used to define a retry strategy when error happens while loading assets
  31580. */
  31581. export class RetryStrategy {
  31582. /**
  31583. * Function used to defines an exponential back off strategy
  31584. * @param maxRetries defines the maximum number of retries (3 by default)
  31585. * @param baseInterval defines the interval between retries
  31586. * @returns the strategy function to use
  31587. */
  31588. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31589. }
  31590. /**
  31591. * File request interface
  31592. */
  31593. export interface IFileRequest {
  31594. /**
  31595. * Raised when the request is complete (success or error).
  31596. */
  31597. onCompleteObservable: Observable<IFileRequest>;
  31598. /**
  31599. * Aborts the request for a file.
  31600. */
  31601. abort: () => void;
  31602. }
  31603. /**
  31604. * Class containing a set of static utilities functions
  31605. */
  31606. export class Tools {
  31607. /**
  31608. * Gets or sets the base URL to use to load assets
  31609. */
  31610. static BaseUrl: string;
  31611. /**
  31612. * Enable/Disable Custom HTTP Request Headers globally.
  31613. * default = false
  31614. * @see CustomRequestHeaders
  31615. */
  31616. static UseCustomRequestHeaders: boolean;
  31617. /**
  31618. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31619. * i.e. when loading files, where the server/service expects an Authorization header
  31620. */
  31621. static CustomRequestHeaders: {
  31622. [key: string]: string;
  31623. };
  31624. /**
  31625. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31626. */
  31627. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31628. /**
  31629. * Default behaviour for cors in the application.
  31630. * It can be a string if the expected behavior is identical in the entire app.
  31631. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31632. */
  31633. static CorsBehavior: string | ((url: string | string[]) => string);
  31634. /**
  31635. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31636. * @ignorenaming
  31637. */
  31638. static UseFallbackTexture: boolean;
  31639. /**
  31640. * Use this object to register external classes like custom textures or material
  31641. * to allow the laoders to instantiate them
  31642. */
  31643. static RegisteredExternalClasses: {
  31644. [key: string]: Object;
  31645. };
  31646. /**
  31647. * Texture content used if a texture cannot loaded
  31648. * @ignorenaming
  31649. */
  31650. static fallbackTexture: string;
  31651. /**
  31652. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31653. * @param u defines the coordinate on X axis
  31654. * @param v defines the coordinate on Y axis
  31655. * @param width defines the width of the source data
  31656. * @param height defines the height of the source data
  31657. * @param pixels defines the source byte array
  31658. * @param color defines the output color
  31659. */
  31660. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31661. /**
  31662. * Interpolates between a and b via alpha
  31663. * @param a The lower value (returned when alpha = 0)
  31664. * @param b The upper value (returned when alpha = 1)
  31665. * @param alpha The interpolation-factor
  31666. * @return The mixed value
  31667. */
  31668. static Mix(a: number, b: number, alpha: number): number;
  31669. /**
  31670. * Tries to instantiate a new object from a given class name
  31671. * @param className defines the class name to instantiate
  31672. * @returns the new object or null if the system was not able to do the instantiation
  31673. */
  31674. static Instantiate(className: string): any;
  31675. /**
  31676. * Provides a slice function that will work even on IE
  31677. * @param data defines the array to slice
  31678. * @param start defines the start of the data (optional)
  31679. * @param end defines the end of the data (optional)
  31680. * @returns the new sliced array
  31681. */
  31682. static Slice<T>(data: T, start?: number, end?: number): T;
  31683. /**
  31684. * Polyfill for setImmediate
  31685. * @param action defines the action to execute after the current execution block
  31686. */
  31687. static SetImmediate(action: () => void): void;
  31688. /**
  31689. * Function indicating if a number is an exponent of 2
  31690. * @param value defines the value to test
  31691. * @returns true if the value is an exponent of 2
  31692. */
  31693. static IsExponentOfTwo(value: number): boolean;
  31694. private static _tmpFloatArray;
  31695. /**
  31696. * Returns the nearest 32-bit single precision float representation of a Number
  31697. * @param value A Number. If the parameter is of a different type, it will get converted
  31698. * to a number or to NaN if it cannot be converted
  31699. * @returns number
  31700. */
  31701. static FloatRound(value: number): number;
  31702. /**
  31703. * Find the next highest power of two.
  31704. * @param x Number to start search from.
  31705. * @return Next highest power of two.
  31706. */
  31707. static CeilingPOT(x: number): number;
  31708. /**
  31709. * Find the next lowest power of two.
  31710. * @param x Number to start search from.
  31711. * @return Next lowest power of two.
  31712. */
  31713. static FloorPOT(x: number): number;
  31714. /**
  31715. * Find the nearest power of two.
  31716. * @param x Number to start search from.
  31717. * @return Next nearest power of two.
  31718. */
  31719. static NearestPOT(x: number): number;
  31720. /**
  31721. * Get the closest exponent of two
  31722. * @param value defines the value to approximate
  31723. * @param max defines the maximum value to return
  31724. * @param mode defines how to define the closest value
  31725. * @returns closest exponent of two of the given value
  31726. */
  31727. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31728. /**
  31729. * Extracts the filename from a path
  31730. * @param path defines the path to use
  31731. * @returns the filename
  31732. */
  31733. static GetFilename(path: string): string;
  31734. /**
  31735. * Extracts the "folder" part of a path (everything before the filename).
  31736. * @param uri The URI to extract the info from
  31737. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31738. * @returns The "folder" part of the path
  31739. */
  31740. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31741. /**
  31742. * Extracts text content from a DOM element hierarchy
  31743. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31744. */
  31745. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31746. /**
  31747. * Convert an angle in radians to degrees
  31748. * @param angle defines the angle to convert
  31749. * @returns the angle in degrees
  31750. */
  31751. static ToDegrees(angle: number): number;
  31752. /**
  31753. * Convert an angle in degrees to radians
  31754. * @param angle defines the angle to convert
  31755. * @returns the angle in radians
  31756. */
  31757. static ToRadians(angle: number): number;
  31758. /**
  31759. * Encode a buffer to a base64 string
  31760. * @param buffer defines the buffer to encode
  31761. * @returns the encoded string
  31762. */
  31763. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31764. /**
  31765. * Extracts minimum and maximum values from a list of indexed positions
  31766. * @param positions defines the positions to use
  31767. * @param indices defines the indices to the positions
  31768. * @param indexStart defines the start index
  31769. * @param indexCount defines the end index
  31770. * @param bias defines bias value to add to the result
  31771. * @return minimum and maximum values
  31772. */
  31773. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31774. minimum: Vector3;
  31775. maximum: Vector3;
  31776. };
  31777. /**
  31778. * Extracts minimum and maximum values from a list of positions
  31779. * @param positions defines the positions to use
  31780. * @param start defines the start index in the positions array
  31781. * @param count defines the number of positions to handle
  31782. * @param bias defines bias value to add to the result
  31783. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31784. * @return minimum and maximum values
  31785. */
  31786. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31787. minimum: Vector3;
  31788. maximum: Vector3;
  31789. };
  31790. /**
  31791. * Returns an array if obj is not an array
  31792. * @param obj defines the object to evaluate as an array
  31793. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31794. * @returns either obj directly if obj is an array or a new array containing obj
  31795. */
  31796. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31797. /**
  31798. * Gets the pointer prefix to use
  31799. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31800. */
  31801. static GetPointerPrefix(): string;
  31802. /**
  31803. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31804. * @param func - the function to be called
  31805. * @param requester - the object that will request the next frame. Falls back to window.
  31806. * @returns frame number
  31807. */
  31808. static QueueNewFrame(func: () => void, requester?: any): number;
  31809. /**
  31810. * Ask the browser to promote the current element to fullscreen rendering mode
  31811. * @param element defines the DOM element to promote
  31812. */
  31813. static RequestFullscreen(element: HTMLElement): void;
  31814. /**
  31815. * Asks the browser to exit fullscreen mode
  31816. */
  31817. static ExitFullscreen(): void;
  31818. /**
  31819. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31820. * @param url define the url we are trying
  31821. * @param element define the dom element where to configure the cors policy
  31822. */
  31823. static SetCorsBehavior(url: string | string[], element: {
  31824. crossOrigin: string | null;
  31825. }): void;
  31826. /**
  31827. * Removes unwanted characters from an url
  31828. * @param url defines the url to clean
  31829. * @returns the cleaned url
  31830. */
  31831. static CleanUrl(url: string): string;
  31832. /**
  31833. * Gets or sets a function used to pre-process url before using them to load assets
  31834. */
  31835. static PreprocessUrl: (url: string) => string;
  31836. /**
  31837. * Loads an image as an HTMLImageElement.
  31838. * @param input url string, ArrayBuffer, or Blob to load
  31839. * @param onLoad callback called when the image successfully loads
  31840. * @param onError callback called when the image fails to load
  31841. * @param offlineProvider offline provider for caching
  31842. * @returns the HTMLImageElement of the loaded image
  31843. */
  31844. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31845. /**
  31846. * Loads a file
  31847. * @param url url string, ArrayBuffer, or Blob to load
  31848. * @param onSuccess callback called when the file successfully loads
  31849. * @param onProgress callback called while file is loading (if the server supports this mode)
  31850. * @param offlineProvider defines the offline provider for caching
  31851. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31852. * @param onError callback called when the file fails to load
  31853. * @returns a file request object
  31854. */
  31855. 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;
  31856. /**
  31857. * Load a script (identified by an url). When the url returns, the
  31858. * content of this file is added into a new script element, attached to the DOM (body element)
  31859. * @param scriptUrl defines the url of the script to laod
  31860. * @param onSuccess defines the callback called when the script is loaded
  31861. * @param onError defines the callback to call if an error occurs
  31862. * @param scriptId defines the id of the script element
  31863. */
  31864. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31865. /**
  31866. * Load an asynchronous script (identified by an url). When the url returns, the
  31867. * content of this file is added into a new script element, attached to the DOM (body element)
  31868. * @param scriptUrl defines the url of the script to laod
  31869. * @param scriptId defines the id of the script element
  31870. * @returns a promise request object
  31871. */
  31872. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31873. /**
  31874. * Loads a file from a blob
  31875. * @param fileToLoad defines the blob to use
  31876. * @param callback defines the callback to call when data is loaded
  31877. * @param progressCallback defines the callback to call during loading process
  31878. * @returns a file request object
  31879. */
  31880. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31881. /**
  31882. * Loads a file
  31883. * @param fileToLoad defines the file to load
  31884. * @param callback defines the callback to call when data is loaded
  31885. * @param progressCallBack defines the callback to call during loading process
  31886. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31887. * @returns a file request object
  31888. */
  31889. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31890. /**
  31891. * Creates a data url from a given string content
  31892. * @param content defines the content to convert
  31893. * @returns the new data url link
  31894. */
  31895. static FileAsURL(content: string): string;
  31896. /**
  31897. * Format the given number to a specific decimal format
  31898. * @param value defines the number to format
  31899. * @param decimals defines the number of decimals to use
  31900. * @returns the formatted string
  31901. */
  31902. static Format(value: number, decimals?: number): string;
  31903. /**
  31904. * Checks if a given vector is inside a specific range
  31905. * @param v defines the vector to test
  31906. * @param min defines the minimum range
  31907. * @param max defines the maximum range
  31908. */
  31909. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31910. /**
  31911. * Tries to copy an object by duplicating every property
  31912. * @param source defines the source object
  31913. * @param destination defines the target object
  31914. * @param doNotCopyList defines a list of properties to avoid
  31915. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31916. */
  31917. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31918. /**
  31919. * Gets a boolean indicating if the given object has no own property
  31920. * @param obj defines the object to test
  31921. * @returns true if object has no own property
  31922. */
  31923. static IsEmpty(obj: any): boolean;
  31924. /**
  31925. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31926. * @param str Source string
  31927. * @param suffix Suffix to search for in the source string
  31928. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31929. */
  31930. static EndsWith(str: string, suffix: string): boolean;
  31931. /**
  31932. * Function used to register events at window level
  31933. * @param events defines the events to register
  31934. */
  31935. static RegisterTopRootEvents(events: {
  31936. name: string;
  31937. handler: Nullable<(e: FocusEvent) => any>;
  31938. }[]): void;
  31939. /**
  31940. * Function used to unregister events from window level
  31941. * @param events defines the events to unregister
  31942. */
  31943. static UnregisterTopRootEvents(events: {
  31944. name: string;
  31945. handler: Nullable<(e: FocusEvent) => any>;
  31946. }[]): void;
  31947. /**
  31948. * @ignore
  31949. */
  31950. static _ScreenshotCanvas: HTMLCanvasElement;
  31951. /**
  31952. * Dumps the current bound framebuffer
  31953. * @param width defines the rendering width
  31954. * @param height defines the rendering height
  31955. * @param engine defines the hosting engine
  31956. * @param successCallback defines the callback triggered once the data are available
  31957. * @param mimeType defines the mime type of the result
  31958. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31959. */
  31960. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31961. /**
  31962. * Converts the canvas data to blob.
  31963. * This acts as a polyfill for browsers not supporting the to blob function.
  31964. * @param canvas Defines the canvas to extract the data from
  31965. * @param successCallback Defines the callback triggered once the data are available
  31966. * @param mimeType Defines the mime type of the result
  31967. */
  31968. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31969. /**
  31970. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31971. * @param successCallback defines the callback triggered once the data are available
  31972. * @param mimeType defines the mime type of the result
  31973. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31974. */
  31975. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31976. /**
  31977. * Downloads a blob in the browser
  31978. * @param blob defines the blob to download
  31979. * @param fileName defines the name of the downloaded file
  31980. */
  31981. static Download(blob: Blob, fileName: string): void;
  31982. /**
  31983. * Captures a screenshot of the current rendering
  31984. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31985. * @param engine defines the rendering engine
  31986. * @param camera defines the source camera
  31987. * @param size This parameter can be set to a single number or to an object with the
  31988. * following (optional) properties: precision, width, height. If a single number is passed,
  31989. * it will be used for both width and height. If an object is passed, the screenshot size
  31990. * will be derived from the parameters. The precision property is a multiplier allowing
  31991. * rendering at a higher or lower resolution
  31992. * @param successCallback defines the callback receives a single parameter which contains the
  31993. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31994. * src parameter of an <img> to display it
  31995. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31996. * Check your browser for supported MIME types
  31997. */
  31998. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31999. /**
  32000. * Generates an image screenshot from the specified camera.
  32001. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32002. * @param engine The engine to use for rendering
  32003. * @param camera The camera to use for rendering
  32004. * @param size This parameter can be set to a single number or to an object with the
  32005. * following (optional) properties: precision, width, height. If a single number is passed,
  32006. * it will be used for both width and height. If an object is passed, the screenshot size
  32007. * will be derived from the parameters. The precision property is a multiplier allowing
  32008. * rendering at a higher or lower resolution
  32009. * @param successCallback The callback receives a single parameter which contains the
  32010. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32011. * src parameter of an <img> to display it
  32012. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32013. * Check your browser for supported MIME types
  32014. * @param samples Texture samples (default: 1)
  32015. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32016. * @param fileName A name for for the downloaded file.
  32017. */
  32018. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32019. /**
  32020. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32021. * Be aware Math.random() could cause collisions, but:
  32022. * "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"
  32023. * @returns a pseudo random id
  32024. */
  32025. static RandomId(): string;
  32026. /**
  32027. * Test if the given uri is a base64 string
  32028. * @param uri The uri to test
  32029. * @return True if the uri is a base64 string or false otherwise
  32030. */
  32031. static IsBase64(uri: string): boolean;
  32032. /**
  32033. * Decode the given base64 uri.
  32034. * @param uri The uri to decode
  32035. * @return The decoded base64 data.
  32036. */
  32037. static DecodeBase64(uri: string): ArrayBuffer;
  32038. /**
  32039. * Gets the absolute url.
  32040. * @param url the input url
  32041. * @return the absolute url
  32042. */
  32043. static GetAbsoluteUrl(url: string): string;
  32044. /**
  32045. * No log
  32046. */
  32047. static readonly NoneLogLevel: number;
  32048. /**
  32049. * Only message logs
  32050. */
  32051. static readonly MessageLogLevel: number;
  32052. /**
  32053. * Only warning logs
  32054. */
  32055. static readonly WarningLogLevel: number;
  32056. /**
  32057. * Only error logs
  32058. */
  32059. static readonly ErrorLogLevel: number;
  32060. /**
  32061. * All logs
  32062. */
  32063. static readonly AllLogLevel: number;
  32064. /**
  32065. * Gets a value indicating the number of loading errors
  32066. * @ignorenaming
  32067. */
  32068. static readonly errorsCount: number;
  32069. /**
  32070. * Callback called when a new log is added
  32071. */
  32072. static OnNewCacheEntry: (entry: string) => void;
  32073. /**
  32074. * Log a message to the console
  32075. * @param message defines the message to log
  32076. */
  32077. static Log(message: string): void;
  32078. /**
  32079. * Write a warning message to the console
  32080. * @param message defines the message to log
  32081. */
  32082. static Warn(message: string): void;
  32083. /**
  32084. * Write an error message to the console
  32085. * @param message defines the message to log
  32086. */
  32087. static Error(message: string): void;
  32088. /**
  32089. * Gets current log cache (list of logs)
  32090. */
  32091. static readonly LogCache: string;
  32092. /**
  32093. * Clears the log cache
  32094. */
  32095. static ClearLogCache(): void;
  32096. /**
  32097. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32098. */
  32099. static LogLevels: number;
  32100. /**
  32101. * Checks if the loaded document was accessed via `file:`-Protocol.
  32102. * @returns boolean
  32103. */
  32104. static IsFileURL(): boolean;
  32105. /**
  32106. * Checks if the window object exists
  32107. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32108. */
  32109. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32110. /**
  32111. * No performance log
  32112. */
  32113. static readonly PerformanceNoneLogLevel: number;
  32114. /**
  32115. * Use user marks to log performance
  32116. */
  32117. static readonly PerformanceUserMarkLogLevel: number;
  32118. /**
  32119. * Log performance to the console
  32120. */
  32121. static readonly PerformanceConsoleLogLevel: number;
  32122. private static _performance;
  32123. /**
  32124. * Sets the current performance log level
  32125. */
  32126. static PerformanceLogLevel: number;
  32127. private static _StartPerformanceCounterDisabled;
  32128. private static _EndPerformanceCounterDisabled;
  32129. private static _StartUserMark;
  32130. private static _EndUserMark;
  32131. private static _StartPerformanceConsole;
  32132. private static _EndPerformanceConsole;
  32133. /**
  32134. * Starts a performance counter
  32135. */
  32136. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32137. /**
  32138. * Ends a specific performance coutner
  32139. */
  32140. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32141. /**
  32142. * Gets either window.performance.now() if supported or Date.now() else
  32143. */
  32144. static readonly Now: number;
  32145. /**
  32146. * This method will return the name of the class used to create the instance of the given object.
  32147. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32148. * @param object the object to get the class name from
  32149. * @param isType defines if the object is actually a type
  32150. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32151. */
  32152. static GetClassName(object: any, isType?: boolean): string;
  32153. /**
  32154. * Gets the first element of an array satisfying a given predicate
  32155. * @param array defines the array to browse
  32156. * @param predicate defines the predicate to use
  32157. * @returns null if not found or the element
  32158. */
  32159. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32160. /**
  32161. * This method will return the name of the full name of the class, including its owning module (if any).
  32162. * 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).
  32163. * @param object the object to get the class name from
  32164. * @param isType defines if the object is actually a type
  32165. * @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.
  32166. * @ignorenaming
  32167. */
  32168. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32169. /**
  32170. * Returns a promise that resolves after the given amount of time.
  32171. * @param delay Number of milliseconds to delay
  32172. * @returns Promise that resolves after the given amount of time
  32173. */
  32174. static DelayAsync(delay: number): Promise<void>;
  32175. /**
  32176. * Gets the current gradient from an array of IValueGradient
  32177. * @param ratio defines the current ratio to get
  32178. * @param gradients defines the array of IValueGradient
  32179. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32180. */
  32181. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32182. }
  32183. /**
  32184. * This class is used to track a performance counter which is number based.
  32185. * The user has access to many properties which give statistics of different nature.
  32186. *
  32187. * The implementer can track two kinds of Performance Counter: time and count.
  32188. * 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.
  32189. * 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.
  32190. */
  32191. export class PerfCounter {
  32192. /**
  32193. * Gets or sets a global boolean to turn on and off all the counters
  32194. */
  32195. static Enabled: boolean;
  32196. /**
  32197. * Returns the smallest value ever
  32198. */
  32199. readonly min: number;
  32200. /**
  32201. * Returns the biggest value ever
  32202. */
  32203. readonly max: number;
  32204. /**
  32205. * Returns the average value since the performance counter is running
  32206. */
  32207. readonly average: number;
  32208. /**
  32209. * Returns the average value of the last second the counter was monitored
  32210. */
  32211. readonly lastSecAverage: number;
  32212. /**
  32213. * Returns the current value
  32214. */
  32215. readonly current: number;
  32216. /**
  32217. * Gets the accumulated total
  32218. */
  32219. readonly total: number;
  32220. /**
  32221. * Gets the total value count
  32222. */
  32223. readonly count: number;
  32224. /**
  32225. * Creates a new counter
  32226. */
  32227. constructor();
  32228. /**
  32229. * Call this method to start monitoring a new frame.
  32230. * 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.
  32231. */
  32232. fetchNewFrame(): void;
  32233. /**
  32234. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32235. * @param newCount the count value to add to the monitored count
  32236. * @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.
  32237. */
  32238. addCount(newCount: number, fetchResult: boolean): void;
  32239. /**
  32240. * Start monitoring this performance counter
  32241. */
  32242. beginMonitoring(): void;
  32243. /**
  32244. * Compute the time lapsed since the previous beginMonitoring() call.
  32245. * @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
  32246. */
  32247. endMonitoring(newFrame?: boolean): void;
  32248. private _fetchResult;
  32249. private _startMonitoringTime;
  32250. private _min;
  32251. private _max;
  32252. private _average;
  32253. private _current;
  32254. private _totalValueCount;
  32255. private _totalAccumulated;
  32256. private _lastSecAverage;
  32257. private _lastSecAccumulated;
  32258. private _lastSecTime;
  32259. private _lastSecValueCount;
  32260. }
  32261. /**
  32262. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32263. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32264. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32265. * @param name The name of the class, case should be preserved
  32266. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32267. */
  32268. export function className(name: string, module?: string): (target: Object) => void;
  32269. /**
  32270. * An implementation of a loop for asynchronous functions.
  32271. */
  32272. export class AsyncLoop {
  32273. /**
  32274. * Defines the number of iterations for the loop
  32275. */
  32276. iterations: number;
  32277. /**
  32278. * Defines the current index of the loop.
  32279. */
  32280. index: number;
  32281. private _done;
  32282. private _fn;
  32283. private _successCallback;
  32284. /**
  32285. * Constructor.
  32286. * @param iterations the number of iterations.
  32287. * @param func the function to run each iteration
  32288. * @param successCallback the callback that will be called upon succesful execution
  32289. * @param offset starting offset.
  32290. */
  32291. constructor(
  32292. /**
  32293. * Defines the number of iterations for the loop
  32294. */
  32295. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32296. /**
  32297. * Execute the next iteration. Must be called after the last iteration was finished.
  32298. */
  32299. executeNext(): void;
  32300. /**
  32301. * Break the loop and run the success callback.
  32302. */
  32303. breakLoop(): void;
  32304. /**
  32305. * Create and run an async loop.
  32306. * @param iterations the number of iterations.
  32307. * @param fn the function to run each iteration
  32308. * @param successCallback the callback that will be called upon succesful execution
  32309. * @param offset starting offset.
  32310. * @returns the created async loop object
  32311. */
  32312. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32313. /**
  32314. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32315. * @param iterations total number of iterations
  32316. * @param syncedIterations number of synchronous iterations in each async iteration.
  32317. * @param fn the function to call each iteration.
  32318. * @param callback a success call back that will be called when iterating stops.
  32319. * @param breakFunction a break condition (optional)
  32320. * @param timeout timeout settings for the setTimeout function. default - 0.
  32321. * @returns the created async loop object
  32322. */
  32323. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32324. }
  32325. }
  32326. declare module "babylonjs/Collisions/collisionCoordinator" {
  32327. import { Nullable } from "babylonjs/types";
  32328. import { Scene } from "babylonjs/scene";
  32329. import { Vector3 } from "babylonjs/Maths/math";
  32330. import { Collider } from "babylonjs/Collisions/collider";
  32331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32332. /** @hidden */
  32333. export interface ICollisionCoordinator {
  32334. createCollider(): Collider;
  32335. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32336. init(scene: Scene): void;
  32337. }
  32338. /** @hidden */
  32339. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32340. private _scene;
  32341. private _scaledPosition;
  32342. private _scaledVelocity;
  32343. private _finalPosition;
  32344. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32345. createCollider(): Collider;
  32346. init(scene: Scene): void;
  32347. private _collideWithWorld;
  32348. }
  32349. }
  32350. declare module "babylonjs/Inputs/scene.inputManager" {
  32351. import { Nullable } from "babylonjs/types";
  32352. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32353. import { Vector2 } from "babylonjs/Maths/math";
  32354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32355. import { Scene } from "babylonjs/scene";
  32356. /**
  32357. * Class used to manage all inputs for the scene.
  32358. */
  32359. export class InputManager {
  32360. /** The distance in pixel that you have to move to prevent some events */
  32361. static DragMovementThreshold: number;
  32362. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32363. static LongPressDelay: number;
  32364. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32365. static DoubleClickDelay: number;
  32366. /** If you need to check double click without raising a single click at first click, enable this flag */
  32367. static ExclusiveDoubleClickMode: boolean;
  32368. private _wheelEventName;
  32369. private _onPointerMove;
  32370. private _onPointerDown;
  32371. private _onPointerUp;
  32372. private _initClickEvent;
  32373. private _initActionManager;
  32374. private _delayedSimpleClick;
  32375. private _delayedSimpleClickTimeout;
  32376. private _previousDelayedSimpleClickTimeout;
  32377. private _meshPickProceed;
  32378. private _previousButtonPressed;
  32379. private _currentPickResult;
  32380. private _previousPickResult;
  32381. private _totalPointersPressed;
  32382. private _doubleClickOccured;
  32383. private _pointerOverMesh;
  32384. private _pickedDownMesh;
  32385. private _pickedUpMesh;
  32386. private _pointerX;
  32387. private _pointerY;
  32388. private _unTranslatedPointerX;
  32389. private _unTranslatedPointerY;
  32390. private _startingPointerPosition;
  32391. private _previousStartingPointerPosition;
  32392. private _startingPointerTime;
  32393. private _previousStartingPointerTime;
  32394. private _pointerCaptures;
  32395. private _onKeyDown;
  32396. private _onKeyUp;
  32397. private _onCanvasFocusObserver;
  32398. private _onCanvasBlurObserver;
  32399. private _scene;
  32400. /**
  32401. * Creates a new InputManager
  32402. * @param scene defines the hosting scene
  32403. */
  32404. constructor(scene: Scene);
  32405. /**
  32406. * Gets the mesh that is currently under the pointer
  32407. */
  32408. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32409. /**
  32410. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32411. */
  32412. readonly unTranslatedPointer: Vector2;
  32413. /**
  32414. * Gets or sets the current on-screen X position of the pointer
  32415. */
  32416. pointerX: number;
  32417. /**
  32418. * Gets or sets the current on-screen Y position of the pointer
  32419. */
  32420. pointerY: number;
  32421. private _updatePointerPosition;
  32422. private _processPointerMove;
  32423. private _setRayOnPointerInfo;
  32424. private _checkPrePointerObservable;
  32425. /**
  32426. * Use this method to simulate a pointer move on a mesh
  32427. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32428. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32429. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32430. */
  32431. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32432. /**
  32433. * Use this method to simulate a pointer down on a mesh
  32434. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32435. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32436. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32437. */
  32438. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32439. private _processPointerDown;
  32440. /** @hidden */
  32441. _isPointerSwiping(): boolean;
  32442. /**
  32443. * Use this method to simulate a pointer up on a mesh
  32444. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32445. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32446. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32447. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32448. */
  32449. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32450. private _processPointerUp;
  32451. /**
  32452. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32453. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32454. * @returns true if the pointer was captured
  32455. */
  32456. isPointerCaptured(pointerId?: number): boolean;
  32457. /**
  32458. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32459. * @param attachUp defines if you want to attach events to pointerup
  32460. * @param attachDown defines if you want to attach events to pointerdown
  32461. * @param attachMove defines if you want to attach events to pointermove
  32462. */
  32463. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32464. /**
  32465. * Detaches all event handlers
  32466. */
  32467. detachControl(): void;
  32468. /**
  32469. * Force the value of meshUnderPointer
  32470. * @param mesh defines the mesh to use
  32471. */
  32472. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32473. /**
  32474. * Gets the mesh under the pointer
  32475. * @returns a Mesh or null if no mesh is under the pointer
  32476. */
  32477. getPointerOverMesh(): Nullable<AbstractMesh>;
  32478. }
  32479. }
  32480. declare module "babylonjs/Animations/animationGroup" {
  32481. import { Animatable } from "babylonjs/Animations/animatable";
  32482. import { Animation } from "babylonjs/Animations/animation";
  32483. import { Scene, IDisposable } from "babylonjs/scene";
  32484. import { Observable } from "babylonjs/Misc/observable";
  32485. import { Nullable } from "babylonjs/types";
  32486. /**
  32487. * This class defines the direct association between an animation and a target
  32488. */
  32489. export class TargetedAnimation {
  32490. /**
  32491. * Animation to perform
  32492. */
  32493. animation: Animation;
  32494. /**
  32495. * Target to animate
  32496. */
  32497. target: any;
  32498. }
  32499. /**
  32500. * Use this class to create coordinated animations on multiple targets
  32501. */
  32502. export class AnimationGroup implements IDisposable {
  32503. /** The name of the animation group */
  32504. name: string;
  32505. private _scene;
  32506. private _targetedAnimations;
  32507. private _animatables;
  32508. private _from;
  32509. private _to;
  32510. private _isStarted;
  32511. private _isPaused;
  32512. private _speedRatio;
  32513. /**
  32514. * Gets or sets the unique id of the node
  32515. */
  32516. uniqueId: number;
  32517. /**
  32518. * This observable will notify when one animation have ended
  32519. */
  32520. onAnimationEndObservable: Observable<TargetedAnimation>;
  32521. /**
  32522. * Observer raised when one animation loops
  32523. */
  32524. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32525. /**
  32526. * This observable will notify when all animations have ended.
  32527. */
  32528. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32529. /**
  32530. * This observable will notify when all animations have paused.
  32531. */
  32532. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32533. /**
  32534. * This observable will notify when all animations are playing.
  32535. */
  32536. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32537. /**
  32538. * Gets the first frame
  32539. */
  32540. readonly from: number;
  32541. /**
  32542. * Gets the last frame
  32543. */
  32544. readonly to: number;
  32545. /**
  32546. * Define if the animations are started
  32547. */
  32548. readonly isStarted: boolean;
  32549. /**
  32550. * Gets a value indicating that the current group is playing
  32551. */
  32552. readonly isPlaying: boolean;
  32553. /**
  32554. * Gets or sets the speed ratio to use for all animations
  32555. */
  32556. /**
  32557. * Gets or sets the speed ratio to use for all animations
  32558. */
  32559. speedRatio: number;
  32560. /**
  32561. * Gets the targeted animations for this animation group
  32562. */
  32563. readonly targetedAnimations: Array<TargetedAnimation>;
  32564. /**
  32565. * returning the list of animatables controlled by this animation group.
  32566. */
  32567. readonly animatables: Array<Animatable>;
  32568. /**
  32569. * Instantiates a new Animation Group.
  32570. * This helps managing several animations at once.
  32571. * @see http://doc.babylonjs.com/how_to/group
  32572. * @param name Defines the name of the group
  32573. * @param scene Defines the scene the group belongs to
  32574. */
  32575. constructor(
  32576. /** The name of the animation group */
  32577. name: string, scene?: Nullable<Scene>);
  32578. /**
  32579. * Add an animation (with its target) in the group
  32580. * @param animation defines the animation we want to add
  32581. * @param target defines the target of the animation
  32582. * @returns the TargetedAnimation object
  32583. */
  32584. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32585. /**
  32586. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32587. * It can add constant keys at begin or end
  32588. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32589. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32590. * @returns the animation group
  32591. */
  32592. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32593. /**
  32594. * Start all animations on given targets
  32595. * @param loop defines if animations must loop
  32596. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32597. * @param from defines the from key (optional)
  32598. * @param to defines the to key (optional)
  32599. * @returns the current animation group
  32600. */
  32601. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32602. /**
  32603. * Pause all animations
  32604. * @returns the animation group
  32605. */
  32606. pause(): AnimationGroup;
  32607. /**
  32608. * Play all animations to initial state
  32609. * This function will start() the animations if they were not started or will restart() them if they were paused
  32610. * @param loop defines if animations must loop
  32611. * @returns the animation group
  32612. */
  32613. play(loop?: boolean): AnimationGroup;
  32614. /**
  32615. * Reset all animations to initial state
  32616. * @returns the animation group
  32617. */
  32618. reset(): AnimationGroup;
  32619. /**
  32620. * Restart animations from key 0
  32621. * @returns the animation group
  32622. */
  32623. restart(): AnimationGroup;
  32624. /**
  32625. * Stop all animations
  32626. * @returns the animation group
  32627. */
  32628. stop(): AnimationGroup;
  32629. /**
  32630. * Set animation weight for all animatables
  32631. * @param weight defines the weight to use
  32632. * @return the animationGroup
  32633. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32634. */
  32635. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32636. /**
  32637. * Synchronize and normalize all animatables with a source animatable
  32638. * @param root defines the root animatable to synchronize with
  32639. * @return the animationGroup
  32640. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32641. */
  32642. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32643. /**
  32644. * Goes to a specific frame in this animation group
  32645. * @param frame the frame number to go to
  32646. * @return the animationGroup
  32647. */
  32648. goToFrame(frame: number): AnimationGroup;
  32649. /**
  32650. * Dispose all associated resources
  32651. */
  32652. dispose(): void;
  32653. private _checkAnimationGroupEnded;
  32654. /**
  32655. * Clone the current animation group and returns a copy
  32656. * @param newName defines the name of the new group
  32657. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32658. * @returns the new aniamtion group
  32659. */
  32660. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32661. /**
  32662. * Returns a new AnimationGroup object parsed from the source provided.
  32663. * @param parsedAnimationGroup defines the source
  32664. * @param scene defines the scene that will receive the animationGroup
  32665. * @returns a new AnimationGroup
  32666. */
  32667. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32668. /**
  32669. * Returns the string "AnimationGroup"
  32670. * @returns "AnimationGroup"
  32671. */
  32672. getClassName(): string;
  32673. /**
  32674. * Creates a detailled string about the object
  32675. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32676. * @returns a string representing the object
  32677. */
  32678. toString(fullDetails?: boolean): string;
  32679. }
  32680. }
  32681. declare module "babylonjs/scene" {
  32682. import { Nullable } from "babylonjs/types";
  32683. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32684. import { Observable } from "babylonjs/Misc/observable";
  32685. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32686. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32687. import { Geometry } from "babylonjs/Meshes/geometry";
  32688. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32689. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32691. import { Mesh } from "babylonjs/Meshes/mesh";
  32692. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32693. import { Bone } from "babylonjs/Bones/bone";
  32694. import { Skeleton } from "babylonjs/Bones/skeleton";
  32695. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32696. import { Camera } from "babylonjs/Cameras/camera";
  32697. import { AbstractScene } from "babylonjs/abstractScene";
  32698. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32699. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32700. import { Material } from "babylonjs/Materials/material";
  32701. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32702. import { Effect } from "babylonjs/Materials/effect";
  32703. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32704. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32705. import { Light } from "babylonjs/Lights/light";
  32706. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32707. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32708. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32709. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32710. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32711. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32712. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32713. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32714. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32715. import { Engine } from "babylonjs/Engines/engine";
  32716. import { Node } from "babylonjs/node";
  32717. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32718. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32719. import { WebRequest } from "babylonjs/Misc/webRequest";
  32720. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32721. import { Ray } from "babylonjs/Culling/ray";
  32722. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32723. import { Animation } from "babylonjs/Animations/animation";
  32724. import { Animatable } from "babylonjs/Animations/animatable";
  32725. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32726. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32727. import { Collider } from "babylonjs/Collisions/collider";
  32728. /**
  32729. * Define an interface for all classes that will hold resources
  32730. */
  32731. export interface IDisposable {
  32732. /**
  32733. * Releases all held resources
  32734. */
  32735. dispose(): void;
  32736. }
  32737. /** Interface defining initialization parameters for Scene class */
  32738. export interface SceneOptions {
  32739. /**
  32740. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32741. * It will improve performance when the number of geometries becomes important.
  32742. */
  32743. useGeometryUniqueIdsMap?: boolean;
  32744. /**
  32745. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32746. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32747. */
  32748. useMaterialMeshMap?: boolean;
  32749. /**
  32750. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32751. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32752. */
  32753. useClonedMeshhMap?: boolean;
  32754. }
  32755. /**
  32756. * Represents a scene to be rendered by the engine.
  32757. * @see http://doc.babylonjs.com/features/scene
  32758. */
  32759. export class Scene extends AbstractScene implements IAnimatable {
  32760. private static _uniqueIdCounter;
  32761. /** The fog is deactivated */
  32762. static readonly FOGMODE_NONE: number;
  32763. /** The fog density is following an exponential function */
  32764. static readonly FOGMODE_EXP: number;
  32765. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32766. static readonly FOGMODE_EXP2: number;
  32767. /** The fog density is following a linear function. */
  32768. static readonly FOGMODE_LINEAR: number;
  32769. /**
  32770. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32771. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32772. */
  32773. static MinDeltaTime: number;
  32774. /**
  32775. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32776. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32777. */
  32778. static MaxDeltaTime: number;
  32779. /**
  32780. * Factory used to create the default material.
  32781. * @param name The name of the material to create
  32782. * @param scene The scene to create the material for
  32783. * @returns The default material
  32784. */
  32785. static DefaultMaterialFactory(scene: Scene): Material;
  32786. /**
  32787. * Factory used to create the a collision coordinator.
  32788. * @returns The collision coordinator
  32789. */
  32790. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32791. /** @hidden */
  32792. _inputManager: InputManager;
  32793. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32794. cameraToUseForPointers: Nullable<Camera>;
  32795. /** @hidden */
  32796. readonly _isScene: boolean;
  32797. /**
  32798. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32799. */
  32800. autoClear: boolean;
  32801. /**
  32802. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32803. */
  32804. autoClearDepthAndStencil: boolean;
  32805. /**
  32806. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32807. */
  32808. clearColor: Color4;
  32809. /**
  32810. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32811. */
  32812. ambientColor: Color3;
  32813. /**
  32814. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32815. * It should only be one of the following (if not the default embedded one):
  32816. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32817. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32818. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32819. * The material properties need to be setup according to the type of texture in use.
  32820. */
  32821. environmentBRDFTexture: BaseTexture;
  32822. /** @hidden */
  32823. protected _environmentTexture: Nullable<BaseTexture>;
  32824. /**
  32825. * Texture used in all pbr material as the reflection texture.
  32826. * As in the majority of the scene they are the same (exception for multi room and so on),
  32827. * this is easier to reference from here than from all the materials.
  32828. */
  32829. /**
  32830. * Texture used in all pbr material as the reflection texture.
  32831. * As in the majority of the scene they are the same (exception for multi room and so on),
  32832. * this is easier to set here than in all the materials.
  32833. */
  32834. environmentTexture: Nullable<BaseTexture>;
  32835. /** @hidden */
  32836. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32837. /**
  32838. * Default image processing configuration used either in the rendering
  32839. * Forward main pass or through the imageProcessingPostProcess if present.
  32840. * As in the majority of the scene they are the same (exception for multi camera),
  32841. * this is easier to reference from here than from all the materials and post process.
  32842. *
  32843. * No setter as we it is a shared configuration, you can set the values instead.
  32844. */
  32845. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32846. private _forceWireframe;
  32847. /**
  32848. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32849. */
  32850. forceWireframe: boolean;
  32851. private _forcePointsCloud;
  32852. /**
  32853. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32854. */
  32855. forcePointsCloud: boolean;
  32856. /**
  32857. * Gets or sets the active clipplane 1
  32858. */
  32859. clipPlane: Nullable<Plane>;
  32860. /**
  32861. * Gets or sets the active clipplane 2
  32862. */
  32863. clipPlane2: Nullable<Plane>;
  32864. /**
  32865. * Gets or sets the active clipplane 3
  32866. */
  32867. clipPlane3: Nullable<Plane>;
  32868. /**
  32869. * Gets or sets the active clipplane 4
  32870. */
  32871. clipPlane4: Nullable<Plane>;
  32872. /**
  32873. * Gets or sets a boolean indicating if animations are enabled
  32874. */
  32875. animationsEnabled: boolean;
  32876. private _animationPropertiesOverride;
  32877. /**
  32878. * Gets or sets the animation properties override
  32879. */
  32880. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32881. /**
  32882. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32883. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32884. */
  32885. useConstantAnimationDeltaTime: boolean;
  32886. /**
  32887. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32888. * Please note that it requires to run a ray cast through the scene on every frame
  32889. */
  32890. constantlyUpdateMeshUnderPointer: boolean;
  32891. /**
  32892. * Defines the HTML cursor to use when hovering over interactive elements
  32893. */
  32894. hoverCursor: string;
  32895. /**
  32896. * Defines the HTML default cursor to use (empty by default)
  32897. */
  32898. defaultCursor: string;
  32899. /**
  32900. * This is used to call preventDefault() on pointer down
  32901. * in order to block unwanted artifacts like system double clicks
  32902. */
  32903. preventDefaultOnPointerDown: boolean;
  32904. /**
  32905. * This is used to call preventDefault() on pointer up
  32906. * in order to block unwanted artifacts like system double clicks
  32907. */
  32908. preventDefaultOnPointerUp: boolean;
  32909. /**
  32910. * Gets or sets user defined metadata
  32911. */
  32912. metadata: any;
  32913. /**
  32914. * For internal use only. Please do not use.
  32915. */
  32916. reservedDataStore: any;
  32917. /**
  32918. * Gets the name of the plugin used to load this scene (null by default)
  32919. */
  32920. loadingPluginName: string;
  32921. /**
  32922. * Use this array to add regular expressions used to disable offline support for specific urls
  32923. */
  32924. disableOfflineSupportExceptionRules: RegExp[];
  32925. /**
  32926. * An event triggered when the scene is disposed.
  32927. */
  32928. onDisposeObservable: Observable<Scene>;
  32929. private _onDisposeObserver;
  32930. /** Sets a function to be executed when this scene is disposed. */
  32931. onDispose: () => void;
  32932. /**
  32933. * An event triggered before rendering the scene (right after animations and physics)
  32934. */
  32935. onBeforeRenderObservable: Observable<Scene>;
  32936. private _onBeforeRenderObserver;
  32937. /** Sets a function to be executed before rendering this scene */
  32938. beforeRender: Nullable<() => void>;
  32939. /**
  32940. * An event triggered after rendering the scene
  32941. */
  32942. onAfterRenderObservable: Observable<Scene>;
  32943. private _onAfterRenderObserver;
  32944. /** Sets a function to be executed after rendering this scene */
  32945. afterRender: Nullable<() => void>;
  32946. /**
  32947. * An event triggered before animating the scene
  32948. */
  32949. onBeforeAnimationsObservable: Observable<Scene>;
  32950. /**
  32951. * An event triggered after animations processing
  32952. */
  32953. onAfterAnimationsObservable: Observable<Scene>;
  32954. /**
  32955. * An event triggered before draw calls are ready to be sent
  32956. */
  32957. onBeforeDrawPhaseObservable: Observable<Scene>;
  32958. /**
  32959. * An event triggered after draw calls have been sent
  32960. */
  32961. onAfterDrawPhaseObservable: Observable<Scene>;
  32962. /**
  32963. * An event triggered when the scene is ready
  32964. */
  32965. onReadyObservable: Observable<Scene>;
  32966. /**
  32967. * An event triggered before rendering a camera
  32968. */
  32969. onBeforeCameraRenderObservable: Observable<Camera>;
  32970. private _onBeforeCameraRenderObserver;
  32971. /** Sets a function to be executed before rendering a camera*/
  32972. beforeCameraRender: () => void;
  32973. /**
  32974. * An event triggered after rendering a camera
  32975. */
  32976. onAfterCameraRenderObservable: Observable<Camera>;
  32977. private _onAfterCameraRenderObserver;
  32978. /** Sets a function to be executed after rendering a camera*/
  32979. afterCameraRender: () => void;
  32980. /**
  32981. * An event triggered when active meshes evaluation is about to start
  32982. */
  32983. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32984. /**
  32985. * An event triggered when active meshes evaluation is done
  32986. */
  32987. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32988. /**
  32989. * An event triggered when particles rendering is about to start
  32990. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32991. */
  32992. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32993. /**
  32994. * An event triggered when particles rendering is done
  32995. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32996. */
  32997. onAfterParticlesRenderingObservable: Observable<Scene>;
  32998. /**
  32999. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33000. */
  33001. onDataLoadedObservable: Observable<Scene>;
  33002. /**
  33003. * An event triggered when a camera is created
  33004. */
  33005. onNewCameraAddedObservable: Observable<Camera>;
  33006. /**
  33007. * An event triggered when a camera is removed
  33008. */
  33009. onCameraRemovedObservable: Observable<Camera>;
  33010. /**
  33011. * An event triggered when a light is created
  33012. */
  33013. onNewLightAddedObservable: Observable<Light>;
  33014. /**
  33015. * An event triggered when a light is removed
  33016. */
  33017. onLightRemovedObservable: Observable<Light>;
  33018. /**
  33019. * An event triggered when a geometry is created
  33020. */
  33021. onNewGeometryAddedObservable: Observable<Geometry>;
  33022. /**
  33023. * An event triggered when a geometry is removed
  33024. */
  33025. onGeometryRemovedObservable: Observable<Geometry>;
  33026. /**
  33027. * An event triggered when a transform node is created
  33028. */
  33029. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33030. /**
  33031. * An event triggered when a transform node is removed
  33032. */
  33033. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33034. /**
  33035. * An event triggered when a mesh is created
  33036. */
  33037. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33038. /**
  33039. * An event triggered when a mesh is removed
  33040. */
  33041. onMeshRemovedObservable: Observable<AbstractMesh>;
  33042. /**
  33043. * An event triggered when a skeleton is created
  33044. */
  33045. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33046. /**
  33047. * An event triggered when a skeleton is removed
  33048. */
  33049. onSkeletonRemovedObservable: Observable<Skeleton>;
  33050. /**
  33051. * An event triggered when a material is created
  33052. */
  33053. onNewMaterialAddedObservable: Observable<Material>;
  33054. /**
  33055. * An event triggered when a material is removed
  33056. */
  33057. onMaterialRemovedObservable: Observable<Material>;
  33058. /**
  33059. * An event triggered when a texture is created
  33060. */
  33061. onNewTextureAddedObservable: Observable<BaseTexture>;
  33062. /**
  33063. * An event triggered when a texture is removed
  33064. */
  33065. onTextureRemovedObservable: Observable<BaseTexture>;
  33066. /**
  33067. * An event triggered when render targets are about to be rendered
  33068. * Can happen multiple times per frame.
  33069. */
  33070. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33071. /**
  33072. * An event triggered when render targets were rendered.
  33073. * Can happen multiple times per frame.
  33074. */
  33075. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33076. /**
  33077. * An event triggered before calculating deterministic simulation step
  33078. */
  33079. onBeforeStepObservable: Observable<Scene>;
  33080. /**
  33081. * An event triggered after calculating deterministic simulation step
  33082. */
  33083. onAfterStepObservable: Observable<Scene>;
  33084. /**
  33085. * An event triggered when the activeCamera property is updated
  33086. */
  33087. onActiveCameraChanged: Observable<Scene>;
  33088. /**
  33089. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33090. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33091. * 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)
  33092. */
  33093. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33094. /**
  33095. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33096. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33097. * 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)
  33098. */
  33099. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33100. /**
  33101. * This Observable will when a mesh has been imported into the scene.
  33102. */
  33103. onMeshImportedObservable: Observable<AbstractMesh>;
  33104. /**
  33105. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33106. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33107. */
  33108. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33109. /** @hidden */
  33110. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33111. /**
  33112. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33113. */
  33114. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33115. /**
  33116. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33117. */
  33118. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33119. /**
  33120. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33121. */
  33122. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33123. /** Callback called when a pointer move is detected */
  33124. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33125. /** Callback called when a pointer down is detected */
  33126. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33127. /** Callback called when a pointer up is detected */
  33128. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33129. /** Callback called when a pointer pick is detected */
  33130. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33131. /**
  33132. * 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).
  33133. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33134. */
  33135. onPrePointerObservable: Observable<PointerInfoPre>;
  33136. /**
  33137. * Observable event triggered each time an input event is received from the rendering canvas
  33138. */
  33139. onPointerObservable: Observable<PointerInfo>;
  33140. /**
  33141. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33142. */
  33143. readonly unTranslatedPointer: Vector2;
  33144. /**
  33145. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33146. */
  33147. static DragMovementThreshold: number;
  33148. /**
  33149. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33150. */
  33151. static LongPressDelay: number;
  33152. /**
  33153. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33154. */
  33155. static DoubleClickDelay: number;
  33156. /** If you need to check double click without raising a single click at first click, enable this flag */
  33157. static ExclusiveDoubleClickMode: boolean;
  33158. /** @hidden */
  33159. _mirroredCameraPosition: Nullable<Vector3>;
  33160. /**
  33161. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33162. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33163. */
  33164. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33165. /**
  33166. * Observable event triggered each time an keyboard event is received from the hosting window
  33167. */
  33168. onKeyboardObservable: Observable<KeyboardInfo>;
  33169. private _useRightHandedSystem;
  33170. /**
  33171. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33172. */
  33173. useRightHandedSystem: boolean;
  33174. private _timeAccumulator;
  33175. private _currentStepId;
  33176. private _currentInternalStep;
  33177. /**
  33178. * Sets the step Id used by deterministic lock step
  33179. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33180. * @param newStepId defines the step Id
  33181. */
  33182. setStepId(newStepId: number): void;
  33183. /**
  33184. * Gets the step Id used by deterministic lock step
  33185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33186. * @returns the step Id
  33187. */
  33188. getStepId(): number;
  33189. /**
  33190. * Gets the internal step used by deterministic lock step
  33191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33192. * @returns the internal step
  33193. */
  33194. getInternalStep(): number;
  33195. private _fogEnabled;
  33196. /**
  33197. * Gets or sets a boolean indicating if fog is enabled on this scene
  33198. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33199. * (Default is true)
  33200. */
  33201. fogEnabled: boolean;
  33202. private _fogMode;
  33203. /**
  33204. * Gets or sets the fog mode to use
  33205. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33206. * | mode | value |
  33207. * | --- | --- |
  33208. * | FOGMODE_NONE | 0 |
  33209. * | FOGMODE_EXP | 1 |
  33210. * | FOGMODE_EXP2 | 2 |
  33211. * | FOGMODE_LINEAR | 3 |
  33212. */
  33213. fogMode: number;
  33214. /**
  33215. * Gets or sets the fog color to use
  33216. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33217. * (Default is Color3(0.2, 0.2, 0.3))
  33218. */
  33219. fogColor: Color3;
  33220. /**
  33221. * Gets or sets the fog density to use
  33222. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33223. * (Default is 0.1)
  33224. */
  33225. fogDensity: number;
  33226. /**
  33227. * Gets or sets the fog start distance to use
  33228. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33229. * (Default is 0)
  33230. */
  33231. fogStart: number;
  33232. /**
  33233. * Gets or sets the fog end distance to use
  33234. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33235. * (Default is 1000)
  33236. */
  33237. fogEnd: number;
  33238. private _shadowsEnabled;
  33239. /**
  33240. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33241. */
  33242. shadowsEnabled: boolean;
  33243. private _lightsEnabled;
  33244. /**
  33245. * Gets or sets a boolean indicating if lights are enabled on this scene
  33246. */
  33247. lightsEnabled: boolean;
  33248. /** All of the active cameras added to this scene. */
  33249. activeCameras: Camera[];
  33250. /** @hidden */
  33251. _activeCamera: Nullable<Camera>;
  33252. /** Gets or sets the current active camera */
  33253. activeCamera: Nullable<Camera>;
  33254. private _defaultMaterial;
  33255. /** The default material used on meshes when no material is affected */
  33256. /** The default material used on meshes when no material is affected */
  33257. defaultMaterial: Material;
  33258. private _texturesEnabled;
  33259. /**
  33260. * Gets or sets a boolean indicating if textures are enabled on this scene
  33261. */
  33262. texturesEnabled: boolean;
  33263. /**
  33264. * Gets or sets a boolean indicating if particles are enabled on this scene
  33265. */
  33266. particlesEnabled: boolean;
  33267. /**
  33268. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33269. */
  33270. spritesEnabled: boolean;
  33271. private _skeletonsEnabled;
  33272. /**
  33273. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33274. */
  33275. skeletonsEnabled: boolean;
  33276. /**
  33277. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33278. */
  33279. lensFlaresEnabled: boolean;
  33280. /**
  33281. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33282. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33283. */
  33284. collisionsEnabled: boolean;
  33285. private _collisionCoordinator;
  33286. /** @hidden */
  33287. readonly collisionCoordinator: ICollisionCoordinator;
  33288. /**
  33289. * Defines the gravity applied to this scene (used only for collisions)
  33290. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33291. */
  33292. gravity: Vector3;
  33293. /**
  33294. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33295. */
  33296. postProcessesEnabled: boolean;
  33297. /**
  33298. * The list of postprocesses added to the scene
  33299. */
  33300. postProcesses: PostProcess[];
  33301. /**
  33302. * Gets the current postprocess manager
  33303. */
  33304. postProcessManager: PostProcessManager;
  33305. /**
  33306. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33307. */
  33308. renderTargetsEnabled: boolean;
  33309. /**
  33310. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33311. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33312. */
  33313. dumpNextRenderTargets: boolean;
  33314. /**
  33315. * The list of user defined render targets added to the scene
  33316. */
  33317. customRenderTargets: RenderTargetTexture[];
  33318. /**
  33319. * Defines if texture loading must be delayed
  33320. * If true, textures will only be loaded when they need to be rendered
  33321. */
  33322. useDelayedTextureLoading: boolean;
  33323. /**
  33324. * Gets the list of meshes imported to the scene through SceneLoader
  33325. */
  33326. importedMeshesFiles: String[];
  33327. /**
  33328. * Gets or sets a boolean indicating if probes are enabled on this scene
  33329. */
  33330. probesEnabled: boolean;
  33331. /**
  33332. * Gets or sets the current offline provider to use to store scene data
  33333. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33334. */
  33335. offlineProvider: IOfflineProvider;
  33336. /**
  33337. * Gets or sets the action manager associated with the scene
  33338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33339. */
  33340. actionManager: AbstractActionManager;
  33341. private _meshesForIntersections;
  33342. /**
  33343. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33344. */
  33345. proceduralTexturesEnabled: boolean;
  33346. private _engine;
  33347. private _totalVertices;
  33348. /** @hidden */
  33349. _activeIndices: PerfCounter;
  33350. /** @hidden */
  33351. _activeParticles: PerfCounter;
  33352. /** @hidden */
  33353. _activeBones: PerfCounter;
  33354. private _animationRatio;
  33355. /** @hidden */
  33356. _animationTimeLast: number;
  33357. /** @hidden */
  33358. _animationTime: number;
  33359. /**
  33360. * Gets or sets a general scale for animation speed
  33361. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33362. */
  33363. animationTimeScale: number;
  33364. /** @hidden */
  33365. _cachedMaterial: Nullable<Material>;
  33366. /** @hidden */
  33367. _cachedEffect: Nullable<Effect>;
  33368. /** @hidden */
  33369. _cachedVisibility: Nullable<number>;
  33370. private _renderId;
  33371. private _frameId;
  33372. private _executeWhenReadyTimeoutId;
  33373. private _intermediateRendering;
  33374. private _viewUpdateFlag;
  33375. private _projectionUpdateFlag;
  33376. /** @hidden */
  33377. _toBeDisposed: Nullable<IDisposable>[];
  33378. private _activeRequests;
  33379. /** @hidden */
  33380. _pendingData: any[];
  33381. private _isDisposed;
  33382. /**
  33383. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33384. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33385. */
  33386. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33387. private _activeMeshes;
  33388. private _processedMaterials;
  33389. private _renderTargets;
  33390. /** @hidden */
  33391. _activeParticleSystems: SmartArray<IParticleSystem>;
  33392. private _activeSkeletons;
  33393. private _softwareSkinnedMeshes;
  33394. private _renderingManager;
  33395. /** @hidden */
  33396. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33397. private _transformMatrix;
  33398. private _sceneUbo;
  33399. /** @hidden */
  33400. _viewMatrix: Matrix;
  33401. private _projectionMatrix;
  33402. /** @hidden */
  33403. _forcedViewPosition: Nullable<Vector3>;
  33404. /** @hidden */
  33405. _frustumPlanes: Plane[];
  33406. /**
  33407. * Gets the list of frustum planes (built from the active camera)
  33408. */
  33409. readonly frustumPlanes: Plane[];
  33410. /**
  33411. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33412. * This is useful if there are more lights that the maximum simulteanous authorized
  33413. */
  33414. requireLightSorting: boolean;
  33415. /** @hidden */
  33416. readonly useMaterialMeshMap: boolean;
  33417. /** @hidden */
  33418. readonly useClonedMeshhMap: boolean;
  33419. private _externalData;
  33420. private _uid;
  33421. /**
  33422. * @hidden
  33423. * Backing store of defined scene components.
  33424. */
  33425. _components: ISceneComponent[];
  33426. /**
  33427. * @hidden
  33428. * Backing store of defined scene components.
  33429. */
  33430. _serializableComponents: ISceneSerializableComponent[];
  33431. /**
  33432. * List of components to register on the next registration step.
  33433. */
  33434. private _transientComponents;
  33435. /**
  33436. * Registers the transient components if needed.
  33437. */
  33438. private _registerTransientComponents;
  33439. /**
  33440. * @hidden
  33441. * Add a component to the scene.
  33442. * Note that the ccomponent could be registered on th next frame if this is called after
  33443. * the register component stage.
  33444. * @param component Defines the component to add to the scene
  33445. */
  33446. _addComponent(component: ISceneComponent): void;
  33447. /**
  33448. * @hidden
  33449. * Gets a component from the scene.
  33450. * @param name defines the name of the component to retrieve
  33451. * @returns the component or null if not present
  33452. */
  33453. _getComponent(name: string): Nullable<ISceneComponent>;
  33454. /**
  33455. * @hidden
  33456. * Defines the actions happening before camera updates.
  33457. */
  33458. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33459. /**
  33460. * @hidden
  33461. * Defines the actions happening before clear the canvas.
  33462. */
  33463. _beforeClearStage: Stage<SimpleStageAction>;
  33464. /**
  33465. * @hidden
  33466. * Defines the actions when collecting render targets for the frame.
  33467. */
  33468. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33469. /**
  33470. * @hidden
  33471. * Defines the actions happening for one camera in the frame.
  33472. */
  33473. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33474. /**
  33475. * @hidden
  33476. * Defines the actions happening during the per mesh ready checks.
  33477. */
  33478. _isReadyForMeshStage: Stage<MeshStageAction>;
  33479. /**
  33480. * @hidden
  33481. * Defines the actions happening before evaluate active mesh checks.
  33482. */
  33483. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33484. /**
  33485. * @hidden
  33486. * Defines the actions happening during the evaluate sub mesh checks.
  33487. */
  33488. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33489. /**
  33490. * @hidden
  33491. * Defines the actions happening during the active mesh stage.
  33492. */
  33493. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33494. /**
  33495. * @hidden
  33496. * Defines the actions happening during the per camera render target step.
  33497. */
  33498. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33499. /**
  33500. * @hidden
  33501. * Defines the actions happening just before the active camera is drawing.
  33502. */
  33503. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33504. /**
  33505. * @hidden
  33506. * Defines the actions happening just before a render target is drawing.
  33507. */
  33508. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33509. /**
  33510. * @hidden
  33511. * Defines the actions happening just before a rendering group is drawing.
  33512. */
  33513. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33514. /**
  33515. * @hidden
  33516. * Defines the actions happening just before a mesh is drawing.
  33517. */
  33518. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33519. /**
  33520. * @hidden
  33521. * Defines the actions happening just after a mesh has been drawn.
  33522. */
  33523. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33524. /**
  33525. * @hidden
  33526. * Defines the actions happening just after a rendering group has been drawn.
  33527. */
  33528. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33529. /**
  33530. * @hidden
  33531. * Defines the actions happening just after the active camera has been drawn.
  33532. */
  33533. _afterCameraDrawStage: Stage<CameraStageAction>;
  33534. /**
  33535. * @hidden
  33536. * Defines the actions happening just after a render target has been drawn.
  33537. */
  33538. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33539. /**
  33540. * @hidden
  33541. * Defines the actions happening just after rendering all cameras and computing intersections.
  33542. */
  33543. _afterRenderStage: Stage<SimpleStageAction>;
  33544. /**
  33545. * @hidden
  33546. * Defines the actions happening when a pointer move event happens.
  33547. */
  33548. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33549. /**
  33550. * @hidden
  33551. * Defines the actions happening when a pointer down event happens.
  33552. */
  33553. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33554. /**
  33555. * @hidden
  33556. * Defines the actions happening when a pointer up event happens.
  33557. */
  33558. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33559. /**
  33560. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33561. */
  33562. private geometriesByUniqueId;
  33563. /**
  33564. * Creates a new Scene
  33565. * @param engine defines the engine to use to render this scene
  33566. * @param options defines the scene options
  33567. */
  33568. constructor(engine: Engine, options?: SceneOptions);
  33569. /**
  33570. * Gets a string idenfifying the name of the class
  33571. * @returns "Scene" string
  33572. */
  33573. getClassName(): string;
  33574. private _defaultMeshCandidates;
  33575. /**
  33576. * @hidden
  33577. */
  33578. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33579. private _defaultSubMeshCandidates;
  33580. /**
  33581. * @hidden
  33582. */
  33583. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33584. /**
  33585. * Sets the default candidate providers for the scene.
  33586. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33587. * and getCollidingSubMeshCandidates to their default function
  33588. */
  33589. setDefaultCandidateProviders(): void;
  33590. /**
  33591. * Gets the mesh that is currently under the pointer
  33592. */
  33593. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33594. /**
  33595. * Gets or sets the current on-screen X position of the pointer
  33596. */
  33597. pointerX: number;
  33598. /**
  33599. * Gets or sets the current on-screen Y position of the pointer
  33600. */
  33601. pointerY: number;
  33602. /**
  33603. * Gets the cached material (ie. the latest rendered one)
  33604. * @returns the cached material
  33605. */
  33606. getCachedMaterial(): Nullable<Material>;
  33607. /**
  33608. * Gets the cached effect (ie. the latest rendered one)
  33609. * @returns the cached effect
  33610. */
  33611. getCachedEffect(): Nullable<Effect>;
  33612. /**
  33613. * Gets the cached visibility state (ie. the latest rendered one)
  33614. * @returns the cached visibility state
  33615. */
  33616. getCachedVisibility(): Nullable<number>;
  33617. /**
  33618. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33619. * @param material defines the current material
  33620. * @param effect defines the current effect
  33621. * @param visibility defines the current visibility state
  33622. * @returns true if one parameter is not cached
  33623. */
  33624. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33625. /**
  33626. * Gets the engine associated with the scene
  33627. * @returns an Engine
  33628. */
  33629. getEngine(): Engine;
  33630. /**
  33631. * Gets the total number of vertices rendered per frame
  33632. * @returns the total number of vertices rendered per frame
  33633. */
  33634. getTotalVertices(): number;
  33635. /**
  33636. * Gets the performance counter for total vertices
  33637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33638. */
  33639. readonly totalVerticesPerfCounter: PerfCounter;
  33640. /**
  33641. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33642. * @returns the total number of active indices rendered per frame
  33643. */
  33644. getActiveIndices(): number;
  33645. /**
  33646. * Gets the performance counter for active indices
  33647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33648. */
  33649. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33650. /**
  33651. * Gets the total number of active particles rendered per frame
  33652. * @returns the total number of active particles rendered per frame
  33653. */
  33654. getActiveParticles(): number;
  33655. /**
  33656. * Gets the performance counter for active particles
  33657. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33658. */
  33659. readonly activeParticlesPerfCounter: PerfCounter;
  33660. /**
  33661. * Gets the total number of active bones rendered per frame
  33662. * @returns the total number of active bones rendered per frame
  33663. */
  33664. getActiveBones(): number;
  33665. /**
  33666. * Gets the performance counter for active bones
  33667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33668. */
  33669. readonly activeBonesPerfCounter: PerfCounter;
  33670. /**
  33671. * Gets the array of active meshes
  33672. * @returns an array of AbstractMesh
  33673. */
  33674. getActiveMeshes(): SmartArray<AbstractMesh>;
  33675. /**
  33676. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33677. * @returns a number
  33678. */
  33679. getAnimationRatio(): number;
  33680. /**
  33681. * Gets an unique Id for the current render phase
  33682. * @returns a number
  33683. */
  33684. getRenderId(): number;
  33685. /**
  33686. * Gets an unique Id for the current frame
  33687. * @returns a number
  33688. */
  33689. getFrameId(): number;
  33690. /** Call this function if you want to manually increment the render Id*/
  33691. incrementRenderId(): void;
  33692. private _createUbo;
  33693. /**
  33694. * Use this method to simulate a pointer move on a mesh
  33695. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33696. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33697. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33698. * @returns the current scene
  33699. */
  33700. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33701. /**
  33702. * Use this method to simulate a pointer down on a mesh
  33703. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33704. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33705. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33706. * @returns the current scene
  33707. */
  33708. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33709. /**
  33710. * Use this method to simulate a pointer up on a mesh
  33711. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33712. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33713. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33714. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33715. * @returns the current scene
  33716. */
  33717. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33718. /**
  33719. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33720. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33721. * @returns true if the pointer was captured
  33722. */
  33723. isPointerCaptured(pointerId?: number): boolean;
  33724. /**
  33725. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33726. * @param attachUp defines if you want to attach events to pointerup
  33727. * @param attachDown defines if you want to attach events to pointerdown
  33728. * @param attachMove defines if you want to attach events to pointermove
  33729. */
  33730. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33731. /** Detaches all event handlers*/
  33732. detachControl(): void;
  33733. /**
  33734. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33735. * Delay loaded resources are not taking in account
  33736. * @return true if all required resources are ready
  33737. */
  33738. isReady(): boolean;
  33739. /** Resets all cached information relative to material (including effect and visibility) */
  33740. resetCachedMaterial(): void;
  33741. /**
  33742. * Registers a function to be called before every frame render
  33743. * @param func defines the function to register
  33744. */
  33745. registerBeforeRender(func: () => void): void;
  33746. /**
  33747. * Unregisters a function called before every frame render
  33748. * @param func defines the function to unregister
  33749. */
  33750. unregisterBeforeRender(func: () => void): void;
  33751. /**
  33752. * Registers a function to be called after every frame render
  33753. * @param func defines the function to register
  33754. */
  33755. registerAfterRender(func: () => void): void;
  33756. /**
  33757. * Unregisters a function called after every frame render
  33758. * @param func defines the function to unregister
  33759. */
  33760. unregisterAfterRender(func: () => void): void;
  33761. private _executeOnceBeforeRender;
  33762. /**
  33763. * The provided function will run before render once and will be disposed afterwards.
  33764. * A timeout delay can be provided so that the function will be executed in N ms.
  33765. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33766. * @param func The function to be executed.
  33767. * @param timeout optional delay in ms
  33768. */
  33769. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33770. /** @hidden */
  33771. _addPendingData(data: any): void;
  33772. /** @hidden */
  33773. _removePendingData(data: any): void;
  33774. /**
  33775. * Returns the number of items waiting to be loaded
  33776. * @returns the number of items waiting to be loaded
  33777. */
  33778. getWaitingItemsCount(): number;
  33779. /**
  33780. * Returns a boolean indicating if the scene is still loading data
  33781. */
  33782. readonly isLoading: boolean;
  33783. /**
  33784. * Registers a function to be executed when the scene is ready
  33785. * @param {Function} func - the function to be executed
  33786. */
  33787. executeWhenReady(func: () => void): void;
  33788. /**
  33789. * Returns a promise that resolves when the scene is ready
  33790. * @returns A promise that resolves when the scene is ready
  33791. */
  33792. whenReadyAsync(): Promise<void>;
  33793. /** @hidden */
  33794. _checkIsReady(): void;
  33795. /**
  33796. * Gets all animatable attached to the scene
  33797. */
  33798. readonly animatables: Animatable[];
  33799. /**
  33800. * Resets the last animation time frame.
  33801. * Useful to override when animations start running when loading a scene for the first time.
  33802. */
  33803. resetLastAnimationTimeFrame(): void;
  33804. /**
  33805. * Gets the current view matrix
  33806. * @returns a Matrix
  33807. */
  33808. getViewMatrix(): Matrix;
  33809. /**
  33810. * Gets the current projection matrix
  33811. * @returns a Matrix
  33812. */
  33813. getProjectionMatrix(): Matrix;
  33814. /**
  33815. * Gets the current transform matrix
  33816. * @returns a Matrix made of View * Projection
  33817. */
  33818. getTransformMatrix(): Matrix;
  33819. /**
  33820. * Sets the current transform matrix
  33821. * @param viewL defines the View matrix to use
  33822. * @param projectionL defines the Projection matrix to use
  33823. * @param viewR defines the right View matrix to use (if provided)
  33824. * @param projectionR defines the right Projection matrix to use (if provided)
  33825. */
  33826. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33827. /**
  33828. * Gets the uniform buffer used to store scene data
  33829. * @returns a UniformBuffer
  33830. */
  33831. getSceneUniformBuffer(): UniformBuffer;
  33832. /**
  33833. * Gets an unique (relatively to the current scene) Id
  33834. * @returns an unique number for the scene
  33835. */
  33836. getUniqueId(): number;
  33837. /**
  33838. * Add a mesh to the list of scene's meshes
  33839. * @param newMesh defines the mesh to add
  33840. * @param recursive if all child meshes should also be added to the scene
  33841. */
  33842. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33843. /**
  33844. * Remove a mesh for the list of scene's meshes
  33845. * @param toRemove defines the mesh to remove
  33846. * @param recursive if all child meshes should also be removed from the scene
  33847. * @returns the index where the mesh was in the mesh list
  33848. */
  33849. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33850. /**
  33851. * Add a transform node to the list of scene's transform nodes
  33852. * @param newTransformNode defines the transform node to add
  33853. */
  33854. addTransformNode(newTransformNode: TransformNode): void;
  33855. /**
  33856. * Remove a transform node for the list of scene's transform nodes
  33857. * @param toRemove defines the transform node to remove
  33858. * @returns the index where the transform node was in the transform node list
  33859. */
  33860. removeTransformNode(toRemove: TransformNode): number;
  33861. /**
  33862. * Remove a skeleton for the list of scene's skeletons
  33863. * @param toRemove defines the skeleton to remove
  33864. * @returns the index where the skeleton was in the skeleton list
  33865. */
  33866. removeSkeleton(toRemove: Skeleton): number;
  33867. /**
  33868. * Remove a morph target for the list of scene's morph targets
  33869. * @param toRemove defines the morph target to remove
  33870. * @returns the index where the morph target was in the morph target list
  33871. */
  33872. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33873. /**
  33874. * Remove a light for the list of scene's lights
  33875. * @param toRemove defines the light to remove
  33876. * @returns the index where the light was in the light list
  33877. */
  33878. removeLight(toRemove: Light): number;
  33879. /**
  33880. * Remove a camera for the list of scene's cameras
  33881. * @param toRemove defines the camera to remove
  33882. * @returns the index where the camera was in the camera list
  33883. */
  33884. removeCamera(toRemove: Camera): number;
  33885. /**
  33886. * Remove a particle system for the list of scene's particle systems
  33887. * @param toRemove defines the particle system to remove
  33888. * @returns the index where the particle system was in the particle system list
  33889. */
  33890. removeParticleSystem(toRemove: IParticleSystem): number;
  33891. /**
  33892. * Remove a animation for the list of scene's animations
  33893. * @param toRemove defines the animation to remove
  33894. * @returns the index where the animation was in the animation list
  33895. */
  33896. removeAnimation(toRemove: Animation): number;
  33897. /**
  33898. * Will stop the animation of the given target
  33899. * @param target - the target
  33900. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33901. * @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)
  33902. */
  33903. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33904. /**
  33905. * Removes the given animation group from this scene.
  33906. * @param toRemove The animation group to remove
  33907. * @returns The index of the removed animation group
  33908. */
  33909. removeAnimationGroup(toRemove: AnimationGroup): number;
  33910. /**
  33911. * Removes the given multi-material from this scene.
  33912. * @param toRemove The multi-material to remove
  33913. * @returns The index of the removed multi-material
  33914. */
  33915. removeMultiMaterial(toRemove: MultiMaterial): number;
  33916. /**
  33917. * Removes the given material from this scene.
  33918. * @param toRemove The material to remove
  33919. * @returns The index of the removed material
  33920. */
  33921. removeMaterial(toRemove: Material): number;
  33922. /**
  33923. * Removes the given action manager from this scene.
  33924. * @param toRemove The action manager to remove
  33925. * @returns The index of the removed action manager
  33926. */
  33927. removeActionManager(toRemove: AbstractActionManager): number;
  33928. /**
  33929. * Removes the given texture from this scene.
  33930. * @param toRemove The texture to remove
  33931. * @returns The index of the removed texture
  33932. */
  33933. removeTexture(toRemove: BaseTexture): number;
  33934. /**
  33935. * Adds the given light to this scene
  33936. * @param newLight The light to add
  33937. */
  33938. addLight(newLight: Light): void;
  33939. /**
  33940. * Sorts the list list based on light priorities
  33941. */
  33942. sortLightsByPriority(): void;
  33943. /**
  33944. * Adds the given camera to this scene
  33945. * @param newCamera The camera to add
  33946. */
  33947. addCamera(newCamera: Camera): void;
  33948. /**
  33949. * Adds the given skeleton to this scene
  33950. * @param newSkeleton The skeleton to add
  33951. */
  33952. addSkeleton(newSkeleton: Skeleton): void;
  33953. /**
  33954. * Adds the given particle system to this scene
  33955. * @param newParticleSystem The particle system to add
  33956. */
  33957. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33958. /**
  33959. * Adds the given animation to this scene
  33960. * @param newAnimation The animation to add
  33961. */
  33962. addAnimation(newAnimation: Animation): void;
  33963. /**
  33964. * Adds the given animation group to this scene.
  33965. * @param newAnimationGroup The animation group to add
  33966. */
  33967. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33968. /**
  33969. * Adds the given multi-material to this scene
  33970. * @param newMultiMaterial The multi-material to add
  33971. */
  33972. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33973. /**
  33974. * Adds the given material to this scene
  33975. * @param newMaterial The material to add
  33976. */
  33977. addMaterial(newMaterial: Material): void;
  33978. /**
  33979. * Adds the given morph target to this scene
  33980. * @param newMorphTargetManager The morph target to add
  33981. */
  33982. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33983. /**
  33984. * Adds the given geometry to this scene
  33985. * @param newGeometry The geometry to add
  33986. */
  33987. addGeometry(newGeometry: Geometry): void;
  33988. /**
  33989. * Adds the given action manager to this scene
  33990. * @param newActionManager The action manager to add
  33991. */
  33992. addActionManager(newActionManager: AbstractActionManager): void;
  33993. /**
  33994. * Adds the given texture to this scene.
  33995. * @param newTexture The texture to add
  33996. */
  33997. addTexture(newTexture: BaseTexture): void;
  33998. /**
  33999. * Switch active camera
  34000. * @param newCamera defines the new active camera
  34001. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34002. */
  34003. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34004. /**
  34005. * sets the active camera of the scene using its ID
  34006. * @param id defines the camera's ID
  34007. * @return the new active camera or null if none found.
  34008. */
  34009. setActiveCameraByID(id: string): Nullable<Camera>;
  34010. /**
  34011. * sets the active camera of the scene using its name
  34012. * @param name defines the camera's name
  34013. * @returns the new active camera or null if none found.
  34014. */
  34015. setActiveCameraByName(name: string): Nullable<Camera>;
  34016. /**
  34017. * get an animation group using its name
  34018. * @param name defines the material's name
  34019. * @return the animation group or null if none found.
  34020. */
  34021. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34022. /**
  34023. * Get a material using its unique id
  34024. * @param uniqueId defines the material's unique id
  34025. * @return the material or null if none found.
  34026. */
  34027. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34028. /**
  34029. * get a material using its id
  34030. * @param id defines the material's ID
  34031. * @return the material or null if none found.
  34032. */
  34033. getMaterialByID(id: string): Nullable<Material>;
  34034. /**
  34035. * Gets a material using its name
  34036. * @param name defines the material's name
  34037. * @return the material or null if none found.
  34038. */
  34039. getMaterialByName(name: string): Nullable<Material>;
  34040. /**
  34041. * Gets a camera using its id
  34042. * @param id defines the id to look for
  34043. * @returns the camera or null if not found
  34044. */
  34045. getCameraByID(id: string): Nullable<Camera>;
  34046. /**
  34047. * Gets a camera using its unique id
  34048. * @param uniqueId defines the unique id to look for
  34049. * @returns the camera or null if not found
  34050. */
  34051. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34052. /**
  34053. * Gets a camera using its name
  34054. * @param name defines the camera's name
  34055. * @return the camera or null if none found.
  34056. */
  34057. getCameraByName(name: string): Nullable<Camera>;
  34058. /**
  34059. * Gets a bone using its id
  34060. * @param id defines the bone's id
  34061. * @return the bone or null if not found
  34062. */
  34063. getBoneByID(id: string): Nullable<Bone>;
  34064. /**
  34065. * Gets a bone using its id
  34066. * @param name defines the bone's name
  34067. * @return the bone or null if not found
  34068. */
  34069. getBoneByName(name: string): Nullable<Bone>;
  34070. /**
  34071. * Gets a light node using its name
  34072. * @param name defines the the light's name
  34073. * @return the light or null if none found.
  34074. */
  34075. getLightByName(name: string): Nullable<Light>;
  34076. /**
  34077. * Gets a light node using its id
  34078. * @param id defines the light's id
  34079. * @return the light or null if none found.
  34080. */
  34081. getLightByID(id: string): Nullable<Light>;
  34082. /**
  34083. * Gets a light node using its scene-generated unique ID
  34084. * @param uniqueId defines the light's unique id
  34085. * @return the light or null if none found.
  34086. */
  34087. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34088. /**
  34089. * Gets a particle system by id
  34090. * @param id defines the particle system id
  34091. * @return the corresponding system or null if none found
  34092. */
  34093. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34094. /**
  34095. * Gets a geometry using its ID
  34096. * @param id defines the geometry's id
  34097. * @return the geometry or null if none found.
  34098. */
  34099. getGeometryByID(id: string): Nullable<Geometry>;
  34100. private _getGeometryByUniqueID;
  34101. /**
  34102. * Add a new geometry to this scene
  34103. * @param geometry defines the geometry to be added to the scene.
  34104. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34105. * @return a boolean defining if the geometry was added or not
  34106. */
  34107. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34108. /**
  34109. * Removes an existing geometry
  34110. * @param geometry defines the geometry to be removed from the scene
  34111. * @return a boolean defining if the geometry was removed or not
  34112. */
  34113. removeGeometry(geometry: Geometry): boolean;
  34114. /**
  34115. * Gets the list of geometries attached to the scene
  34116. * @returns an array of Geometry
  34117. */
  34118. getGeometries(): Geometry[];
  34119. /**
  34120. * Gets the first added mesh found of a given ID
  34121. * @param id defines the id to search for
  34122. * @return the mesh found or null if not found at all
  34123. */
  34124. getMeshByID(id: string): Nullable<AbstractMesh>;
  34125. /**
  34126. * Gets a list of meshes using their id
  34127. * @param id defines the id to search for
  34128. * @returns a list of meshes
  34129. */
  34130. getMeshesByID(id: string): Array<AbstractMesh>;
  34131. /**
  34132. * Gets the first added transform node found of a given ID
  34133. * @param id defines the id to search for
  34134. * @return the found transform node or null if not found at all.
  34135. */
  34136. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34137. /**
  34138. * Gets a transform node with its auto-generated unique id
  34139. * @param uniqueId efines the unique id to search for
  34140. * @return the found transform node or null if not found at all.
  34141. */
  34142. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34143. /**
  34144. * Gets a list of transform nodes using their id
  34145. * @param id defines the id to search for
  34146. * @returns a list of transform nodes
  34147. */
  34148. getTransformNodesByID(id: string): Array<TransformNode>;
  34149. /**
  34150. * Gets a mesh with its auto-generated unique id
  34151. * @param uniqueId defines the unique id to search for
  34152. * @return the found mesh or null if not found at all.
  34153. */
  34154. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34155. /**
  34156. * Gets a the last added mesh using a given id
  34157. * @param id defines the id to search for
  34158. * @return the found mesh or null if not found at all.
  34159. */
  34160. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34161. /**
  34162. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34163. * @param id defines the id to search for
  34164. * @return the found node or null if not found at all
  34165. */
  34166. getLastEntryByID(id: string): Nullable<Node>;
  34167. /**
  34168. * Gets a node (Mesh, Camera, Light) using a given id
  34169. * @param id defines the id to search for
  34170. * @return the found node or null if not found at all
  34171. */
  34172. getNodeByID(id: string): Nullable<Node>;
  34173. /**
  34174. * Gets a node (Mesh, Camera, Light) using a given name
  34175. * @param name defines the name to search for
  34176. * @return the found node or null if not found at all.
  34177. */
  34178. getNodeByName(name: string): Nullable<Node>;
  34179. /**
  34180. * Gets a mesh using a given name
  34181. * @param name defines the name to search for
  34182. * @return the found mesh or null if not found at all.
  34183. */
  34184. getMeshByName(name: string): Nullable<AbstractMesh>;
  34185. /**
  34186. * Gets a transform node using a given name
  34187. * @param name defines the name to search for
  34188. * @return the found transform node or null if not found at all.
  34189. */
  34190. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34191. /**
  34192. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34193. * @param id defines the id to search for
  34194. * @return the found skeleton or null if not found at all.
  34195. */
  34196. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34197. /**
  34198. * Gets a skeleton using a given auto generated unique id
  34199. * @param uniqueId defines the unique id to search for
  34200. * @return the found skeleton or null if not found at all.
  34201. */
  34202. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34203. /**
  34204. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34205. * @param id defines the id to search for
  34206. * @return the found skeleton or null if not found at all.
  34207. */
  34208. getSkeletonById(id: string): Nullable<Skeleton>;
  34209. /**
  34210. * Gets a skeleton using a given name
  34211. * @param name defines the name to search for
  34212. * @return the found skeleton or null if not found at all.
  34213. */
  34214. getSkeletonByName(name: string): Nullable<Skeleton>;
  34215. /**
  34216. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34217. * @param id defines the id to search for
  34218. * @return the found morph target manager or null if not found at all.
  34219. */
  34220. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34221. /**
  34222. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34223. * @param id defines the id to search for
  34224. * @return the found morph target or null if not found at all.
  34225. */
  34226. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34227. /**
  34228. * Gets a boolean indicating if the given mesh is active
  34229. * @param mesh defines the mesh to look for
  34230. * @returns true if the mesh is in the active list
  34231. */
  34232. isActiveMesh(mesh: AbstractMesh): boolean;
  34233. /**
  34234. * Return a unique id as a string which can serve as an identifier for the scene
  34235. */
  34236. readonly uid: string;
  34237. /**
  34238. * Add an externaly attached data from its key.
  34239. * This method call will fail and return false, if such key already exists.
  34240. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34241. * @param key the unique key that identifies the data
  34242. * @param data the data object to associate to the key for this Engine instance
  34243. * @return true if no such key were already present and the data was added successfully, false otherwise
  34244. */
  34245. addExternalData<T>(key: string, data: T): boolean;
  34246. /**
  34247. * Get an externaly attached data from its key
  34248. * @param key the unique key that identifies the data
  34249. * @return the associated data, if present (can be null), or undefined if not present
  34250. */
  34251. getExternalData<T>(key: string): Nullable<T>;
  34252. /**
  34253. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34254. * @param key the unique key that identifies the data
  34255. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34256. * @return the associated data, can be null if the factory returned null.
  34257. */
  34258. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34259. /**
  34260. * Remove an externaly attached data from the Engine instance
  34261. * @param key the unique key that identifies the data
  34262. * @return true if the data was successfully removed, false if it doesn't exist
  34263. */
  34264. removeExternalData(key: string): boolean;
  34265. private _evaluateSubMesh;
  34266. /**
  34267. * Clear the processed materials smart array preventing retention point in material dispose.
  34268. */
  34269. freeProcessedMaterials(): void;
  34270. private _preventFreeActiveMeshesAndRenderingGroups;
  34271. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34272. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34273. * when disposing several meshes in a row or a hierarchy of meshes.
  34274. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34275. */
  34276. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34277. /**
  34278. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34279. */
  34280. freeActiveMeshes(): void;
  34281. /**
  34282. * Clear the info related to rendering groups preventing retention points during dispose.
  34283. */
  34284. freeRenderingGroups(): void;
  34285. /** @hidden */
  34286. _isInIntermediateRendering(): boolean;
  34287. /**
  34288. * Lambda returning the list of potentially active meshes.
  34289. */
  34290. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34291. /**
  34292. * Lambda returning the list of potentially active sub meshes.
  34293. */
  34294. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34295. /**
  34296. * Lambda returning the list of potentially intersecting sub meshes.
  34297. */
  34298. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34299. /**
  34300. * Lambda returning the list of potentially colliding sub meshes.
  34301. */
  34302. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34303. private _activeMeshesFrozen;
  34304. /**
  34305. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34306. * @returns the current scene
  34307. */
  34308. freezeActiveMeshes(): Scene;
  34309. /**
  34310. * Use this function to restart evaluating active meshes on every frame
  34311. * @returns the current scene
  34312. */
  34313. unfreezeActiveMeshes(): Scene;
  34314. private _evaluateActiveMeshes;
  34315. private _activeMesh;
  34316. /**
  34317. * Update the transform matrix to update from the current active camera
  34318. * @param force defines a boolean used to force the update even if cache is up to date
  34319. */
  34320. updateTransformMatrix(force?: boolean): void;
  34321. private _bindFrameBuffer;
  34322. /** @hidden */
  34323. _allowPostProcessClearColor: boolean;
  34324. /** @hidden */
  34325. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34326. private _processSubCameras;
  34327. private _checkIntersections;
  34328. /** @hidden */
  34329. _advancePhysicsEngineStep(step: number): void;
  34330. /**
  34331. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34332. */
  34333. getDeterministicFrameTime: () => number;
  34334. /** @hidden */
  34335. _animate(): void;
  34336. /** Execute all animations (for a frame) */
  34337. animate(): void;
  34338. /**
  34339. * Render the scene
  34340. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34341. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34342. */
  34343. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34344. /**
  34345. * Freeze all materials
  34346. * A frozen material will not be updatable but should be faster to render
  34347. */
  34348. freezeMaterials(): void;
  34349. /**
  34350. * Unfreeze all materials
  34351. * A frozen material will not be updatable but should be faster to render
  34352. */
  34353. unfreezeMaterials(): void;
  34354. /**
  34355. * Releases all held ressources
  34356. */
  34357. dispose(): void;
  34358. /**
  34359. * Gets if the scene is already disposed
  34360. */
  34361. readonly isDisposed: boolean;
  34362. /**
  34363. * Call this function to reduce memory footprint of the scene.
  34364. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34365. */
  34366. clearCachedVertexData(): void;
  34367. /**
  34368. * This function will remove the local cached buffer data from texture.
  34369. * It will save memory but will prevent the texture from being rebuilt
  34370. */
  34371. cleanCachedTextureBuffer(): void;
  34372. /**
  34373. * Get the world extend vectors with an optional filter
  34374. *
  34375. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34376. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34377. */
  34378. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34379. min: Vector3;
  34380. max: Vector3;
  34381. };
  34382. /**
  34383. * Creates a ray that can be used to pick in the scene
  34384. * @param x defines the x coordinate of the origin (on-screen)
  34385. * @param y defines the y coordinate of the origin (on-screen)
  34386. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34387. * @param camera defines the camera to use for the picking
  34388. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34389. * @returns a Ray
  34390. */
  34391. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34392. /**
  34393. * Creates a ray that can be used to pick in the scene
  34394. * @param x defines the x coordinate of the origin (on-screen)
  34395. * @param y defines the y coordinate of the origin (on-screen)
  34396. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34397. * @param result defines the ray where to store the picking ray
  34398. * @param camera defines the camera to use for the picking
  34399. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34400. * @returns the current scene
  34401. */
  34402. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34403. /**
  34404. * Creates a ray that can be used to pick in the scene
  34405. * @param x defines the x coordinate of the origin (on-screen)
  34406. * @param y defines the y coordinate of the origin (on-screen)
  34407. * @param camera defines the camera to use for the picking
  34408. * @returns a Ray
  34409. */
  34410. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34411. /**
  34412. * Creates a ray that can be used to pick in the scene
  34413. * @param x defines the x coordinate of the origin (on-screen)
  34414. * @param y defines the y coordinate of the origin (on-screen)
  34415. * @param result defines the ray where to store the picking ray
  34416. * @param camera defines the camera to use for the picking
  34417. * @returns the current scene
  34418. */
  34419. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34420. /** Launch a ray to try to pick a mesh in the scene
  34421. * @param x position on screen
  34422. * @param y position on screen
  34423. * @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
  34424. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34425. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34426. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34427. * @returns a PickingInfo
  34428. */
  34429. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34430. /** Use the given ray to pick a mesh in the scene
  34431. * @param ray The ray to use to pick meshes
  34432. * @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
  34433. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34434. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34435. * @returns a PickingInfo
  34436. */
  34437. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34438. /**
  34439. * Launch a ray to try to pick a mesh in the scene
  34440. * @param x X position on screen
  34441. * @param y Y position on screen
  34442. * @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
  34443. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34444. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34445. * @returns an array of PickingInfo
  34446. */
  34447. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34448. /**
  34449. * Launch a ray to try to pick a mesh in the scene
  34450. * @param ray Ray to use
  34451. * @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
  34452. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34453. * @returns an array of PickingInfo
  34454. */
  34455. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34456. /**
  34457. * Force the value of meshUnderPointer
  34458. * @param mesh defines the mesh to use
  34459. */
  34460. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34461. /**
  34462. * Gets the mesh under the pointer
  34463. * @returns a Mesh or null if no mesh is under the pointer
  34464. */
  34465. getPointerOverMesh(): Nullable<AbstractMesh>;
  34466. /** @hidden */
  34467. _rebuildGeometries(): void;
  34468. /** @hidden */
  34469. _rebuildTextures(): void;
  34470. private _getByTags;
  34471. /**
  34472. * Get a list of meshes by tags
  34473. * @param tagsQuery defines the tags query to use
  34474. * @param forEach defines a predicate used to filter results
  34475. * @returns an array of Mesh
  34476. */
  34477. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34478. /**
  34479. * Get a list of cameras by tags
  34480. * @param tagsQuery defines the tags query to use
  34481. * @param forEach defines a predicate used to filter results
  34482. * @returns an array of Camera
  34483. */
  34484. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34485. /**
  34486. * Get a list of lights by tags
  34487. * @param tagsQuery defines the tags query to use
  34488. * @param forEach defines a predicate used to filter results
  34489. * @returns an array of Light
  34490. */
  34491. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34492. /**
  34493. * Get a list of materials by tags
  34494. * @param tagsQuery defines the tags query to use
  34495. * @param forEach defines a predicate used to filter results
  34496. * @returns an array of Material
  34497. */
  34498. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34499. /**
  34500. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34501. * This allowed control for front to back rendering or reversly depending of the special needs.
  34502. *
  34503. * @param renderingGroupId The rendering group id corresponding to its index
  34504. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34505. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34506. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34507. */
  34508. 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;
  34509. /**
  34510. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34511. *
  34512. * @param renderingGroupId The rendering group id corresponding to its index
  34513. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34514. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34515. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34516. */
  34517. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34518. /**
  34519. * Gets the current auto clear configuration for one rendering group of the rendering
  34520. * manager.
  34521. * @param index the rendering group index to get the information for
  34522. * @returns The auto clear setup for the requested rendering group
  34523. */
  34524. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34525. private _blockMaterialDirtyMechanism;
  34526. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34527. blockMaterialDirtyMechanism: boolean;
  34528. /**
  34529. * Will flag all materials as dirty to trigger new shader compilation
  34530. * @param flag defines the flag used to specify which material part must be marked as dirty
  34531. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34532. */
  34533. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34534. /** @hidden */
  34535. _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;
  34536. /** @hidden */
  34537. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34538. }
  34539. }
  34540. declare module "babylonjs/assetContainer" {
  34541. import { AbstractScene } from "babylonjs/abstractScene";
  34542. import { Scene } from "babylonjs/scene";
  34543. import { Mesh } from "babylonjs/Meshes/mesh";
  34544. /**
  34545. * Set of assets to keep when moving a scene into an asset container.
  34546. */
  34547. export class KeepAssets extends AbstractScene {
  34548. }
  34549. /**
  34550. * Container with a set of assets that can be added or removed from a scene.
  34551. */
  34552. export class AssetContainer extends AbstractScene {
  34553. /**
  34554. * The scene the AssetContainer belongs to.
  34555. */
  34556. scene: Scene;
  34557. /**
  34558. * Instantiates an AssetContainer.
  34559. * @param scene The scene the AssetContainer belongs to.
  34560. */
  34561. constructor(scene: Scene);
  34562. /**
  34563. * Adds all the assets from the container to the scene.
  34564. */
  34565. addAllToScene(): void;
  34566. /**
  34567. * Removes all the assets in the container from the scene
  34568. */
  34569. removeAllFromScene(): void;
  34570. /**
  34571. * Disposes all the assets in the container
  34572. */
  34573. dispose(): void;
  34574. private _moveAssets;
  34575. /**
  34576. * Removes all the assets contained in the scene and adds them to the container.
  34577. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34578. */
  34579. moveAllFromScene(keepAssets?: KeepAssets): void;
  34580. /**
  34581. * 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.
  34582. * @returns the root mesh
  34583. */
  34584. createRootMesh(): Mesh;
  34585. }
  34586. }
  34587. declare module "babylonjs/abstractScene" {
  34588. import { Scene } from "babylonjs/scene";
  34589. import { Nullable } from "babylonjs/types";
  34590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34591. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34592. import { Geometry } from "babylonjs/Meshes/geometry";
  34593. import { Skeleton } from "babylonjs/Bones/skeleton";
  34594. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34595. import { AssetContainer } from "babylonjs/assetContainer";
  34596. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34597. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34598. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34599. import { Material } from "babylonjs/Materials/material";
  34600. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34601. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34602. import { Camera } from "babylonjs/Cameras/camera";
  34603. import { Light } from "babylonjs/Lights/light";
  34604. import { Node } from "babylonjs/node";
  34605. import { Animation } from "babylonjs/Animations/animation";
  34606. /**
  34607. * Defines how the parser contract is defined.
  34608. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34609. */
  34610. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34611. /**
  34612. * Defines how the individual parser contract is defined.
  34613. * These parser can parse an individual asset
  34614. */
  34615. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34616. /**
  34617. * Base class of the scene acting as a container for the different elements composing a scene.
  34618. * This class is dynamically extended by the different components of the scene increasing
  34619. * flexibility and reducing coupling
  34620. */
  34621. export abstract class AbstractScene {
  34622. /**
  34623. * Stores the list of available parsers in the application.
  34624. */
  34625. private static _BabylonFileParsers;
  34626. /**
  34627. * Stores the list of available individual parsers in the application.
  34628. */
  34629. private static _IndividualBabylonFileParsers;
  34630. /**
  34631. * Adds a parser in the list of available ones
  34632. * @param name Defines the name of the parser
  34633. * @param parser Defines the parser to add
  34634. */
  34635. static AddParser(name: string, parser: BabylonFileParser): void;
  34636. /**
  34637. * Gets a general parser from the list of avaialble ones
  34638. * @param name Defines the name of the parser
  34639. * @returns the requested parser or null
  34640. */
  34641. static GetParser(name: string): Nullable<BabylonFileParser>;
  34642. /**
  34643. * Adds n individual parser in the list of available ones
  34644. * @param name Defines the name of the parser
  34645. * @param parser Defines the parser to add
  34646. */
  34647. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34648. /**
  34649. * Gets an individual parser from the list of avaialble ones
  34650. * @param name Defines the name of the parser
  34651. * @returns the requested parser or null
  34652. */
  34653. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34654. /**
  34655. * Parser json data and populate both a scene and its associated container object
  34656. * @param jsonData Defines the data to parse
  34657. * @param scene Defines the scene to parse the data for
  34658. * @param container Defines the container attached to the parsing sequence
  34659. * @param rootUrl Defines the root url of the data
  34660. */
  34661. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34662. /**
  34663. * Gets the list of root nodes (ie. nodes with no parent)
  34664. */
  34665. rootNodes: Node[];
  34666. /** All of the cameras added to this scene
  34667. * @see http://doc.babylonjs.com/babylon101/cameras
  34668. */
  34669. cameras: Camera[];
  34670. /**
  34671. * All of the lights added to this scene
  34672. * @see http://doc.babylonjs.com/babylon101/lights
  34673. */
  34674. lights: Light[];
  34675. /**
  34676. * All of the (abstract) meshes added to this scene
  34677. */
  34678. meshes: AbstractMesh[];
  34679. /**
  34680. * The list of skeletons added to the scene
  34681. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34682. */
  34683. skeletons: Skeleton[];
  34684. /**
  34685. * All of the particle systems added to this scene
  34686. * @see http://doc.babylonjs.com/babylon101/particles
  34687. */
  34688. particleSystems: IParticleSystem[];
  34689. /**
  34690. * Gets a list of Animations associated with the scene
  34691. */
  34692. animations: Animation[];
  34693. /**
  34694. * All of the animation groups added to this scene
  34695. * @see http://doc.babylonjs.com/how_to/group
  34696. */
  34697. animationGroups: AnimationGroup[];
  34698. /**
  34699. * All of the multi-materials added to this scene
  34700. * @see http://doc.babylonjs.com/how_to/multi_materials
  34701. */
  34702. multiMaterials: MultiMaterial[];
  34703. /**
  34704. * All of the materials added to this scene
  34705. * In the context of a Scene, it is not supposed to be modified manually.
  34706. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34707. * Note also that the order of the Material wihin the array is not significant and might change.
  34708. * @see http://doc.babylonjs.com/babylon101/materials
  34709. */
  34710. materials: Material[];
  34711. /**
  34712. * The list of morph target managers added to the scene
  34713. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34714. */
  34715. morphTargetManagers: MorphTargetManager[];
  34716. /**
  34717. * The list of geometries used in the scene.
  34718. */
  34719. geometries: Geometry[];
  34720. /**
  34721. * All of the tranform nodes added to this scene
  34722. * In the context of a Scene, it is not supposed to be modified manually.
  34723. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34724. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34725. * @see http://doc.babylonjs.com/how_to/transformnode
  34726. */
  34727. transformNodes: TransformNode[];
  34728. /**
  34729. * ActionManagers available on the scene.
  34730. */
  34731. actionManagers: AbstractActionManager[];
  34732. /**
  34733. * Textures to keep.
  34734. */
  34735. textures: BaseTexture[];
  34736. /**
  34737. * Environment texture for the scene
  34738. */
  34739. environmentTexture: Nullable<BaseTexture>;
  34740. }
  34741. }
  34742. declare module "babylonjs/Audio/sound" {
  34743. import { Observable } from "babylonjs/Misc/observable";
  34744. import { Vector3 } from "babylonjs/Maths/math";
  34745. import { Nullable } from "babylonjs/types";
  34746. import { Scene } from "babylonjs/scene";
  34747. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34748. /**
  34749. * Defines a sound that can be played in the application.
  34750. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34752. */
  34753. export class Sound {
  34754. /**
  34755. * The name of the sound in the scene.
  34756. */
  34757. name: string;
  34758. /**
  34759. * Does the sound autoplay once loaded.
  34760. */
  34761. autoplay: boolean;
  34762. /**
  34763. * Does the sound loop after it finishes playing once.
  34764. */
  34765. loop: boolean;
  34766. /**
  34767. * Does the sound use a custom attenuation curve to simulate the falloff
  34768. * happening when the source gets further away from the camera.
  34769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34770. */
  34771. useCustomAttenuation: boolean;
  34772. /**
  34773. * The sound track id this sound belongs to.
  34774. */
  34775. soundTrackId: number;
  34776. /**
  34777. * Is this sound currently played.
  34778. */
  34779. isPlaying: boolean;
  34780. /**
  34781. * Is this sound currently paused.
  34782. */
  34783. isPaused: boolean;
  34784. /**
  34785. * Does this sound enables spatial sound.
  34786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34787. */
  34788. spatialSound: boolean;
  34789. /**
  34790. * Define the reference distance the sound should be heard perfectly.
  34791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34792. */
  34793. refDistance: number;
  34794. /**
  34795. * Define the roll off factor of spatial sounds.
  34796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34797. */
  34798. rolloffFactor: number;
  34799. /**
  34800. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34802. */
  34803. maxDistance: number;
  34804. /**
  34805. * Define the distance attenuation model the sound will follow.
  34806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34807. */
  34808. distanceModel: string;
  34809. /**
  34810. * @hidden
  34811. * Back Compat
  34812. **/
  34813. onended: () => any;
  34814. /**
  34815. * Observable event when the current playing sound finishes.
  34816. */
  34817. onEndedObservable: Observable<Sound>;
  34818. private _panningModel;
  34819. private _playbackRate;
  34820. private _streaming;
  34821. private _startTime;
  34822. private _startOffset;
  34823. private _position;
  34824. /** @hidden */
  34825. _positionInEmitterSpace: boolean;
  34826. private _localDirection;
  34827. private _volume;
  34828. private _isReadyToPlay;
  34829. private _isDirectional;
  34830. private _readyToPlayCallback;
  34831. private _audioBuffer;
  34832. private _soundSource;
  34833. private _streamingSource;
  34834. private _soundPanner;
  34835. private _soundGain;
  34836. private _inputAudioNode;
  34837. private _outputAudioNode;
  34838. private _coneInnerAngle;
  34839. private _coneOuterAngle;
  34840. private _coneOuterGain;
  34841. private _scene;
  34842. private _connectedTransformNode;
  34843. private _customAttenuationFunction;
  34844. private _registerFunc;
  34845. private _isOutputConnected;
  34846. private _htmlAudioElement;
  34847. private _urlType;
  34848. /** @hidden */
  34849. static _SceneComponentInitialization: (scene: Scene) => void;
  34850. /**
  34851. * Create a sound and attach it to a scene
  34852. * @param name Name of your sound
  34853. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34854. * @param scene defines the scene the sound belongs to
  34855. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34856. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34857. */
  34858. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34859. /**
  34860. * Release the sound and its associated resources
  34861. */
  34862. dispose(): void;
  34863. /**
  34864. * Gets if the sounds is ready to be played or not.
  34865. * @returns true if ready, otherwise false
  34866. */
  34867. isReady(): boolean;
  34868. private _soundLoaded;
  34869. /**
  34870. * Sets the data of the sound from an audiobuffer
  34871. * @param audioBuffer The audioBuffer containing the data
  34872. */
  34873. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34874. /**
  34875. * Updates the current sounds options such as maxdistance, loop...
  34876. * @param options A JSON object containing values named as the object properties
  34877. */
  34878. updateOptions(options: any): void;
  34879. private _createSpatialParameters;
  34880. private _updateSpatialParameters;
  34881. /**
  34882. * Switch the panning model to HRTF:
  34883. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34885. */
  34886. switchPanningModelToHRTF(): void;
  34887. /**
  34888. * Switch the panning model to Equal Power:
  34889. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34891. */
  34892. switchPanningModelToEqualPower(): void;
  34893. private _switchPanningModel;
  34894. /**
  34895. * Connect this sound to a sound track audio node like gain...
  34896. * @param soundTrackAudioNode the sound track audio node to connect to
  34897. */
  34898. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34899. /**
  34900. * Transform this sound into a directional source
  34901. * @param coneInnerAngle Size of the inner cone in degree
  34902. * @param coneOuterAngle Size of the outer cone in degree
  34903. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34904. */
  34905. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34906. /**
  34907. * Gets or sets the inner angle for the directional cone.
  34908. */
  34909. /**
  34910. * Gets or sets the inner angle for the directional cone.
  34911. */
  34912. directionalConeInnerAngle: number;
  34913. /**
  34914. * Gets or sets the outer angle for the directional cone.
  34915. */
  34916. /**
  34917. * Gets or sets the outer angle for the directional cone.
  34918. */
  34919. directionalConeOuterAngle: number;
  34920. /**
  34921. * Sets the position of the emitter if spatial sound is enabled
  34922. * @param newPosition Defines the new posisiton
  34923. */
  34924. setPosition(newPosition: Vector3): void;
  34925. /**
  34926. * Sets the local direction of the emitter if spatial sound is enabled
  34927. * @param newLocalDirection Defines the new local direction
  34928. */
  34929. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34930. private _updateDirection;
  34931. /** @hidden */
  34932. updateDistanceFromListener(): void;
  34933. /**
  34934. * Sets a new custom attenuation function for the sound.
  34935. * @param callback Defines the function used for the attenuation
  34936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34937. */
  34938. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34939. /**
  34940. * Play the sound
  34941. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34942. * @param offset (optional) Start the sound setting it at a specific time
  34943. */
  34944. play(time?: number, offset?: number): void;
  34945. private _onended;
  34946. /**
  34947. * Stop the sound
  34948. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34949. */
  34950. stop(time?: number): void;
  34951. /**
  34952. * Put the sound in pause
  34953. */
  34954. pause(): void;
  34955. /**
  34956. * Sets a dedicated volume for this sounds
  34957. * @param newVolume Define the new volume of the sound
  34958. * @param time Define in how long the sound should be at this value
  34959. */
  34960. setVolume(newVolume: number, time?: number): void;
  34961. /**
  34962. * Set the sound play back rate
  34963. * @param newPlaybackRate Define the playback rate the sound should be played at
  34964. */
  34965. setPlaybackRate(newPlaybackRate: number): void;
  34966. /**
  34967. * Gets the volume of the sound.
  34968. * @returns the volume of the sound
  34969. */
  34970. getVolume(): number;
  34971. /**
  34972. * Attach the sound to a dedicated mesh
  34973. * @param transformNode The transform node to connect the sound with
  34974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34975. */
  34976. attachToMesh(transformNode: TransformNode): void;
  34977. /**
  34978. * Detach the sound from the previously attached mesh
  34979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34980. */
  34981. detachFromMesh(): void;
  34982. private _onRegisterAfterWorldMatrixUpdate;
  34983. /**
  34984. * Clone the current sound in the scene.
  34985. * @returns the new sound clone
  34986. */
  34987. clone(): Nullable<Sound>;
  34988. /**
  34989. * Gets the current underlying audio buffer containing the data
  34990. * @returns the audio buffer
  34991. */
  34992. getAudioBuffer(): Nullable<AudioBuffer>;
  34993. /**
  34994. * Serializes the Sound in a JSON representation
  34995. * @returns the JSON representation of the sound
  34996. */
  34997. serialize(): any;
  34998. /**
  34999. * Parse a JSON representation of a sound to innstantiate in a given scene
  35000. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35001. * @param scene Define the scene the new parsed sound should be created in
  35002. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35003. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35004. * @returns the newly parsed sound
  35005. */
  35006. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35007. }
  35008. }
  35009. declare module "babylonjs/Actions/directAudioActions" {
  35010. import { Action } from "babylonjs/Actions/action";
  35011. import { Condition } from "babylonjs/Actions/condition";
  35012. import { Sound } from "babylonjs/Audio/sound";
  35013. /**
  35014. * This defines an action helpful to play a defined sound on a triggered action.
  35015. */
  35016. export class PlaySoundAction extends Action {
  35017. private _sound;
  35018. /**
  35019. * Instantiate the action
  35020. * @param triggerOptions defines the trigger options
  35021. * @param sound defines the sound to play
  35022. * @param condition defines the trigger related conditions
  35023. */
  35024. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35025. /** @hidden */
  35026. _prepare(): void;
  35027. /**
  35028. * Execute the action and play the sound.
  35029. */
  35030. execute(): void;
  35031. /**
  35032. * Serializes the actions and its related information.
  35033. * @param parent defines the object to serialize in
  35034. * @returns the serialized object
  35035. */
  35036. serialize(parent: any): any;
  35037. }
  35038. /**
  35039. * This defines an action helpful to stop a defined sound on a triggered action.
  35040. */
  35041. export class StopSoundAction extends Action {
  35042. private _sound;
  35043. /**
  35044. * Instantiate the action
  35045. * @param triggerOptions defines the trigger options
  35046. * @param sound defines the sound to stop
  35047. * @param condition defines the trigger related conditions
  35048. */
  35049. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35050. /** @hidden */
  35051. _prepare(): void;
  35052. /**
  35053. * Execute the action and stop the sound.
  35054. */
  35055. execute(): void;
  35056. /**
  35057. * Serializes the actions and its related information.
  35058. * @param parent defines the object to serialize in
  35059. * @returns the serialized object
  35060. */
  35061. serialize(parent: any): any;
  35062. }
  35063. }
  35064. declare module "babylonjs/Actions/interpolateValueAction" {
  35065. import { Action } from "babylonjs/Actions/action";
  35066. import { Condition } from "babylonjs/Actions/condition";
  35067. import { Observable } from "babylonjs/Misc/observable";
  35068. /**
  35069. * This defines an action responsible to change the value of a property
  35070. * by interpolating between its current value and the newly set one once triggered.
  35071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35072. */
  35073. export class InterpolateValueAction extends Action {
  35074. /**
  35075. * Defines the path of the property where the value should be interpolated
  35076. */
  35077. propertyPath: string;
  35078. /**
  35079. * Defines the target value at the end of the interpolation.
  35080. */
  35081. value: any;
  35082. /**
  35083. * Defines the time it will take for the property to interpolate to the value.
  35084. */
  35085. duration: number;
  35086. /**
  35087. * Defines if the other scene animations should be stopped when the action has been triggered
  35088. */
  35089. stopOtherAnimations?: boolean;
  35090. /**
  35091. * Defines a callback raised once the interpolation animation has been done.
  35092. */
  35093. onInterpolationDone?: () => void;
  35094. /**
  35095. * Observable triggered once the interpolation animation has been done.
  35096. */
  35097. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35098. private _target;
  35099. private _effectiveTarget;
  35100. private _property;
  35101. /**
  35102. * Instantiate the action
  35103. * @param triggerOptions defines the trigger options
  35104. * @param target defines the object containing the value to interpolate
  35105. * @param propertyPath defines the path to the property in the target object
  35106. * @param value defines the target value at the end of the interpolation
  35107. * @param duration deines the time it will take for the property to interpolate to the value.
  35108. * @param condition defines the trigger related conditions
  35109. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35110. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35111. */
  35112. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35113. /** @hidden */
  35114. _prepare(): void;
  35115. /**
  35116. * Execute the action starts the value interpolation.
  35117. */
  35118. execute(): void;
  35119. /**
  35120. * Serializes the actions and its related information.
  35121. * @param parent defines the object to serialize in
  35122. * @returns the serialized object
  35123. */
  35124. serialize(parent: any): any;
  35125. }
  35126. }
  35127. declare module "babylonjs/Actions/index" {
  35128. export * from "babylonjs/Actions/action";
  35129. export * from "babylonjs/Actions/actionEvent";
  35130. export * from "babylonjs/Actions/actionManager";
  35131. export * from "babylonjs/Actions/condition";
  35132. export * from "babylonjs/Actions/directActions";
  35133. export * from "babylonjs/Actions/directAudioActions";
  35134. export * from "babylonjs/Actions/interpolateValueAction";
  35135. }
  35136. declare module "babylonjs/Animations/index" {
  35137. export * from "babylonjs/Animations/animatable";
  35138. export * from "babylonjs/Animations/animation";
  35139. export * from "babylonjs/Animations/animationGroup";
  35140. export * from "babylonjs/Animations/animationPropertiesOverride";
  35141. export * from "babylonjs/Animations/easing";
  35142. export * from "babylonjs/Animations/runtimeAnimation";
  35143. export * from "babylonjs/Animations/animationEvent";
  35144. export * from "babylonjs/Animations/animationGroup";
  35145. export * from "babylonjs/Animations/animationKey";
  35146. export * from "babylonjs/Animations/animationRange";
  35147. }
  35148. declare module "babylonjs/Audio/soundTrack" {
  35149. import { Sound } from "babylonjs/Audio/sound";
  35150. import { Analyser } from "babylonjs/Audio/analyser";
  35151. import { Scene } from "babylonjs/scene";
  35152. /**
  35153. * Options allowed during the creation of a sound track.
  35154. */
  35155. export interface ISoundTrackOptions {
  35156. /**
  35157. * The volume the sound track should take during creation
  35158. */
  35159. volume?: number;
  35160. /**
  35161. * Define if the sound track is the main sound track of the scene
  35162. */
  35163. mainTrack?: boolean;
  35164. }
  35165. /**
  35166. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35167. * It will be also used in a future release to apply effects on a specific track.
  35168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35169. */
  35170. export class SoundTrack {
  35171. /**
  35172. * The unique identifier of the sound track in the scene.
  35173. */
  35174. id: number;
  35175. /**
  35176. * The list of sounds included in the sound track.
  35177. */
  35178. soundCollection: Array<Sound>;
  35179. private _outputAudioNode;
  35180. private _scene;
  35181. private _isMainTrack;
  35182. private _connectedAnalyser;
  35183. private _options;
  35184. private _isInitialized;
  35185. /**
  35186. * Creates a new sound track.
  35187. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35188. * @param scene Define the scene the sound track belongs to
  35189. * @param options
  35190. */
  35191. constructor(scene: Scene, options?: ISoundTrackOptions);
  35192. private _initializeSoundTrackAudioGraph;
  35193. /**
  35194. * Release the sound track and its associated resources
  35195. */
  35196. dispose(): void;
  35197. /**
  35198. * Adds a sound to this sound track
  35199. * @param sound define the cound to add
  35200. * @ignoreNaming
  35201. */
  35202. AddSound(sound: Sound): void;
  35203. /**
  35204. * Removes a sound to this sound track
  35205. * @param sound define the cound to remove
  35206. * @ignoreNaming
  35207. */
  35208. RemoveSound(sound: Sound): void;
  35209. /**
  35210. * Set a global volume for the full sound track.
  35211. * @param newVolume Define the new volume of the sound track
  35212. */
  35213. setVolume(newVolume: number): void;
  35214. /**
  35215. * Switch the panning model to HRTF:
  35216. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35218. */
  35219. switchPanningModelToHRTF(): void;
  35220. /**
  35221. * Switch the panning model to Equal Power:
  35222. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35224. */
  35225. switchPanningModelToEqualPower(): void;
  35226. /**
  35227. * Connect the sound track to an audio analyser allowing some amazing
  35228. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35230. * @param analyser The analyser to connect to the engine
  35231. */
  35232. connectToAnalyser(analyser: Analyser): void;
  35233. }
  35234. }
  35235. declare module "babylonjs/Audio/audioSceneComponent" {
  35236. import { Sound } from "babylonjs/Audio/sound";
  35237. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35238. import { Nullable } from "babylonjs/types";
  35239. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35240. import { Scene } from "babylonjs/scene";
  35241. import { AbstractScene } from "babylonjs/abstractScene";
  35242. module "babylonjs/abstractScene" {
  35243. interface AbstractScene {
  35244. /**
  35245. * The list of sounds used in the scene.
  35246. */
  35247. sounds: Nullable<Array<Sound>>;
  35248. }
  35249. }
  35250. module "babylonjs/scene" {
  35251. interface Scene {
  35252. /**
  35253. * @hidden
  35254. * Backing field
  35255. */
  35256. _mainSoundTrack: SoundTrack;
  35257. /**
  35258. * The main sound track played by the scene.
  35259. * It cotains your primary collection of sounds.
  35260. */
  35261. mainSoundTrack: SoundTrack;
  35262. /**
  35263. * The list of sound tracks added to the scene
  35264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35265. */
  35266. soundTracks: Nullable<Array<SoundTrack>>;
  35267. /**
  35268. * Gets a sound using a given name
  35269. * @param name defines the name to search for
  35270. * @return the found sound or null if not found at all.
  35271. */
  35272. getSoundByName(name: string): Nullable<Sound>;
  35273. /**
  35274. * Gets or sets if audio support is enabled
  35275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35276. */
  35277. audioEnabled: boolean;
  35278. /**
  35279. * Gets or sets if audio will be output to headphones
  35280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35281. */
  35282. headphone: boolean;
  35283. }
  35284. }
  35285. /**
  35286. * Defines the sound scene component responsible to manage any sounds
  35287. * in a given scene.
  35288. */
  35289. export class AudioSceneComponent implements ISceneSerializableComponent {
  35290. /**
  35291. * The component name helpfull to identify the component in the list of scene components.
  35292. */
  35293. readonly name: string;
  35294. /**
  35295. * The scene the component belongs to.
  35296. */
  35297. scene: Scene;
  35298. private _audioEnabled;
  35299. /**
  35300. * Gets whether audio is enabled or not.
  35301. * Please use related enable/disable method to switch state.
  35302. */
  35303. readonly audioEnabled: boolean;
  35304. private _headphone;
  35305. /**
  35306. * Gets whether audio is outputing to headphone or not.
  35307. * Please use the according Switch methods to change output.
  35308. */
  35309. readonly headphone: boolean;
  35310. /**
  35311. * Creates a new instance of the component for the given scene
  35312. * @param scene Defines the scene to register the component in
  35313. */
  35314. constructor(scene: Scene);
  35315. /**
  35316. * Registers the component in a given scene
  35317. */
  35318. register(): void;
  35319. /**
  35320. * Rebuilds the elements related to this component in case of
  35321. * context lost for instance.
  35322. */
  35323. rebuild(): void;
  35324. /**
  35325. * Serializes the component data to the specified json object
  35326. * @param serializationObject The object to serialize to
  35327. */
  35328. serialize(serializationObject: any): void;
  35329. /**
  35330. * Adds all the element from the container to the scene
  35331. * @param container the container holding the elements
  35332. */
  35333. addFromContainer(container: AbstractScene): void;
  35334. /**
  35335. * Removes all the elements in the container from the scene
  35336. * @param container contains the elements to remove
  35337. * @param dispose if the removed element should be disposed (default: false)
  35338. */
  35339. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35340. /**
  35341. * Disposes the component and the associated ressources.
  35342. */
  35343. dispose(): void;
  35344. /**
  35345. * Disables audio in the associated scene.
  35346. */
  35347. disableAudio(): void;
  35348. /**
  35349. * Enables audio in the associated scene.
  35350. */
  35351. enableAudio(): void;
  35352. /**
  35353. * Switch audio to headphone output.
  35354. */
  35355. switchAudioModeForHeadphones(): void;
  35356. /**
  35357. * Switch audio to normal speakers.
  35358. */
  35359. switchAudioModeForNormalSpeakers(): void;
  35360. private _afterRender;
  35361. }
  35362. }
  35363. declare module "babylonjs/Audio/weightedsound" {
  35364. import { Sound } from "babylonjs/Audio/sound";
  35365. /**
  35366. * Wraps one or more Sound objects and selects one with random weight for playback.
  35367. */
  35368. export class WeightedSound {
  35369. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35370. loop: boolean;
  35371. private _coneInnerAngle;
  35372. private _coneOuterAngle;
  35373. private _volume;
  35374. /** A Sound is currently playing. */
  35375. isPlaying: boolean;
  35376. /** A Sound is currently paused. */
  35377. isPaused: boolean;
  35378. private _sounds;
  35379. private _weights;
  35380. private _currentIndex?;
  35381. /**
  35382. * Creates a new WeightedSound from the list of sounds given.
  35383. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35384. * @param sounds Array of Sounds that will be selected from.
  35385. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35386. */
  35387. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35388. /**
  35389. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35390. */
  35391. /**
  35392. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35393. */
  35394. directionalConeInnerAngle: number;
  35395. /**
  35396. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35397. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35398. */
  35399. /**
  35400. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35401. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35402. */
  35403. directionalConeOuterAngle: number;
  35404. /**
  35405. * Playback volume.
  35406. */
  35407. /**
  35408. * Playback volume.
  35409. */
  35410. volume: number;
  35411. private _onended;
  35412. /**
  35413. * Suspend playback
  35414. */
  35415. pause(): void;
  35416. /**
  35417. * Stop playback
  35418. */
  35419. stop(): void;
  35420. /**
  35421. * Start playback.
  35422. * @param startOffset Position the clip head at a specific time in seconds.
  35423. */
  35424. play(startOffset?: number): void;
  35425. }
  35426. }
  35427. declare module "babylonjs/Audio/index" {
  35428. export * from "babylonjs/Audio/analyser";
  35429. export * from "babylonjs/Audio/audioEngine";
  35430. export * from "babylonjs/Audio/audioSceneComponent";
  35431. export * from "babylonjs/Audio/sound";
  35432. export * from "babylonjs/Audio/soundTrack";
  35433. export * from "babylonjs/Audio/weightedsound";
  35434. }
  35435. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35436. import { Behavior } from "babylonjs/Behaviors/behavior";
  35437. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35438. import { BackEase } from "babylonjs/Animations/easing";
  35439. /**
  35440. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35441. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35442. */
  35443. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35444. /**
  35445. * Gets the name of the behavior.
  35446. */
  35447. readonly name: string;
  35448. /**
  35449. * The easing function used by animations
  35450. */
  35451. static EasingFunction: BackEase;
  35452. /**
  35453. * The easing mode used by animations
  35454. */
  35455. static EasingMode: number;
  35456. /**
  35457. * The duration of the animation, in milliseconds
  35458. */
  35459. transitionDuration: number;
  35460. /**
  35461. * Length of the distance animated by the transition when lower radius is reached
  35462. */
  35463. lowerRadiusTransitionRange: number;
  35464. /**
  35465. * Length of the distance animated by the transition when upper radius is reached
  35466. */
  35467. upperRadiusTransitionRange: number;
  35468. private _autoTransitionRange;
  35469. /**
  35470. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35471. */
  35472. /**
  35473. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35474. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35475. */
  35476. autoTransitionRange: boolean;
  35477. private _attachedCamera;
  35478. private _onAfterCheckInputsObserver;
  35479. private _onMeshTargetChangedObserver;
  35480. /**
  35481. * Initializes the behavior.
  35482. */
  35483. init(): void;
  35484. /**
  35485. * Attaches the behavior to its arc rotate camera.
  35486. * @param camera Defines the camera to attach the behavior to
  35487. */
  35488. attach(camera: ArcRotateCamera): void;
  35489. /**
  35490. * Detaches the behavior from its current arc rotate camera.
  35491. */
  35492. detach(): void;
  35493. private _radiusIsAnimating;
  35494. private _radiusBounceTransition;
  35495. private _animatables;
  35496. private _cachedWheelPrecision;
  35497. /**
  35498. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35499. * @param radiusLimit The limit to check against.
  35500. * @return Bool to indicate if at limit.
  35501. */
  35502. private _isRadiusAtLimit;
  35503. /**
  35504. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35505. * @param radiusDelta The delta by which to animate to. Can be negative.
  35506. */
  35507. private _applyBoundRadiusAnimation;
  35508. /**
  35509. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35510. */
  35511. protected _clearAnimationLocks(): void;
  35512. /**
  35513. * Stops and removes all animations that have been applied to the camera
  35514. */
  35515. stopAllAnimations(): void;
  35516. }
  35517. }
  35518. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35519. import { Behavior } from "babylonjs/Behaviors/behavior";
  35520. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35521. import { ExponentialEase } from "babylonjs/Animations/easing";
  35522. import { Nullable } from "babylonjs/types";
  35523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35524. import { Vector3 } from "babylonjs/Maths/math";
  35525. /**
  35526. * 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.
  35527. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35528. */
  35529. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35530. /**
  35531. * Gets the name of the behavior.
  35532. */
  35533. readonly name: string;
  35534. private _mode;
  35535. private _radiusScale;
  35536. private _positionScale;
  35537. private _defaultElevation;
  35538. private _elevationReturnTime;
  35539. private _elevationReturnWaitTime;
  35540. private _zoomStopsAnimation;
  35541. private _framingTime;
  35542. /**
  35543. * The easing function used by animations
  35544. */
  35545. static EasingFunction: ExponentialEase;
  35546. /**
  35547. * The easing mode used by animations
  35548. */
  35549. static EasingMode: number;
  35550. /**
  35551. * Sets the current mode used by the behavior
  35552. */
  35553. /**
  35554. * Gets current mode used by the behavior.
  35555. */
  35556. mode: number;
  35557. /**
  35558. * Sets the scale applied to the radius (1 by default)
  35559. */
  35560. /**
  35561. * Gets the scale applied to the radius
  35562. */
  35563. radiusScale: number;
  35564. /**
  35565. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35566. */
  35567. /**
  35568. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35569. */
  35570. positionScale: number;
  35571. /**
  35572. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35573. * behaviour is triggered, in radians.
  35574. */
  35575. /**
  35576. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35577. * behaviour is triggered, in radians.
  35578. */
  35579. defaultElevation: number;
  35580. /**
  35581. * Sets the time (in milliseconds) taken to return to the default beta position.
  35582. * Negative value indicates camera should not return to default.
  35583. */
  35584. /**
  35585. * Gets the time (in milliseconds) taken to return to the default beta position.
  35586. * Negative value indicates camera should not return to default.
  35587. */
  35588. elevationReturnTime: number;
  35589. /**
  35590. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35591. */
  35592. /**
  35593. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35594. */
  35595. elevationReturnWaitTime: number;
  35596. /**
  35597. * Sets the flag that indicates if user zooming should stop animation.
  35598. */
  35599. /**
  35600. * Gets the flag that indicates if user zooming should stop animation.
  35601. */
  35602. zoomStopsAnimation: boolean;
  35603. /**
  35604. * Sets the transition time when framing the mesh, in milliseconds
  35605. */
  35606. /**
  35607. * Gets the transition time when framing the mesh, in milliseconds
  35608. */
  35609. framingTime: number;
  35610. /**
  35611. * Define if the behavior should automatically change the configured
  35612. * camera limits and sensibilities.
  35613. */
  35614. autoCorrectCameraLimitsAndSensibility: boolean;
  35615. private _onPrePointerObservableObserver;
  35616. private _onAfterCheckInputsObserver;
  35617. private _onMeshTargetChangedObserver;
  35618. private _attachedCamera;
  35619. private _isPointerDown;
  35620. private _lastInteractionTime;
  35621. /**
  35622. * Initializes the behavior.
  35623. */
  35624. init(): void;
  35625. /**
  35626. * Attaches the behavior to its arc rotate camera.
  35627. * @param camera Defines the camera to attach the behavior to
  35628. */
  35629. attach(camera: ArcRotateCamera): void;
  35630. /**
  35631. * Detaches the behavior from its current arc rotate camera.
  35632. */
  35633. detach(): void;
  35634. private _animatables;
  35635. private _betaIsAnimating;
  35636. private _betaTransition;
  35637. private _radiusTransition;
  35638. private _vectorTransition;
  35639. /**
  35640. * Targets the given mesh and updates zoom level accordingly.
  35641. * @param mesh The mesh to target.
  35642. * @param radius Optional. If a cached radius position already exists, overrides default.
  35643. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35644. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35645. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35646. */
  35647. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35648. /**
  35649. * Targets the given mesh with its children and updates zoom level accordingly.
  35650. * @param mesh The mesh to target.
  35651. * @param radius Optional. If a cached radius position already exists, overrides default.
  35652. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35653. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35654. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35655. */
  35656. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35657. /**
  35658. * Targets the given meshes with their children and updates zoom level accordingly.
  35659. * @param meshes The mesh to target.
  35660. * @param radius Optional. If a cached radius position already exists, overrides default.
  35661. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35662. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35663. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35664. */
  35665. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35666. /**
  35667. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35668. * @param minimumWorld Determines the smaller position of the bounding box extend
  35669. * @param maximumWorld Determines the bigger position of the bounding box extend
  35670. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35671. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35672. */
  35673. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35674. /**
  35675. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35676. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35677. * frustum width.
  35678. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35679. * to fully enclose the mesh in the viewing frustum.
  35680. */
  35681. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35682. /**
  35683. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35684. * is automatically returned to its default position (expected to be above ground plane).
  35685. */
  35686. private _maintainCameraAboveGround;
  35687. /**
  35688. * Returns the frustum slope based on the canvas ratio and camera FOV
  35689. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35690. */
  35691. private _getFrustumSlope;
  35692. /**
  35693. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35694. */
  35695. private _clearAnimationLocks;
  35696. /**
  35697. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35698. */
  35699. private _applyUserInteraction;
  35700. /**
  35701. * Stops and removes all animations that have been applied to the camera
  35702. */
  35703. stopAllAnimations(): void;
  35704. /**
  35705. * Gets a value indicating if the user is moving the camera
  35706. */
  35707. readonly isUserIsMoving: boolean;
  35708. /**
  35709. * The camera can move all the way towards the mesh.
  35710. */
  35711. static IgnoreBoundsSizeMode: number;
  35712. /**
  35713. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35714. */
  35715. static FitFrustumSidesMode: number;
  35716. }
  35717. }
  35718. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35719. import { Nullable } from "babylonjs/types";
  35720. import { Camera } from "babylonjs/Cameras/camera";
  35721. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35722. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35723. /**
  35724. * Base class for Camera Pointer Inputs.
  35725. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35726. * for example usage.
  35727. */
  35728. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35729. /**
  35730. * Defines the camera the input is attached to.
  35731. */
  35732. abstract camera: Camera;
  35733. /**
  35734. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35735. */
  35736. protected _altKey: boolean;
  35737. protected _ctrlKey: boolean;
  35738. protected _metaKey: boolean;
  35739. protected _shiftKey: boolean;
  35740. /**
  35741. * Which mouse buttons were pressed at time of last mouse event.
  35742. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35743. */
  35744. protected _buttonsPressed: number;
  35745. /**
  35746. * Defines the buttons associated with the input to handle camera move.
  35747. */
  35748. buttons: number[];
  35749. /**
  35750. * Attach the input controls to a specific dom element to get the input from.
  35751. * @param element Defines the element the controls should be listened from
  35752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35753. */
  35754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35755. /**
  35756. * Detach the current controls from the specified dom element.
  35757. * @param element Defines the element to stop listening the inputs from
  35758. */
  35759. detachControl(element: Nullable<HTMLElement>): void;
  35760. /**
  35761. * Gets the class name of the current input.
  35762. * @returns the class name
  35763. */
  35764. getClassName(): string;
  35765. /**
  35766. * Get the friendly name associated with the input class.
  35767. * @returns the input friendly name
  35768. */
  35769. getSimpleName(): string;
  35770. /**
  35771. * Called on pointer POINTERDOUBLETAP event.
  35772. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35773. */
  35774. protected onDoubleTap(type: string): void;
  35775. /**
  35776. * Called on pointer POINTERMOVE event if only a single touch is active.
  35777. * Override this method to provide functionality.
  35778. */
  35779. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35780. /**
  35781. * Called on pointer POINTERMOVE event if multiple touches are active.
  35782. * Override this method to provide functionality.
  35783. */
  35784. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35785. /**
  35786. * Called on JS contextmenu event.
  35787. * Override this method to provide functionality.
  35788. */
  35789. protected onContextMenu(evt: PointerEvent): void;
  35790. /**
  35791. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35792. * press.
  35793. * Override this method to provide functionality.
  35794. */
  35795. protected onButtonDown(evt: PointerEvent): void;
  35796. /**
  35797. * Called each time a new POINTERUP event occurs. Ie, for each button
  35798. * release.
  35799. * Override this method to provide functionality.
  35800. */
  35801. protected onButtonUp(evt: PointerEvent): void;
  35802. /**
  35803. * Called when window becomes inactive.
  35804. * Override this method to provide functionality.
  35805. */
  35806. protected onLostFocus(): void;
  35807. private _pointerInput;
  35808. private _observer;
  35809. private _onLostFocus;
  35810. private pointA;
  35811. private pointB;
  35812. }
  35813. }
  35814. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35815. import { Nullable } from "babylonjs/types";
  35816. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35817. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35818. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35819. /**
  35820. * Manage the pointers inputs to control an arc rotate camera.
  35821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35822. */
  35823. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35824. /**
  35825. * Defines the camera the input is attached to.
  35826. */
  35827. camera: ArcRotateCamera;
  35828. /**
  35829. * Gets the class name of the current input.
  35830. * @returns the class name
  35831. */
  35832. getClassName(): string;
  35833. /**
  35834. * Defines the buttons associated with the input to handle camera move.
  35835. */
  35836. buttons: number[];
  35837. /**
  35838. * Defines the pointer angular sensibility along the X axis or how fast is
  35839. * the camera rotating.
  35840. */
  35841. angularSensibilityX: number;
  35842. /**
  35843. * Defines the pointer angular sensibility along the Y axis or how fast is
  35844. * the camera rotating.
  35845. */
  35846. angularSensibilityY: number;
  35847. /**
  35848. * Defines the pointer pinch precision or how fast is the camera zooming.
  35849. */
  35850. pinchPrecision: number;
  35851. /**
  35852. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35853. * from 0.
  35854. * It defines the percentage of current camera.radius to use as delta when
  35855. * pinch zoom is used.
  35856. */
  35857. pinchDeltaPercentage: number;
  35858. /**
  35859. * Defines the pointer panning sensibility or how fast is the camera moving.
  35860. */
  35861. panningSensibility: number;
  35862. /**
  35863. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35864. */
  35865. multiTouchPanning: boolean;
  35866. /**
  35867. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35868. * zoom (pinch) through multitouch.
  35869. */
  35870. multiTouchPanAndZoom: boolean;
  35871. /**
  35872. * Revers pinch action direction.
  35873. */
  35874. pinchInwards: boolean;
  35875. private _isPanClick;
  35876. private _twoFingerActivityCount;
  35877. private _isPinching;
  35878. /**
  35879. * Called on pointer POINTERMOVE event if only a single touch is active.
  35880. */
  35881. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35882. /**
  35883. * Called on pointer POINTERDOUBLETAP event.
  35884. */
  35885. protected onDoubleTap(type: string): void;
  35886. /**
  35887. * Called on pointer POINTERMOVE event if multiple touches are active.
  35888. */
  35889. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35890. /**
  35891. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35892. * press.
  35893. */
  35894. protected onButtonDown(evt: PointerEvent): void;
  35895. /**
  35896. * Called each time a new POINTERUP event occurs. Ie, for each button
  35897. * release.
  35898. */
  35899. protected onButtonUp(evt: PointerEvent): void;
  35900. /**
  35901. * Called when window becomes inactive.
  35902. */
  35903. protected onLostFocus(): void;
  35904. }
  35905. }
  35906. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35907. import { Nullable } from "babylonjs/types";
  35908. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35909. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35910. /**
  35911. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35913. */
  35914. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35915. /**
  35916. * Defines the camera the input is attached to.
  35917. */
  35918. camera: ArcRotateCamera;
  35919. /**
  35920. * Defines the list of key codes associated with the up action (increase alpha)
  35921. */
  35922. keysUp: number[];
  35923. /**
  35924. * Defines the list of key codes associated with the down action (decrease alpha)
  35925. */
  35926. keysDown: number[];
  35927. /**
  35928. * Defines the list of key codes associated with the left action (increase beta)
  35929. */
  35930. keysLeft: number[];
  35931. /**
  35932. * Defines the list of key codes associated with the right action (decrease beta)
  35933. */
  35934. keysRight: number[];
  35935. /**
  35936. * Defines the list of key codes associated with the reset action.
  35937. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35938. */
  35939. keysReset: number[];
  35940. /**
  35941. * Defines the panning sensibility of the inputs.
  35942. * (How fast is the camera paning)
  35943. */
  35944. panningSensibility: number;
  35945. /**
  35946. * Defines the zooming sensibility of the inputs.
  35947. * (How fast is the camera zooming)
  35948. */
  35949. zoomingSensibility: number;
  35950. /**
  35951. * Defines wether maintaining the alt key down switch the movement mode from
  35952. * orientation to zoom.
  35953. */
  35954. useAltToZoom: boolean;
  35955. /**
  35956. * Rotation speed of the camera
  35957. */
  35958. angularSpeed: number;
  35959. private _keys;
  35960. private _ctrlPressed;
  35961. private _altPressed;
  35962. private _onCanvasBlurObserver;
  35963. private _onKeyboardObserver;
  35964. private _engine;
  35965. private _scene;
  35966. /**
  35967. * Attach the input controls to a specific dom element to get the input from.
  35968. * @param element Defines the element the controls should be listened from
  35969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35970. */
  35971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35972. /**
  35973. * Detach the current controls from the specified dom element.
  35974. * @param element Defines the element to stop listening the inputs from
  35975. */
  35976. detachControl(element: Nullable<HTMLElement>): void;
  35977. /**
  35978. * Update the current camera state depending on the inputs that have been used this frame.
  35979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35980. */
  35981. checkInputs(): void;
  35982. /**
  35983. * Gets the class name of the current intput.
  35984. * @returns the class name
  35985. */
  35986. getClassName(): string;
  35987. /**
  35988. * Get the friendly name associated with the input class.
  35989. * @returns the input friendly name
  35990. */
  35991. getSimpleName(): string;
  35992. }
  35993. }
  35994. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35995. import { Nullable } from "babylonjs/types";
  35996. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35997. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35998. /**
  35999. * Manage the mouse wheel inputs to control an arc rotate camera.
  36000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36001. */
  36002. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36003. /**
  36004. * Defines the camera the input is attached to.
  36005. */
  36006. camera: ArcRotateCamera;
  36007. /**
  36008. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36009. */
  36010. wheelPrecision: number;
  36011. /**
  36012. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36013. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36014. */
  36015. wheelDeltaPercentage: number;
  36016. private _wheel;
  36017. private _observer;
  36018. /**
  36019. * Attach the input controls to a specific dom element to get the input from.
  36020. * @param element Defines the element the controls should be listened from
  36021. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36022. */
  36023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36024. /**
  36025. * Detach the current controls from the specified dom element.
  36026. * @param element Defines the element to stop listening the inputs from
  36027. */
  36028. detachControl(element: Nullable<HTMLElement>): void;
  36029. /**
  36030. * Gets the class name of the current intput.
  36031. * @returns the class name
  36032. */
  36033. getClassName(): string;
  36034. /**
  36035. * Get the friendly name associated with the input class.
  36036. * @returns the input friendly name
  36037. */
  36038. getSimpleName(): string;
  36039. }
  36040. }
  36041. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36042. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36043. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36044. /**
  36045. * Default Inputs manager for the ArcRotateCamera.
  36046. * It groups all the default supported inputs for ease of use.
  36047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36048. */
  36049. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36050. /**
  36051. * Instantiates a new ArcRotateCameraInputsManager.
  36052. * @param camera Defines the camera the inputs belong to
  36053. */
  36054. constructor(camera: ArcRotateCamera);
  36055. /**
  36056. * Add mouse wheel input support to the input manager.
  36057. * @returns the current input manager
  36058. */
  36059. addMouseWheel(): ArcRotateCameraInputsManager;
  36060. /**
  36061. * Add pointers input support to the input manager.
  36062. * @returns the current input manager
  36063. */
  36064. addPointers(): ArcRotateCameraInputsManager;
  36065. /**
  36066. * Add keyboard input support to the input manager.
  36067. * @returns the current input manager
  36068. */
  36069. addKeyboard(): ArcRotateCameraInputsManager;
  36070. }
  36071. }
  36072. declare module "babylonjs/Cameras/arcRotateCamera" {
  36073. import { Observable } from "babylonjs/Misc/observable";
  36074. import { Nullable } from "babylonjs/types";
  36075. import { Scene } from "babylonjs/scene";
  36076. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36078. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36079. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36080. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36081. import { Camera } from "babylonjs/Cameras/camera";
  36082. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36083. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36084. import { Collider } from "babylonjs/Collisions/collider";
  36085. /**
  36086. * This represents an orbital type of camera.
  36087. *
  36088. * 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.
  36089. * 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.
  36090. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36091. */
  36092. export class ArcRotateCamera extends TargetCamera {
  36093. /**
  36094. * Defines the rotation angle of the camera along the longitudinal axis.
  36095. */
  36096. alpha: number;
  36097. /**
  36098. * Defines the rotation angle of the camera along the latitudinal axis.
  36099. */
  36100. beta: number;
  36101. /**
  36102. * Defines the radius of the camera from it s target point.
  36103. */
  36104. radius: number;
  36105. protected _target: Vector3;
  36106. protected _targetHost: Nullable<AbstractMesh>;
  36107. /**
  36108. * Defines the target point of the camera.
  36109. * The camera looks towards it form the radius distance.
  36110. */
  36111. target: Vector3;
  36112. /**
  36113. * Define the current local position of the camera in the scene
  36114. */
  36115. position: Vector3;
  36116. protected _upVector: Vector3;
  36117. protected _upToYMatrix: Matrix;
  36118. protected _YToUpMatrix: Matrix;
  36119. /**
  36120. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36121. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36122. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36123. */
  36124. upVector: Vector3;
  36125. /**
  36126. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36127. */
  36128. setMatUp(): void;
  36129. /**
  36130. * Current inertia value on the longitudinal axis.
  36131. * The bigger this number the longer it will take for the camera to stop.
  36132. */
  36133. inertialAlphaOffset: number;
  36134. /**
  36135. * Current inertia value on the latitudinal axis.
  36136. * The bigger this number the longer it will take for the camera to stop.
  36137. */
  36138. inertialBetaOffset: number;
  36139. /**
  36140. * Current inertia value on the radius axis.
  36141. * The bigger this number the longer it will take for the camera to stop.
  36142. */
  36143. inertialRadiusOffset: number;
  36144. /**
  36145. * Minimum allowed angle on the longitudinal axis.
  36146. * This can help limiting how the Camera is able to move in the scene.
  36147. */
  36148. lowerAlphaLimit: Nullable<number>;
  36149. /**
  36150. * Maximum allowed angle on the longitudinal axis.
  36151. * This can help limiting how the Camera is able to move in the scene.
  36152. */
  36153. upperAlphaLimit: Nullable<number>;
  36154. /**
  36155. * Minimum allowed angle on the latitudinal axis.
  36156. * This can help limiting how the Camera is able to move in the scene.
  36157. */
  36158. lowerBetaLimit: number;
  36159. /**
  36160. * Maximum allowed angle on the latitudinal axis.
  36161. * This can help limiting how the Camera is able to move in the scene.
  36162. */
  36163. upperBetaLimit: number;
  36164. /**
  36165. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36166. * This can help limiting how the Camera is able to move in the scene.
  36167. */
  36168. lowerRadiusLimit: Nullable<number>;
  36169. /**
  36170. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36171. * This can help limiting how the Camera is able to move in the scene.
  36172. */
  36173. upperRadiusLimit: Nullable<number>;
  36174. /**
  36175. * Defines the current inertia value used during panning of the camera along the X axis.
  36176. */
  36177. inertialPanningX: number;
  36178. /**
  36179. * Defines the current inertia value used during panning of the camera along the Y axis.
  36180. */
  36181. inertialPanningY: number;
  36182. /**
  36183. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36184. * Basically if your fingers moves away from more than this distance you will be considered
  36185. * in pinch mode.
  36186. */
  36187. pinchToPanMaxDistance: number;
  36188. /**
  36189. * Defines the maximum distance the camera can pan.
  36190. * This could help keeping the cammera always in your scene.
  36191. */
  36192. panningDistanceLimit: Nullable<number>;
  36193. /**
  36194. * Defines the target of the camera before paning.
  36195. */
  36196. panningOriginTarget: Vector3;
  36197. /**
  36198. * Defines the value of the inertia used during panning.
  36199. * 0 would mean stop inertia and one would mean no decelleration at all.
  36200. */
  36201. panningInertia: number;
  36202. /**
  36203. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36204. */
  36205. angularSensibilityX: number;
  36206. /**
  36207. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36208. */
  36209. angularSensibilityY: number;
  36210. /**
  36211. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36212. */
  36213. pinchPrecision: number;
  36214. /**
  36215. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36216. * It will be used instead of pinchDeltaPrecision if different from 0.
  36217. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36218. */
  36219. pinchDeltaPercentage: number;
  36220. /**
  36221. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36222. */
  36223. panningSensibility: number;
  36224. /**
  36225. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36226. */
  36227. keysUp: number[];
  36228. /**
  36229. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36230. */
  36231. keysDown: number[];
  36232. /**
  36233. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36234. */
  36235. keysLeft: number[];
  36236. /**
  36237. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36238. */
  36239. keysRight: number[];
  36240. /**
  36241. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36242. */
  36243. wheelPrecision: number;
  36244. /**
  36245. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36246. * It will be used instead of pinchDeltaPrecision if different from 0.
  36247. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36248. */
  36249. wheelDeltaPercentage: number;
  36250. /**
  36251. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36252. */
  36253. zoomOnFactor: number;
  36254. /**
  36255. * Defines a screen offset for the camera position.
  36256. */
  36257. targetScreenOffset: Vector2;
  36258. /**
  36259. * Allows the camera to be completely reversed.
  36260. * If false the camera can not arrive upside down.
  36261. */
  36262. allowUpsideDown: boolean;
  36263. /**
  36264. * Define if double tap/click is used to restore the previously saved state of the camera.
  36265. */
  36266. useInputToRestoreState: boolean;
  36267. /** @hidden */
  36268. _viewMatrix: Matrix;
  36269. /** @hidden */
  36270. _useCtrlForPanning: boolean;
  36271. /** @hidden */
  36272. _panningMouseButton: number;
  36273. /**
  36274. * Defines the input associated to the camera.
  36275. */
  36276. inputs: ArcRotateCameraInputsManager;
  36277. /** @hidden */
  36278. _reset: () => void;
  36279. /**
  36280. * Defines the allowed panning axis.
  36281. */
  36282. panningAxis: Vector3;
  36283. protected _localDirection: Vector3;
  36284. protected _transformedDirection: Vector3;
  36285. private _bouncingBehavior;
  36286. /**
  36287. * Gets the bouncing behavior of the camera if it has been enabled.
  36288. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36289. */
  36290. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36291. /**
  36292. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36293. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36294. */
  36295. useBouncingBehavior: boolean;
  36296. private _framingBehavior;
  36297. /**
  36298. * Gets the framing behavior of the camera if it has been enabled.
  36299. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36300. */
  36301. readonly framingBehavior: Nullable<FramingBehavior>;
  36302. /**
  36303. * Defines if the framing behavior of the camera is enabled on the camera.
  36304. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36305. */
  36306. useFramingBehavior: boolean;
  36307. private _autoRotationBehavior;
  36308. /**
  36309. * Gets the auto rotation behavior of the camera if it has been enabled.
  36310. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36311. */
  36312. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36313. /**
  36314. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36315. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36316. */
  36317. useAutoRotationBehavior: boolean;
  36318. /**
  36319. * Observable triggered when the mesh target has been changed on the camera.
  36320. */
  36321. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36322. /**
  36323. * Event raised when the camera is colliding with a mesh.
  36324. */
  36325. onCollide: (collidedMesh: AbstractMesh) => void;
  36326. /**
  36327. * Defines whether the camera should check collision with the objects oh the scene.
  36328. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36329. */
  36330. checkCollisions: boolean;
  36331. /**
  36332. * Defines the collision radius of the camera.
  36333. * This simulates a sphere around the camera.
  36334. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36335. */
  36336. collisionRadius: Vector3;
  36337. protected _collider: Collider;
  36338. protected _previousPosition: Vector3;
  36339. protected _collisionVelocity: Vector3;
  36340. protected _newPosition: Vector3;
  36341. protected _previousAlpha: number;
  36342. protected _previousBeta: number;
  36343. protected _previousRadius: number;
  36344. protected _collisionTriggered: boolean;
  36345. protected _targetBoundingCenter: Nullable<Vector3>;
  36346. private _computationVector;
  36347. /**
  36348. * Instantiates a new ArcRotateCamera in a given scene
  36349. * @param name Defines the name of the camera
  36350. * @param alpha Defines the camera rotation along the logitudinal axis
  36351. * @param beta Defines the camera rotation along the latitudinal axis
  36352. * @param radius Defines the camera distance from its target
  36353. * @param target Defines the camera target
  36354. * @param scene Defines the scene the camera belongs to
  36355. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36356. */
  36357. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36358. /** @hidden */
  36359. _initCache(): void;
  36360. /** @hidden */
  36361. _updateCache(ignoreParentClass?: boolean): void;
  36362. protected _getTargetPosition(): Vector3;
  36363. private _storedAlpha;
  36364. private _storedBeta;
  36365. private _storedRadius;
  36366. private _storedTarget;
  36367. /**
  36368. * Stores the current state of the camera (alpha, beta, radius and target)
  36369. * @returns the camera itself
  36370. */
  36371. storeState(): Camera;
  36372. /**
  36373. * @hidden
  36374. * Restored camera state. You must call storeState() first
  36375. */
  36376. _restoreStateValues(): boolean;
  36377. /** @hidden */
  36378. _isSynchronizedViewMatrix(): boolean;
  36379. /**
  36380. * Attached controls to the current camera.
  36381. * @param element Defines the element the controls should be listened from
  36382. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36383. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36384. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36385. */
  36386. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36387. /**
  36388. * Detach the current controls from the camera.
  36389. * The camera will stop reacting to inputs.
  36390. * @param element Defines the element to stop listening the inputs from
  36391. */
  36392. detachControl(element: HTMLElement): void;
  36393. /** @hidden */
  36394. _checkInputs(): void;
  36395. protected _checkLimits(): void;
  36396. /**
  36397. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36398. */
  36399. rebuildAnglesAndRadius(): void;
  36400. /**
  36401. * Use a position to define the current camera related information like aplha, beta and radius
  36402. * @param position Defines the position to set the camera at
  36403. */
  36404. setPosition(position: Vector3): void;
  36405. /**
  36406. * Defines the target the camera should look at.
  36407. * This will automatically adapt alpha beta and radius to fit within the new target.
  36408. * @param target Defines the new target as a Vector or a mesh
  36409. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36410. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36411. */
  36412. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36413. /** @hidden */
  36414. _getViewMatrix(): Matrix;
  36415. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36416. /**
  36417. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36418. * @param meshes Defines the mesh to zoom on
  36419. * @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)
  36420. */
  36421. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36422. /**
  36423. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36424. * The target will be changed but the radius
  36425. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36426. * @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)
  36427. */
  36428. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36429. min: Vector3;
  36430. max: Vector3;
  36431. distance: number;
  36432. }, doNotUpdateMaxZ?: boolean): void;
  36433. /**
  36434. * @override
  36435. * Override Camera.createRigCamera
  36436. */
  36437. createRigCamera(name: string, cameraIndex: number): Camera;
  36438. /**
  36439. * @hidden
  36440. * @override
  36441. * Override Camera._updateRigCameras
  36442. */
  36443. _updateRigCameras(): void;
  36444. /**
  36445. * Destroy the camera and release the current resources hold by it.
  36446. */
  36447. dispose(): void;
  36448. /**
  36449. * Gets the current object class name.
  36450. * @return the class name
  36451. */
  36452. getClassName(): string;
  36453. }
  36454. }
  36455. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36456. import { Behavior } from "babylonjs/Behaviors/behavior";
  36457. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36458. /**
  36459. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36460. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36461. */
  36462. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36463. /**
  36464. * Gets the name of the behavior.
  36465. */
  36466. readonly name: string;
  36467. private _zoomStopsAnimation;
  36468. private _idleRotationSpeed;
  36469. private _idleRotationWaitTime;
  36470. private _idleRotationSpinupTime;
  36471. /**
  36472. * Sets the flag that indicates if user zooming should stop animation.
  36473. */
  36474. /**
  36475. * Gets the flag that indicates if user zooming should stop animation.
  36476. */
  36477. zoomStopsAnimation: boolean;
  36478. /**
  36479. * Sets the default speed at which the camera rotates around the model.
  36480. */
  36481. /**
  36482. * Gets the default speed at which the camera rotates around the model.
  36483. */
  36484. idleRotationSpeed: number;
  36485. /**
  36486. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36487. */
  36488. /**
  36489. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36490. */
  36491. idleRotationWaitTime: number;
  36492. /**
  36493. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36494. */
  36495. /**
  36496. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36497. */
  36498. idleRotationSpinupTime: number;
  36499. /**
  36500. * Gets a value indicating if the camera is currently rotating because of this behavior
  36501. */
  36502. readonly rotationInProgress: boolean;
  36503. private _onPrePointerObservableObserver;
  36504. private _onAfterCheckInputsObserver;
  36505. private _attachedCamera;
  36506. private _isPointerDown;
  36507. private _lastFrameTime;
  36508. private _lastInteractionTime;
  36509. private _cameraRotationSpeed;
  36510. /**
  36511. * Initializes the behavior.
  36512. */
  36513. init(): void;
  36514. /**
  36515. * Attaches the behavior to its arc rotate camera.
  36516. * @param camera Defines the camera to attach the behavior to
  36517. */
  36518. attach(camera: ArcRotateCamera): void;
  36519. /**
  36520. * Detaches the behavior from its current arc rotate camera.
  36521. */
  36522. detach(): void;
  36523. /**
  36524. * Returns true if user is scrolling.
  36525. * @return true if user is scrolling.
  36526. */
  36527. private _userIsZooming;
  36528. private _lastFrameRadius;
  36529. private _shouldAnimationStopForInteraction;
  36530. /**
  36531. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36532. */
  36533. private _applyUserInteraction;
  36534. private _userIsMoving;
  36535. }
  36536. }
  36537. declare module "babylonjs/Behaviors/Cameras/index" {
  36538. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36539. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36540. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36541. }
  36542. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36543. import { Mesh } from "babylonjs/Meshes/mesh";
  36544. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36545. import { Behavior } from "babylonjs/Behaviors/behavior";
  36546. /**
  36547. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36548. */
  36549. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36550. private ui;
  36551. /**
  36552. * The name of the behavior
  36553. */
  36554. name: string;
  36555. /**
  36556. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36557. */
  36558. distanceAwayFromFace: number;
  36559. /**
  36560. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36561. */
  36562. distanceAwayFromBottomOfFace: number;
  36563. private _faceVectors;
  36564. private _target;
  36565. private _scene;
  36566. private _onRenderObserver;
  36567. private _tmpMatrix;
  36568. private _tmpVector;
  36569. /**
  36570. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36571. * @param ui The transform node that should be attched to the mesh
  36572. */
  36573. constructor(ui: TransformNode);
  36574. /**
  36575. * Initializes the behavior
  36576. */
  36577. init(): void;
  36578. private _closestFace;
  36579. private _zeroVector;
  36580. private _lookAtTmpMatrix;
  36581. private _lookAtToRef;
  36582. /**
  36583. * Attaches the AttachToBoxBehavior to the passed in mesh
  36584. * @param target The mesh that the specified node will be attached to
  36585. */
  36586. attach(target: Mesh): void;
  36587. /**
  36588. * Detaches the behavior from the mesh
  36589. */
  36590. detach(): void;
  36591. }
  36592. }
  36593. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36594. import { Behavior } from "babylonjs/Behaviors/behavior";
  36595. import { Mesh } from "babylonjs/Meshes/mesh";
  36596. /**
  36597. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36598. */
  36599. export class FadeInOutBehavior implements Behavior<Mesh> {
  36600. /**
  36601. * Time in milliseconds to delay before fading in (Default: 0)
  36602. */
  36603. delay: number;
  36604. /**
  36605. * Time in milliseconds for the mesh to fade in (Default: 300)
  36606. */
  36607. fadeInTime: number;
  36608. private _millisecondsPerFrame;
  36609. private _hovered;
  36610. private _hoverValue;
  36611. private _ownerNode;
  36612. /**
  36613. * Instatiates the FadeInOutBehavior
  36614. */
  36615. constructor();
  36616. /**
  36617. * The name of the behavior
  36618. */
  36619. readonly name: string;
  36620. /**
  36621. * Initializes the behavior
  36622. */
  36623. init(): void;
  36624. /**
  36625. * Attaches the fade behavior on the passed in mesh
  36626. * @param ownerNode The mesh that will be faded in/out once attached
  36627. */
  36628. attach(ownerNode: Mesh): void;
  36629. /**
  36630. * Detaches the behavior from the mesh
  36631. */
  36632. detach(): void;
  36633. /**
  36634. * Triggers the mesh to begin fading in or out
  36635. * @param value if the object should fade in or out (true to fade in)
  36636. */
  36637. fadeIn(value: boolean): void;
  36638. private _update;
  36639. private _setAllVisibility;
  36640. }
  36641. }
  36642. declare module "babylonjs/Misc/pivotTools" {
  36643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36644. /**
  36645. * Class containing a set of static utilities functions for managing Pivots
  36646. * @hidden
  36647. */
  36648. export class PivotTools {
  36649. private static _PivotCached;
  36650. private static _OldPivotPoint;
  36651. private static _PivotTranslation;
  36652. private static _PivotTmpVector;
  36653. /** @hidden */
  36654. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36655. /** @hidden */
  36656. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36657. }
  36658. }
  36659. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36660. import { Scene } from "babylonjs/scene";
  36661. import { Vector4, Plane } from "babylonjs/Maths/math";
  36662. import { Mesh } from "babylonjs/Meshes/mesh";
  36663. import { Nullable } from "babylonjs/types";
  36664. /**
  36665. * Class containing static functions to help procedurally build meshes
  36666. */
  36667. export class PlaneBuilder {
  36668. /**
  36669. * Creates a plane mesh
  36670. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36671. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36672. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36676. * @param name defines the name of the mesh
  36677. * @param options defines the options used to create the mesh
  36678. * @param scene defines the hosting scene
  36679. * @returns the plane mesh
  36680. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36681. */
  36682. static CreatePlane(name: string, options: {
  36683. size?: number;
  36684. width?: number;
  36685. height?: number;
  36686. sideOrientation?: number;
  36687. frontUVs?: Vector4;
  36688. backUVs?: Vector4;
  36689. updatable?: boolean;
  36690. sourcePlane?: Plane;
  36691. }, scene?: Nullable<Scene>): Mesh;
  36692. }
  36693. }
  36694. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36695. import { Behavior } from "babylonjs/Behaviors/behavior";
  36696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36697. import { Observable } from "babylonjs/Misc/observable";
  36698. import { Vector3 } from "babylonjs/Maths/math";
  36699. import { Ray } from "babylonjs/Culling/ray";
  36700. import "babylonjs/Meshes/Builders/planeBuilder";
  36701. /**
  36702. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36703. */
  36704. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36705. private static _AnyMouseID;
  36706. private _attachedNode;
  36707. private _dragPlane;
  36708. private _scene;
  36709. private _pointerObserver;
  36710. private _beforeRenderObserver;
  36711. private static _planeScene;
  36712. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36713. /**
  36714. * 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)
  36715. */
  36716. maxDragAngle: number;
  36717. /**
  36718. * @hidden
  36719. */
  36720. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36721. /**
  36722. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36723. */
  36724. currentDraggingPointerID: number;
  36725. /**
  36726. * The last position where the pointer hit the drag plane in world space
  36727. */
  36728. lastDragPosition: Vector3;
  36729. /**
  36730. * If the behavior is currently in a dragging state
  36731. */
  36732. dragging: boolean;
  36733. /**
  36734. * 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)
  36735. */
  36736. dragDeltaRatio: number;
  36737. /**
  36738. * If the drag plane orientation should be updated during the dragging (Default: true)
  36739. */
  36740. updateDragPlane: boolean;
  36741. private _debugMode;
  36742. private _moving;
  36743. /**
  36744. * Fires each time the attached mesh is dragged with the pointer
  36745. * * delta between last drag position and current drag position in world space
  36746. * * dragDistance along the drag axis
  36747. * * dragPlaneNormal normal of the current drag plane used during the drag
  36748. * * dragPlanePoint in world space where the drag intersects the drag plane
  36749. */
  36750. onDragObservable: Observable<{
  36751. delta: Vector3;
  36752. dragPlanePoint: Vector3;
  36753. dragPlaneNormal: Vector3;
  36754. dragDistance: number;
  36755. pointerId: number;
  36756. }>;
  36757. /**
  36758. * Fires each time a drag begins (eg. mouse down on mesh)
  36759. */
  36760. onDragStartObservable: Observable<{
  36761. dragPlanePoint: Vector3;
  36762. pointerId: number;
  36763. }>;
  36764. /**
  36765. * Fires each time a drag ends (eg. mouse release after drag)
  36766. */
  36767. onDragEndObservable: Observable<{
  36768. dragPlanePoint: Vector3;
  36769. pointerId: number;
  36770. }>;
  36771. /**
  36772. * If the attached mesh should be moved when dragged
  36773. */
  36774. moveAttached: boolean;
  36775. /**
  36776. * If the drag behavior will react to drag events (Default: true)
  36777. */
  36778. enabled: boolean;
  36779. /**
  36780. * If camera controls should be detached during the drag
  36781. */
  36782. detachCameraControls: boolean;
  36783. /**
  36784. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36785. */
  36786. useObjectOrienationForDragging: boolean;
  36787. private _options;
  36788. /**
  36789. * Creates a pointer drag behavior that can be attached to a mesh
  36790. * @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)
  36791. */
  36792. constructor(options?: {
  36793. dragAxis?: Vector3;
  36794. dragPlaneNormal?: Vector3;
  36795. });
  36796. /**
  36797. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36798. */
  36799. validateDrag: (targetPosition: Vector3) => boolean;
  36800. /**
  36801. * The name of the behavior
  36802. */
  36803. readonly name: string;
  36804. /**
  36805. * Initializes the behavior
  36806. */
  36807. init(): void;
  36808. private _tmpVector;
  36809. private _alternatePickedPoint;
  36810. private _worldDragAxis;
  36811. private _targetPosition;
  36812. private _attachedElement;
  36813. /**
  36814. * Attaches the drag behavior the passed in mesh
  36815. * @param ownerNode The mesh that will be dragged around once attached
  36816. */
  36817. attach(ownerNode: AbstractMesh): void;
  36818. /**
  36819. * Force relase the drag action by code.
  36820. */
  36821. releaseDrag(): void;
  36822. private _startDragRay;
  36823. private _lastPointerRay;
  36824. /**
  36825. * Simulates the start of a pointer drag event on the behavior
  36826. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36827. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36828. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36829. */
  36830. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36831. private _startDrag;
  36832. private _dragDelta;
  36833. private _moveDrag;
  36834. private _pickWithRayOnDragPlane;
  36835. private _pointA;
  36836. private _pointB;
  36837. private _pointC;
  36838. private _lineA;
  36839. private _lineB;
  36840. private _localAxis;
  36841. private _lookAt;
  36842. private _updateDragPlanePosition;
  36843. /**
  36844. * Detaches the behavior from the mesh
  36845. */
  36846. detach(): void;
  36847. }
  36848. }
  36849. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36850. import { Mesh } from "babylonjs/Meshes/mesh";
  36851. import { Behavior } from "babylonjs/Behaviors/behavior";
  36852. /**
  36853. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36854. */
  36855. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36856. private _dragBehaviorA;
  36857. private _dragBehaviorB;
  36858. private _startDistance;
  36859. private _initialScale;
  36860. private _targetScale;
  36861. private _ownerNode;
  36862. private _sceneRenderObserver;
  36863. /**
  36864. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36865. */
  36866. constructor();
  36867. /**
  36868. * The name of the behavior
  36869. */
  36870. readonly name: string;
  36871. /**
  36872. * Initializes the behavior
  36873. */
  36874. init(): void;
  36875. private _getCurrentDistance;
  36876. /**
  36877. * Attaches the scale behavior the passed in mesh
  36878. * @param ownerNode The mesh that will be scaled around once attached
  36879. */
  36880. attach(ownerNode: Mesh): void;
  36881. /**
  36882. * Detaches the behavior from the mesh
  36883. */
  36884. detach(): void;
  36885. }
  36886. }
  36887. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36888. import { Behavior } from "babylonjs/Behaviors/behavior";
  36889. import { Mesh } from "babylonjs/Meshes/mesh";
  36890. import { Observable } from "babylonjs/Misc/observable";
  36891. /**
  36892. * 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
  36893. */
  36894. export class SixDofDragBehavior implements Behavior<Mesh> {
  36895. private static _virtualScene;
  36896. private _ownerNode;
  36897. private _sceneRenderObserver;
  36898. private _scene;
  36899. private _targetPosition;
  36900. private _virtualOriginMesh;
  36901. private _virtualDragMesh;
  36902. private _pointerObserver;
  36903. private _moving;
  36904. private _startingOrientation;
  36905. /**
  36906. * 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)
  36907. */
  36908. private zDragFactor;
  36909. /**
  36910. * If the object should rotate to face the drag origin
  36911. */
  36912. rotateDraggedObject: boolean;
  36913. /**
  36914. * If the behavior is currently in a dragging state
  36915. */
  36916. dragging: boolean;
  36917. /**
  36918. * 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)
  36919. */
  36920. dragDeltaRatio: number;
  36921. /**
  36922. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36923. */
  36924. currentDraggingPointerID: number;
  36925. /**
  36926. * If camera controls should be detached during the drag
  36927. */
  36928. detachCameraControls: boolean;
  36929. /**
  36930. * Fires each time a drag starts
  36931. */
  36932. onDragStartObservable: Observable<{}>;
  36933. /**
  36934. * Fires each time a drag ends (eg. mouse release after drag)
  36935. */
  36936. onDragEndObservable: Observable<{}>;
  36937. /**
  36938. * 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
  36939. */
  36940. constructor();
  36941. /**
  36942. * The name of the behavior
  36943. */
  36944. readonly name: string;
  36945. /**
  36946. * Initializes the behavior
  36947. */
  36948. init(): void;
  36949. /**
  36950. * Attaches the scale behavior the passed in mesh
  36951. * @param ownerNode The mesh that will be scaled around once attached
  36952. */
  36953. attach(ownerNode: Mesh): void;
  36954. /**
  36955. * Detaches the behavior from the mesh
  36956. */
  36957. detach(): void;
  36958. }
  36959. }
  36960. declare module "babylonjs/Behaviors/Meshes/index" {
  36961. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36962. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36963. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36964. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36965. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36966. }
  36967. declare module "babylonjs/Behaviors/index" {
  36968. export * from "babylonjs/Behaviors/behavior";
  36969. export * from "babylonjs/Behaviors/Cameras/index";
  36970. export * from "babylonjs/Behaviors/Meshes/index";
  36971. }
  36972. declare module "babylonjs/Bones/boneIKController" {
  36973. import { Bone } from "babylonjs/Bones/bone";
  36974. import { Vector3 } from "babylonjs/Maths/math";
  36975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36976. import { Nullable } from "babylonjs/types";
  36977. /**
  36978. * Class used to apply inverse kinematics to bones
  36979. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36980. */
  36981. export class BoneIKController {
  36982. private static _tmpVecs;
  36983. private static _tmpQuat;
  36984. private static _tmpMats;
  36985. /**
  36986. * Gets or sets the target mesh
  36987. */
  36988. targetMesh: AbstractMesh;
  36989. /** Gets or sets the mesh used as pole */
  36990. poleTargetMesh: AbstractMesh;
  36991. /**
  36992. * Gets or sets the bone used as pole
  36993. */
  36994. poleTargetBone: Nullable<Bone>;
  36995. /**
  36996. * Gets or sets the target position
  36997. */
  36998. targetPosition: Vector3;
  36999. /**
  37000. * Gets or sets the pole target position
  37001. */
  37002. poleTargetPosition: Vector3;
  37003. /**
  37004. * Gets or sets the pole target local offset
  37005. */
  37006. poleTargetLocalOffset: Vector3;
  37007. /**
  37008. * Gets or sets the pole angle
  37009. */
  37010. poleAngle: number;
  37011. /**
  37012. * Gets or sets the mesh associated with the controller
  37013. */
  37014. mesh: AbstractMesh;
  37015. /**
  37016. * 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)
  37017. */
  37018. slerpAmount: number;
  37019. private _bone1Quat;
  37020. private _bone1Mat;
  37021. private _bone2Ang;
  37022. private _bone1;
  37023. private _bone2;
  37024. private _bone1Length;
  37025. private _bone2Length;
  37026. private _maxAngle;
  37027. private _maxReach;
  37028. private _rightHandedSystem;
  37029. private _bendAxis;
  37030. private _slerping;
  37031. private _adjustRoll;
  37032. /**
  37033. * Gets or sets maximum allowed angle
  37034. */
  37035. maxAngle: number;
  37036. /**
  37037. * Creates a new BoneIKController
  37038. * @param mesh defines the mesh to control
  37039. * @param bone defines the bone to control
  37040. * @param options defines options to set up the controller
  37041. */
  37042. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37043. targetMesh?: AbstractMesh;
  37044. poleTargetMesh?: AbstractMesh;
  37045. poleTargetBone?: Bone;
  37046. poleTargetLocalOffset?: Vector3;
  37047. poleAngle?: number;
  37048. bendAxis?: Vector3;
  37049. maxAngle?: number;
  37050. slerpAmount?: number;
  37051. });
  37052. private _setMaxAngle;
  37053. /**
  37054. * Force the controller to update the bones
  37055. */
  37056. update(): void;
  37057. }
  37058. }
  37059. declare module "babylonjs/Bones/boneLookController" {
  37060. import { Vector3, Space } from "babylonjs/Maths/math";
  37061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37062. import { Bone } from "babylonjs/Bones/bone";
  37063. /**
  37064. * Class used to make a bone look toward a point in space
  37065. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37066. */
  37067. export class BoneLookController {
  37068. private static _tmpVecs;
  37069. private static _tmpQuat;
  37070. private static _tmpMats;
  37071. /**
  37072. * The target Vector3 that the bone will look at
  37073. */
  37074. target: Vector3;
  37075. /**
  37076. * The mesh that the bone is attached to
  37077. */
  37078. mesh: AbstractMesh;
  37079. /**
  37080. * The bone that will be looking to the target
  37081. */
  37082. bone: Bone;
  37083. /**
  37084. * The up axis of the coordinate system that is used when the bone is rotated
  37085. */
  37086. upAxis: Vector3;
  37087. /**
  37088. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37089. */
  37090. upAxisSpace: Space;
  37091. /**
  37092. * Used to make an adjustment to the yaw of the bone
  37093. */
  37094. adjustYaw: number;
  37095. /**
  37096. * Used to make an adjustment to the pitch of the bone
  37097. */
  37098. adjustPitch: number;
  37099. /**
  37100. * Used to make an adjustment to the roll of the bone
  37101. */
  37102. adjustRoll: number;
  37103. /**
  37104. * 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)
  37105. */
  37106. slerpAmount: number;
  37107. private _minYaw;
  37108. private _maxYaw;
  37109. private _minPitch;
  37110. private _maxPitch;
  37111. private _minYawSin;
  37112. private _minYawCos;
  37113. private _maxYawSin;
  37114. private _maxYawCos;
  37115. private _midYawConstraint;
  37116. private _minPitchTan;
  37117. private _maxPitchTan;
  37118. private _boneQuat;
  37119. private _slerping;
  37120. private _transformYawPitch;
  37121. private _transformYawPitchInv;
  37122. private _firstFrameSkipped;
  37123. private _yawRange;
  37124. private _fowardAxis;
  37125. /**
  37126. * Gets or sets the minimum yaw angle that the bone can look to
  37127. */
  37128. minYaw: number;
  37129. /**
  37130. * Gets or sets the maximum yaw angle that the bone can look to
  37131. */
  37132. maxYaw: number;
  37133. /**
  37134. * Gets or sets the minimum pitch angle that the bone can look to
  37135. */
  37136. minPitch: number;
  37137. /**
  37138. * Gets or sets the maximum pitch angle that the bone can look to
  37139. */
  37140. maxPitch: number;
  37141. /**
  37142. * Create a BoneLookController
  37143. * @param mesh the mesh that the bone belongs to
  37144. * @param bone the bone that will be looking to the target
  37145. * @param target the target Vector3 to look at
  37146. * @param options optional settings:
  37147. * * maxYaw: the maximum angle the bone will yaw to
  37148. * * minYaw: the minimum angle the bone will yaw to
  37149. * * maxPitch: the maximum angle the bone will pitch to
  37150. * * minPitch: the minimum angle the bone will yaw to
  37151. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37152. * * upAxis: the up axis of the coordinate system
  37153. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37154. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37155. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37156. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37157. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37158. * * adjustRoll: used to make an adjustment to the roll of the bone
  37159. **/
  37160. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37161. maxYaw?: number;
  37162. minYaw?: number;
  37163. maxPitch?: number;
  37164. minPitch?: number;
  37165. slerpAmount?: number;
  37166. upAxis?: Vector3;
  37167. upAxisSpace?: Space;
  37168. yawAxis?: Vector3;
  37169. pitchAxis?: Vector3;
  37170. adjustYaw?: number;
  37171. adjustPitch?: number;
  37172. adjustRoll?: number;
  37173. });
  37174. /**
  37175. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37176. */
  37177. update(): void;
  37178. private _getAngleDiff;
  37179. private _getAngleBetween;
  37180. private _isAngleBetween;
  37181. }
  37182. }
  37183. declare module "babylonjs/Bones/index" {
  37184. export * from "babylonjs/Bones/bone";
  37185. export * from "babylonjs/Bones/boneIKController";
  37186. export * from "babylonjs/Bones/boneLookController";
  37187. export * from "babylonjs/Bones/skeleton";
  37188. }
  37189. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37190. import { Nullable } from "babylonjs/types";
  37191. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37192. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37193. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37194. /**
  37195. * Manage the gamepad inputs to control an arc rotate camera.
  37196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37197. */
  37198. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37199. /**
  37200. * Defines the camera the input is attached to.
  37201. */
  37202. camera: ArcRotateCamera;
  37203. /**
  37204. * Defines the gamepad the input is gathering event from.
  37205. */
  37206. gamepad: Nullable<Gamepad>;
  37207. /**
  37208. * Defines the gamepad rotation sensiblity.
  37209. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37210. */
  37211. gamepadRotationSensibility: number;
  37212. /**
  37213. * Defines the gamepad move sensiblity.
  37214. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37215. */
  37216. gamepadMoveSensibility: number;
  37217. private _onGamepadConnectedObserver;
  37218. private _onGamepadDisconnectedObserver;
  37219. /**
  37220. * Attach the input controls to a specific dom element to get the input from.
  37221. * @param element Defines the element the controls should be listened from
  37222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37223. */
  37224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37225. /**
  37226. * Detach the current controls from the specified dom element.
  37227. * @param element Defines the element to stop listening the inputs from
  37228. */
  37229. detachControl(element: Nullable<HTMLElement>): void;
  37230. /**
  37231. * Update the current camera state depending on the inputs that have been used this frame.
  37232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37233. */
  37234. checkInputs(): void;
  37235. /**
  37236. * Gets the class name of the current intput.
  37237. * @returns the class name
  37238. */
  37239. getClassName(): string;
  37240. /**
  37241. * Get the friendly name associated with the input class.
  37242. * @returns the input friendly name
  37243. */
  37244. getSimpleName(): string;
  37245. }
  37246. }
  37247. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37248. import { Nullable } from "babylonjs/types";
  37249. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37250. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37251. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37252. interface ArcRotateCameraInputsManager {
  37253. /**
  37254. * Add orientation input support to the input manager.
  37255. * @returns the current input manager
  37256. */
  37257. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37258. }
  37259. }
  37260. /**
  37261. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37263. */
  37264. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37265. /**
  37266. * Defines the camera the input is attached to.
  37267. */
  37268. camera: ArcRotateCamera;
  37269. /**
  37270. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37271. */
  37272. alphaCorrection: number;
  37273. /**
  37274. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37275. */
  37276. gammaCorrection: number;
  37277. private _alpha;
  37278. private _gamma;
  37279. private _dirty;
  37280. private _deviceOrientationHandler;
  37281. /**
  37282. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37283. */
  37284. constructor();
  37285. /**
  37286. * Attach the input controls to a specific dom element to get the input from.
  37287. * @param element Defines the element the controls should be listened from
  37288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37289. */
  37290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37291. /** @hidden */
  37292. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37293. /**
  37294. * Update the current camera state depending on the inputs that have been used this frame.
  37295. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37296. */
  37297. checkInputs(): void;
  37298. /**
  37299. * Detach the current controls from the specified dom element.
  37300. * @param element Defines the element to stop listening the inputs from
  37301. */
  37302. detachControl(element: Nullable<HTMLElement>): void;
  37303. /**
  37304. * Gets the class name of the current intput.
  37305. * @returns the class name
  37306. */
  37307. getClassName(): string;
  37308. /**
  37309. * Get the friendly name associated with the input class.
  37310. * @returns the input friendly name
  37311. */
  37312. getSimpleName(): string;
  37313. }
  37314. }
  37315. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37316. import { Nullable } from "babylonjs/types";
  37317. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37318. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37319. /**
  37320. * Listen to mouse events to control the camera.
  37321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37322. */
  37323. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37324. /**
  37325. * Defines the camera the input is attached to.
  37326. */
  37327. camera: FlyCamera;
  37328. /**
  37329. * Defines if touch is enabled. (Default is true.)
  37330. */
  37331. touchEnabled: boolean;
  37332. /**
  37333. * Defines the buttons associated with the input to handle camera rotation.
  37334. */
  37335. buttons: number[];
  37336. /**
  37337. * Assign buttons for Yaw control.
  37338. */
  37339. buttonsYaw: number[];
  37340. /**
  37341. * Assign buttons for Pitch control.
  37342. */
  37343. buttonsPitch: number[];
  37344. /**
  37345. * Assign buttons for Roll control.
  37346. */
  37347. buttonsRoll: number[];
  37348. /**
  37349. * Detect if any button is being pressed while mouse is moved.
  37350. * -1 = Mouse locked.
  37351. * 0 = Left button.
  37352. * 1 = Middle Button.
  37353. * 2 = Right Button.
  37354. */
  37355. activeButton: number;
  37356. /**
  37357. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37358. * Higher values reduce its sensitivity.
  37359. */
  37360. angularSensibility: number;
  37361. private _mousemoveCallback;
  37362. private _observer;
  37363. private _rollObserver;
  37364. private previousPosition;
  37365. private noPreventDefault;
  37366. private element;
  37367. /**
  37368. * Listen to mouse events to control the camera.
  37369. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37371. */
  37372. constructor(touchEnabled?: boolean);
  37373. /**
  37374. * Attach the mouse control to the HTML DOM element.
  37375. * @param element Defines the element that listens to the input events.
  37376. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37377. */
  37378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37379. /**
  37380. * Detach the current controls from the specified dom element.
  37381. * @param element Defines the element to stop listening the inputs from
  37382. */
  37383. detachControl(element: Nullable<HTMLElement>): void;
  37384. /**
  37385. * Gets the class name of the current input.
  37386. * @returns the class name.
  37387. */
  37388. getClassName(): string;
  37389. /**
  37390. * Get the friendly name associated with the input class.
  37391. * @returns the input's friendly name.
  37392. */
  37393. getSimpleName(): string;
  37394. private _pointerInput;
  37395. private _onMouseMove;
  37396. /**
  37397. * Rotate camera by mouse offset.
  37398. */
  37399. private rotateCamera;
  37400. }
  37401. }
  37402. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37403. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37404. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37405. /**
  37406. * Default Inputs manager for the FlyCamera.
  37407. * It groups all the default supported inputs for ease of use.
  37408. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37409. */
  37410. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37411. /**
  37412. * Instantiates a new FlyCameraInputsManager.
  37413. * @param camera Defines the camera the inputs belong to.
  37414. */
  37415. constructor(camera: FlyCamera);
  37416. /**
  37417. * Add keyboard input support to the input manager.
  37418. * @returns the new FlyCameraKeyboardMoveInput().
  37419. */
  37420. addKeyboard(): FlyCameraInputsManager;
  37421. /**
  37422. * Add mouse input support to the input manager.
  37423. * @param touchEnabled Enable touch screen support.
  37424. * @returns the new FlyCameraMouseInput().
  37425. */
  37426. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37427. }
  37428. }
  37429. declare module "babylonjs/Cameras/flyCamera" {
  37430. import { Scene } from "babylonjs/scene";
  37431. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37433. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37434. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37435. /**
  37436. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37437. * such as in a 3D Space Shooter or a Flight Simulator.
  37438. */
  37439. export class FlyCamera extends TargetCamera {
  37440. /**
  37441. * Define the collision ellipsoid of the camera.
  37442. * This is helpful for simulating a camera body, like a player's body.
  37443. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37444. */
  37445. ellipsoid: Vector3;
  37446. /**
  37447. * Define an offset for the position of the ellipsoid around the camera.
  37448. * This can be helpful if the camera is attached away from the player's body center,
  37449. * such as at its head.
  37450. */
  37451. ellipsoidOffset: Vector3;
  37452. /**
  37453. * Enable or disable collisions of the camera with the rest of the scene objects.
  37454. */
  37455. checkCollisions: boolean;
  37456. /**
  37457. * Enable or disable gravity on the camera.
  37458. */
  37459. applyGravity: boolean;
  37460. /**
  37461. * Define the current direction the camera is moving to.
  37462. */
  37463. cameraDirection: Vector3;
  37464. /**
  37465. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37466. * This overrides and empties cameraRotation.
  37467. */
  37468. rotationQuaternion: Quaternion;
  37469. /**
  37470. * Track Roll to maintain the wanted Rolling when looking around.
  37471. */
  37472. _trackRoll: number;
  37473. /**
  37474. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37475. */
  37476. rollCorrect: number;
  37477. /**
  37478. * Mimic a banked turn, Rolling the camera when Yawing.
  37479. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37480. */
  37481. bankedTurn: boolean;
  37482. /**
  37483. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37484. */
  37485. bankedTurnLimit: number;
  37486. /**
  37487. * Value of 0 disables the banked Roll.
  37488. * Value of 1 is equal to the Yaw angle in radians.
  37489. */
  37490. bankedTurnMultiplier: number;
  37491. /**
  37492. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37493. */
  37494. inputs: FlyCameraInputsManager;
  37495. /**
  37496. * Gets the input sensibility for mouse input.
  37497. * Higher values reduce sensitivity.
  37498. */
  37499. /**
  37500. * Sets the input sensibility for a mouse input.
  37501. * Higher values reduce sensitivity.
  37502. */
  37503. angularSensibility: number;
  37504. /**
  37505. * Get the keys for camera movement forward.
  37506. */
  37507. /**
  37508. * Set the keys for camera movement forward.
  37509. */
  37510. keysForward: number[];
  37511. /**
  37512. * Get the keys for camera movement backward.
  37513. */
  37514. keysBackward: number[];
  37515. /**
  37516. * Get the keys for camera movement up.
  37517. */
  37518. /**
  37519. * Set the keys for camera movement up.
  37520. */
  37521. keysUp: number[];
  37522. /**
  37523. * Get the keys for camera movement down.
  37524. */
  37525. /**
  37526. * Set the keys for camera movement down.
  37527. */
  37528. keysDown: number[];
  37529. /**
  37530. * Get the keys for camera movement left.
  37531. */
  37532. /**
  37533. * Set the keys for camera movement left.
  37534. */
  37535. keysLeft: number[];
  37536. /**
  37537. * Set the keys for camera movement right.
  37538. */
  37539. /**
  37540. * Set the keys for camera movement right.
  37541. */
  37542. keysRight: number[];
  37543. /**
  37544. * Event raised when the camera collides with a mesh in the scene.
  37545. */
  37546. onCollide: (collidedMesh: AbstractMesh) => void;
  37547. private _collider;
  37548. private _needMoveForGravity;
  37549. private _oldPosition;
  37550. private _diffPosition;
  37551. private _newPosition;
  37552. /** @hidden */
  37553. _localDirection: Vector3;
  37554. /** @hidden */
  37555. _transformedDirection: Vector3;
  37556. /**
  37557. * Instantiates a FlyCamera.
  37558. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37559. * such as in a 3D Space Shooter or a Flight Simulator.
  37560. * @param name Define the name of the camera in the scene.
  37561. * @param position Define the starting position of the camera in the scene.
  37562. * @param scene Define the scene the camera belongs to.
  37563. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37564. */
  37565. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37566. /**
  37567. * Attach a control to the HTML DOM element.
  37568. * @param element Defines the element that listens to the input events.
  37569. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37570. */
  37571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37572. /**
  37573. * Detach a control from the HTML DOM element.
  37574. * The camera will stop reacting to that input.
  37575. * @param element Defines the element that listens to the input events.
  37576. */
  37577. detachControl(element: HTMLElement): void;
  37578. private _collisionMask;
  37579. /**
  37580. * Get the mask that the camera ignores in collision events.
  37581. */
  37582. /**
  37583. * Set the mask that the camera ignores in collision events.
  37584. */
  37585. collisionMask: number;
  37586. /** @hidden */
  37587. _collideWithWorld(displacement: Vector3): void;
  37588. /** @hidden */
  37589. private _onCollisionPositionChange;
  37590. /** @hidden */
  37591. _checkInputs(): void;
  37592. /** @hidden */
  37593. _decideIfNeedsToMove(): boolean;
  37594. /** @hidden */
  37595. _updatePosition(): void;
  37596. /**
  37597. * Restore the Roll to its target value at the rate specified.
  37598. * @param rate - Higher means slower restoring.
  37599. * @hidden
  37600. */
  37601. restoreRoll(rate: number): void;
  37602. /**
  37603. * Destroy the camera and release the current resources held by it.
  37604. */
  37605. dispose(): void;
  37606. /**
  37607. * Get the current object class name.
  37608. * @returns the class name.
  37609. */
  37610. getClassName(): string;
  37611. }
  37612. }
  37613. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37614. import { Nullable } from "babylonjs/types";
  37615. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37616. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37617. /**
  37618. * Listen to keyboard events to control the camera.
  37619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37620. */
  37621. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37622. /**
  37623. * Defines the camera the input is attached to.
  37624. */
  37625. camera: FlyCamera;
  37626. /**
  37627. * The list of keyboard keys used to control the forward move of the camera.
  37628. */
  37629. keysForward: number[];
  37630. /**
  37631. * The list of keyboard keys used to control the backward move of the camera.
  37632. */
  37633. keysBackward: number[];
  37634. /**
  37635. * The list of keyboard keys used to control the forward move of the camera.
  37636. */
  37637. keysUp: number[];
  37638. /**
  37639. * The list of keyboard keys used to control the backward move of the camera.
  37640. */
  37641. keysDown: number[];
  37642. /**
  37643. * The list of keyboard keys used to control the right strafe move of the camera.
  37644. */
  37645. keysRight: number[];
  37646. /**
  37647. * The list of keyboard keys used to control the left strafe move of the camera.
  37648. */
  37649. keysLeft: number[];
  37650. private _keys;
  37651. private _onCanvasBlurObserver;
  37652. private _onKeyboardObserver;
  37653. private _engine;
  37654. private _scene;
  37655. /**
  37656. * Attach the input controls to a specific dom element to get the input from.
  37657. * @param element Defines the element the controls should be listened from
  37658. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37659. */
  37660. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37661. /**
  37662. * Detach the current controls from the specified dom element.
  37663. * @param element Defines the element to stop listening the inputs from
  37664. */
  37665. detachControl(element: Nullable<HTMLElement>): void;
  37666. /**
  37667. * Gets the class name of the current intput.
  37668. * @returns the class name
  37669. */
  37670. getClassName(): string;
  37671. /** @hidden */
  37672. _onLostFocus(e: FocusEvent): void;
  37673. /**
  37674. * Get the friendly name associated with the input class.
  37675. * @returns the input friendly name
  37676. */
  37677. getSimpleName(): string;
  37678. /**
  37679. * Update the current camera state depending on the inputs that have been used this frame.
  37680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37681. */
  37682. checkInputs(): void;
  37683. }
  37684. }
  37685. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37686. import { Nullable } from "babylonjs/types";
  37687. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37688. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37689. /**
  37690. * Manage the mouse wheel inputs to control a follow camera.
  37691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37692. */
  37693. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37694. /**
  37695. * Defines the camera the input is attached to.
  37696. */
  37697. camera: FollowCamera;
  37698. /**
  37699. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37700. */
  37701. axisControlRadius: boolean;
  37702. /**
  37703. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37704. */
  37705. axisControlHeight: boolean;
  37706. /**
  37707. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37708. */
  37709. axisControlRotation: boolean;
  37710. /**
  37711. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37712. * relation to mouseWheel events.
  37713. */
  37714. wheelPrecision: number;
  37715. /**
  37716. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37717. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37718. */
  37719. wheelDeltaPercentage: number;
  37720. private _wheel;
  37721. private _observer;
  37722. /**
  37723. * Attach the input controls to a specific dom element to get the input from.
  37724. * @param element Defines the element the controls should be listened from
  37725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37726. */
  37727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37728. /**
  37729. * Detach the current controls from the specified dom element.
  37730. * @param element Defines the element to stop listening the inputs from
  37731. */
  37732. detachControl(element: Nullable<HTMLElement>): void;
  37733. /**
  37734. * Gets the class name of the current intput.
  37735. * @returns the class name
  37736. */
  37737. getClassName(): string;
  37738. /**
  37739. * Get the friendly name associated with the input class.
  37740. * @returns the input friendly name
  37741. */
  37742. getSimpleName(): string;
  37743. }
  37744. }
  37745. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37746. import { Nullable } from "babylonjs/types";
  37747. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37748. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37749. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37750. /**
  37751. * Manage the pointers inputs to control an follow camera.
  37752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37753. */
  37754. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37755. /**
  37756. * Defines the camera the input is attached to.
  37757. */
  37758. camera: FollowCamera;
  37759. /**
  37760. * Gets the class name of the current input.
  37761. * @returns the class name
  37762. */
  37763. getClassName(): string;
  37764. /**
  37765. * Defines the pointer angular sensibility along the X axis or how fast is
  37766. * the camera rotating.
  37767. * A negative number will reverse the axis direction.
  37768. */
  37769. angularSensibilityX: number;
  37770. /**
  37771. * Defines the pointer angular sensibility along the Y axis or how fast is
  37772. * the camera rotating.
  37773. * A negative number will reverse the axis direction.
  37774. */
  37775. angularSensibilityY: number;
  37776. /**
  37777. * Defines the pointer pinch precision or how fast is the camera zooming.
  37778. * A negative number will reverse the axis direction.
  37779. */
  37780. pinchPrecision: number;
  37781. /**
  37782. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37783. * from 0.
  37784. * It defines the percentage of current camera.radius to use as delta when
  37785. * pinch zoom is used.
  37786. */
  37787. pinchDeltaPercentage: number;
  37788. /**
  37789. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37790. */
  37791. axisXControlRadius: boolean;
  37792. /**
  37793. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37794. */
  37795. axisXControlHeight: boolean;
  37796. /**
  37797. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37798. */
  37799. axisXControlRotation: boolean;
  37800. /**
  37801. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37802. */
  37803. axisYControlRadius: boolean;
  37804. /**
  37805. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37806. */
  37807. axisYControlHeight: boolean;
  37808. /**
  37809. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37810. */
  37811. axisYControlRotation: boolean;
  37812. /**
  37813. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37814. */
  37815. axisPinchControlRadius: boolean;
  37816. /**
  37817. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37818. */
  37819. axisPinchControlHeight: boolean;
  37820. /**
  37821. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37822. */
  37823. axisPinchControlRotation: boolean;
  37824. /**
  37825. * Log error messages if basic misconfiguration has occurred.
  37826. */
  37827. warningEnable: boolean;
  37828. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37829. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37830. private _warningCounter;
  37831. private _warning;
  37832. }
  37833. }
  37834. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37835. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37836. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37837. /**
  37838. * Default Inputs manager for the FollowCamera.
  37839. * It groups all the default supported inputs for ease of use.
  37840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37841. */
  37842. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37843. /**
  37844. * Instantiates a new FollowCameraInputsManager.
  37845. * @param camera Defines the camera the inputs belong to
  37846. */
  37847. constructor(camera: FollowCamera);
  37848. /**
  37849. * Add keyboard input support to the input manager.
  37850. * @returns the current input manager
  37851. */
  37852. addKeyboard(): FollowCameraInputsManager;
  37853. /**
  37854. * Add mouse wheel input support to the input manager.
  37855. * @returns the current input manager
  37856. */
  37857. addMouseWheel(): FollowCameraInputsManager;
  37858. /**
  37859. * Add pointers input support to the input manager.
  37860. * @returns the current input manager
  37861. */
  37862. addPointers(): FollowCameraInputsManager;
  37863. /**
  37864. * Add orientation input support to the input manager.
  37865. * @returns the current input manager
  37866. */
  37867. addVRDeviceOrientation(): FollowCameraInputsManager;
  37868. }
  37869. }
  37870. declare module "babylonjs/Cameras/followCamera" {
  37871. import { Nullable } from "babylonjs/types";
  37872. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37873. import { Scene } from "babylonjs/scene";
  37874. import { Vector3 } from "babylonjs/Maths/math";
  37875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37876. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37877. /**
  37878. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37879. * an arc rotate version arcFollowCamera are available.
  37880. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37881. */
  37882. export class FollowCamera extends TargetCamera {
  37883. /**
  37884. * Distance the follow camera should follow an object at
  37885. */
  37886. radius: number;
  37887. /**
  37888. * Minimum allowed distance of the camera to the axis of rotation
  37889. * (The camera can not get closer).
  37890. * This can help limiting how the Camera is able to move in the scene.
  37891. */
  37892. lowerRadiusLimit: Nullable<number>;
  37893. /**
  37894. * Maximum allowed distance of the camera to the axis of rotation
  37895. * (The camera can not get further).
  37896. * This can help limiting how the Camera is able to move in the scene.
  37897. */
  37898. upperRadiusLimit: Nullable<number>;
  37899. /**
  37900. * Define a rotation offset between the camera and the object it follows
  37901. */
  37902. rotationOffset: number;
  37903. /**
  37904. * Minimum allowed angle to camera position relative to target object.
  37905. * This can help limiting how the Camera is able to move in the scene.
  37906. */
  37907. lowerRotationOffsetLimit: Nullable<number>;
  37908. /**
  37909. * Maximum allowed angle to camera position relative to target object.
  37910. * This can help limiting how the Camera is able to move in the scene.
  37911. */
  37912. upperRotationOffsetLimit: Nullable<number>;
  37913. /**
  37914. * Define a height offset between the camera and the object it follows.
  37915. * It can help following an object from the top (like a car chaing a plane)
  37916. */
  37917. heightOffset: number;
  37918. /**
  37919. * Minimum allowed height of camera position relative to target object.
  37920. * This can help limiting how the Camera is able to move in the scene.
  37921. */
  37922. lowerHeightOffsetLimit: Nullable<number>;
  37923. /**
  37924. * Maximum allowed height of camera position relative to target object.
  37925. * This can help limiting how the Camera is able to move in the scene.
  37926. */
  37927. upperHeightOffsetLimit: Nullable<number>;
  37928. /**
  37929. * Define how fast the camera can accelerate to follow it s target.
  37930. */
  37931. cameraAcceleration: number;
  37932. /**
  37933. * Define the speed limit of the camera following an object.
  37934. */
  37935. maxCameraSpeed: number;
  37936. /**
  37937. * Define the target of the camera.
  37938. */
  37939. lockedTarget: Nullable<AbstractMesh>;
  37940. /**
  37941. * Defines the input associated with the camera.
  37942. */
  37943. inputs: FollowCameraInputsManager;
  37944. /**
  37945. * Instantiates the follow camera.
  37946. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37947. * @param name Define the name of the camera in the scene
  37948. * @param position Define the position of the camera
  37949. * @param scene Define the scene the camera belong to
  37950. * @param lockedTarget Define the target of the camera
  37951. */
  37952. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37953. private _follow;
  37954. /**
  37955. * Attached controls to the current camera.
  37956. * @param element Defines the element the controls should be listened from
  37957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37958. */
  37959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37960. /**
  37961. * Detach the current controls from the camera.
  37962. * The camera will stop reacting to inputs.
  37963. * @param element Defines the element to stop listening the inputs from
  37964. */
  37965. detachControl(element: HTMLElement): void;
  37966. /** @hidden */
  37967. _checkInputs(): void;
  37968. private _checkLimits;
  37969. /**
  37970. * Gets the camera class name.
  37971. * @returns the class name
  37972. */
  37973. getClassName(): string;
  37974. }
  37975. /**
  37976. * Arc Rotate version of the follow camera.
  37977. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37978. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37979. */
  37980. export class ArcFollowCamera extends TargetCamera {
  37981. /** The longitudinal angle of the camera */
  37982. alpha: number;
  37983. /** The latitudinal angle of the camera */
  37984. beta: number;
  37985. /** The radius of the camera from its target */
  37986. radius: number;
  37987. /** Define the camera target (the messh it should follow) */
  37988. target: Nullable<AbstractMesh>;
  37989. private _cartesianCoordinates;
  37990. /**
  37991. * Instantiates a new ArcFollowCamera
  37992. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37993. * @param name Define the name of the camera
  37994. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37995. * @param beta Define the rotation angle of the camera around the elevation axis
  37996. * @param radius Define the radius of the camera from its target point
  37997. * @param target Define the target of the camera
  37998. * @param scene Define the scene the camera belongs to
  37999. */
  38000. constructor(name: string,
  38001. /** The longitudinal angle of the camera */
  38002. alpha: number,
  38003. /** The latitudinal angle of the camera */
  38004. beta: number,
  38005. /** The radius of the camera from its target */
  38006. radius: number,
  38007. /** Define the camera target (the messh it should follow) */
  38008. target: Nullable<AbstractMesh>, scene: Scene);
  38009. private _follow;
  38010. /** @hidden */
  38011. _checkInputs(): void;
  38012. /**
  38013. * Returns the class name of the object.
  38014. * It is mostly used internally for serialization purposes.
  38015. */
  38016. getClassName(): string;
  38017. }
  38018. }
  38019. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38020. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38021. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38022. import { Nullable } from "babylonjs/types";
  38023. /**
  38024. * Manage the keyboard inputs to control the movement of a follow camera.
  38025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38026. */
  38027. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38028. /**
  38029. * Defines the camera the input is attached to.
  38030. */
  38031. camera: FollowCamera;
  38032. /**
  38033. * Defines the list of key codes associated with the up action (increase heightOffset)
  38034. */
  38035. keysHeightOffsetIncr: number[];
  38036. /**
  38037. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38038. */
  38039. keysHeightOffsetDecr: number[];
  38040. /**
  38041. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38042. */
  38043. keysHeightOffsetModifierAlt: boolean;
  38044. /**
  38045. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38046. */
  38047. keysHeightOffsetModifierCtrl: boolean;
  38048. /**
  38049. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38050. */
  38051. keysHeightOffsetModifierShift: boolean;
  38052. /**
  38053. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38054. */
  38055. keysRotationOffsetIncr: number[];
  38056. /**
  38057. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38058. */
  38059. keysRotationOffsetDecr: number[];
  38060. /**
  38061. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38062. */
  38063. keysRotationOffsetModifierAlt: boolean;
  38064. /**
  38065. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38066. */
  38067. keysRotationOffsetModifierCtrl: boolean;
  38068. /**
  38069. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38070. */
  38071. keysRotationOffsetModifierShift: boolean;
  38072. /**
  38073. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38074. */
  38075. keysRadiusIncr: number[];
  38076. /**
  38077. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38078. */
  38079. keysRadiusDecr: number[];
  38080. /**
  38081. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38082. */
  38083. keysRadiusModifierAlt: boolean;
  38084. /**
  38085. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38086. */
  38087. keysRadiusModifierCtrl: boolean;
  38088. /**
  38089. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38090. */
  38091. keysRadiusModifierShift: boolean;
  38092. /**
  38093. * Defines the rate of change of heightOffset.
  38094. */
  38095. heightSensibility: number;
  38096. /**
  38097. * Defines the rate of change of rotationOffset.
  38098. */
  38099. rotationSensibility: number;
  38100. /**
  38101. * Defines the rate of change of radius.
  38102. */
  38103. radiusSensibility: number;
  38104. private _keys;
  38105. private _ctrlPressed;
  38106. private _altPressed;
  38107. private _shiftPressed;
  38108. private _onCanvasBlurObserver;
  38109. private _onKeyboardObserver;
  38110. private _engine;
  38111. private _scene;
  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. /**
  38119. * Detach the current controls from the specified dom element.
  38120. * @param element Defines the element to stop listening the inputs from
  38121. */
  38122. detachControl(element: Nullable<HTMLElement>): void;
  38123. /**
  38124. * Update the current camera state depending on the inputs that have been used this frame.
  38125. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38126. */
  38127. checkInputs(): void;
  38128. /**
  38129. * Gets the class name of the current input.
  38130. * @returns the class name
  38131. */
  38132. getClassName(): string;
  38133. /**
  38134. * Get the friendly name associated with the input class.
  38135. * @returns the input friendly name
  38136. */
  38137. getSimpleName(): string;
  38138. /**
  38139. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38140. * allow modification of the heightOffset value.
  38141. */
  38142. private _modifierHeightOffset;
  38143. /**
  38144. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38145. * allow modification of the rotationOffset value.
  38146. */
  38147. private _modifierRotationOffset;
  38148. /**
  38149. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38150. * allow modification of the radius value.
  38151. */
  38152. private _modifierRadius;
  38153. }
  38154. }
  38155. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38156. import { Nullable } from "babylonjs/types";
  38157. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38158. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38159. import { Observable } from "babylonjs/Misc/observable";
  38160. module "babylonjs/Cameras/freeCameraInputsManager" {
  38161. interface FreeCameraInputsManager {
  38162. /**
  38163. * @hidden
  38164. */
  38165. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38166. /**
  38167. * Add orientation input support to the input manager.
  38168. * @returns the current input manager
  38169. */
  38170. addDeviceOrientation(): FreeCameraInputsManager;
  38171. }
  38172. }
  38173. /**
  38174. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38175. * Screen rotation is taken into account.
  38176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38177. */
  38178. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38179. private _camera;
  38180. private _screenOrientationAngle;
  38181. private _constantTranform;
  38182. private _screenQuaternion;
  38183. private _alpha;
  38184. private _beta;
  38185. private _gamma;
  38186. /**
  38187. * @hidden
  38188. */
  38189. _onDeviceOrientationChangedObservable: Observable<void>;
  38190. /**
  38191. * Instantiates a new input
  38192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38193. */
  38194. constructor();
  38195. /**
  38196. * Define the camera controlled by the input.
  38197. */
  38198. camera: FreeCamera;
  38199. /**
  38200. * Attach the input controls to a specific dom element to get the input from.
  38201. * @param element Defines the element the controls should be listened from
  38202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38203. */
  38204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38205. private _orientationChanged;
  38206. private _deviceOrientation;
  38207. /**
  38208. * Detach the current controls from the specified dom element.
  38209. * @param element Defines the element to stop listening the inputs from
  38210. */
  38211. detachControl(element: Nullable<HTMLElement>): void;
  38212. /**
  38213. * Update the current camera state depending on the inputs that have been used this frame.
  38214. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38215. */
  38216. checkInputs(): void;
  38217. /**
  38218. * Gets the class name of the current intput.
  38219. * @returns the class name
  38220. */
  38221. getClassName(): string;
  38222. /**
  38223. * Get the friendly name associated with the input class.
  38224. * @returns the input friendly name
  38225. */
  38226. getSimpleName(): string;
  38227. }
  38228. }
  38229. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38230. import { Nullable } from "babylonjs/types";
  38231. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38232. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38233. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38234. /**
  38235. * Manage the gamepad inputs to control a free camera.
  38236. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38237. */
  38238. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38239. /**
  38240. * Define the camera the input is attached to.
  38241. */
  38242. camera: FreeCamera;
  38243. /**
  38244. * Define the Gamepad controlling the input
  38245. */
  38246. gamepad: Nullable<Gamepad>;
  38247. /**
  38248. * Defines the gamepad rotation sensiblity.
  38249. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38250. */
  38251. gamepadAngularSensibility: number;
  38252. /**
  38253. * Defines the gamepad move sensiblity.
  38254. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38255. */
  38256. gamepadMoveSensibility: number;
  38257. private _onGamepadConnectedObserver;
  38258. private _onGamepadDisconnectedObserver;
  38259. private _cameraTransform;
  38260. private _deltaTransform;
  38261. private _vector3;
  38262. private _vector2;
  38263. /**
  38264. * Attach the input controls to a specific dom element to get the input from.
  38265. * @param element Defines the element the controls should be listened from
  38266. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38267. */
  38268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38269. /**
  38270. * Detach the current controls from the specified dom element.
  38271. * @param element Defines the element to stop listening the inputs from
  38272. */
  38273. detachControl(element: Nullable<HTMLElement>): void;
  38274. /**
  38275. * Update the current camera state depending on the inputs that have been used this frame.
  38276. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38277. */
  38278. checkInputs(): void;
  38279. /**
  38280. * Gets the class name of the current intput.
  38281. * @returns the class name
  38282. */
  38283. getClassName(): string;
  38284. /**
  38285. * Get the friendly name associated with the input class.
  38286. * @returns the input friendly name
  38287. */
  38288. getSimpleName(): string;
  38289. }
  38290. }
  38291. declare module "babylonjs/Misc/virtualJoystick" {
  38292. import { Nullable } from "babylonjs/types";
  38293. import { Vector3 } from "babylonjs/Maths/math";
  38294. /**
  38295. * Defines the potential axis of a Joystick
  38296. */
  38297. export enum JoystickAxis {
  38298. /** X axis */
  38299. X = 0,
  38300. /** Y axis */
  38301. Y = 1,
  38302. /** Z axis */
  38303. Z = 2
  38304. }
  38305. /**
  38306. * Class used to define virtual joystick (used in touch mode)
  38307. */
  38308. export class VirtualJoystick {
  38309. /**
  38310. * Gets or sets a boolean indicating that left and right values must be inverted
  38311. */
  38312. reverseLeftRight: boolean;
  38313. /**
  38314. * Gets or sets a boolean indicating that up and down values must be inverted
  38315. */
  38316. reverseUpDown: boolean;
  38317. /**
  38318. * Gets the offset value for the position (ie. the change of the position value)
  38319. */
  38320. deltaPosition: Vector3;
  38321. /**
  38322. * Gets a boolean indicating if the virtual joystick was pressed
  38323. */
  38324. pressed: boolean;
  38325. /**
  38326. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38327. */
  38328. static Canvas: Nullable<HTMLCanvasElement>;
  38329. private static _globalJoystickIndex;
  38330. private static vjCanvasContext;
  38331. private static vjCanvasWidth;
  38332. private static vjCanvasHeight;
  38333. private static halfWidth;
  38334. private _action;
  38335. private _axisTargetedByLeftAndRight;
  38336. private _axisTargetedByUpAndDown;
  38337. private _joystickSensibility;
  38338. private _inversedSensibility;
  38339. private _joystickPointerID;
  38340. private _joystickColor;
  38341. private _joystickPointerPos;
  38342. private _joystickPreviousPointerPos;
  38343. private _joystickPointerStartPos;
  38344. private _deltaJoystickVector;
  38345. private _leftJoystick;
  38346. private _touches;
  38347. private _onPointerDownHandlerRef;
  38348. private _onPointerMoveHandlerRef;
  38349. private _onPointerUpHandlerRef;
  38350. private _onResize;
  38351. /**
  38352. * Creates a new virtual joystick
  38353. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38354. */
  38355. constructor(leftJoystick?: boolean);
  38356. /**
  38357. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38358. * @param newJoystickSensibility defines the new sensibility
  38359. */
  38360. setJoystickSensibility(newJoystickSensibility: number): void;
  38361. private _onPointerDown;
  38362. private _onPointerMove;
  38363. private _onPointerUp;
  38364. /**
  38365. * Change the color of the virtual joystick
  38366. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38367. */
  38368. setJoystickColor(newColor: string): void;
  38369. /**
  38370. * Defines a callback to call when the joystick is touched
  38371. * @param action defines the callback
  38372. */
  38373. setActionOnTouch(action: () => any): void;
  38374. /**
  38375. * Defines which axis you'd like to control for left & right
  38376. * @param axis defines the axis to use
  38377. */
  38378. setAxisForLeftRight(axis: JoystickAxis): void;
  38379. /**
  38380. * Defines which axis you'd like to control for up & down
  38381. * @param axis defines the axis to use
  38382. */
  38383. setAxisForUpDown(axis: JoystickAxis): void;
  38384. private _drawVirtualJoystick;
  38385. /**
  38386. * Release internal HTML canvas
  38387. */
  38388. releaseCanvas(): void;
  38389. }
  38390. }
  38391. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38392. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38393. import { Nullable } from "babylonjs/types";
  38394. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38395. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38396. module "babylonjs/Cameras/freeCameraInputsManager" {
  38397. interface FreeCameraInputsManager {
  38398. /**
  38399. * Add virtual joystick input support to the input manager.
  38400. * @returns the current input manager
  38401. */
  38402. addVirtualJoystick(): FreeCameraInputsManager;
  38403. }
  38404. }
  38405. /**
  38406. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38407. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38408. */
  38409. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38410. /**
  38411. * Defines the camera the input is attached to.
  38412. */
  38413. camera: FreeCamera;
  38414. private _leftjoystick;
  38415. private _rightjoystick;
  38416. /**
  38417. * Gets the left stick of the virtual joystick.
  38418. * @returns The virtual Joystick
  38419. */
  38420. getLeftJoystick(): VirtualJoystick;
  38421. /**
  38422. * Gets the right stick of the virtual joystick.
  38423. * @returns The virtual Joystick
  38424. */
  38425. getRightJoystick(): VirtualJoystick;
  38426. /**
  38427. * Update the current camera state depending on the inputs that have been used this frame.
  38428. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38429. */
  38430. checkInputs(): void;
  38431. /**
  38432. * Attach the input controls to a specific dom element to get the input from.
  38433. * @param element Defines the element the controls should be listened from
  38434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38435. */
  38436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38437. /**
  38438. * Detach the current controls from the specified dom element.
  38439. * @param element Defines the element to stop listening the inputs from
  38440. */
  38441. detachControl(element: Nullable<HTMLElement>): void;
  38442. /**
  38443. * Gets the class name of the current intput.
  38444. * @returns the class name
  38445. */
  38446. getClassName(): string;
  38447. /**
  38448. * Get the friendly name associated with the input class.
  38449. * @returns the input friendly name
  38450. */
  38451. getSimpleName(): string;
  38452. }
  38453. }
  38454. declare module "babylonjs/Cameras/Inputs/index" {
  38455. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38456. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38457. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38458. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38459. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38460. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38461. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38462. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38463. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38464. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38465. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38466. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38467. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38468. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38469. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38470. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38471. }
  38472. declare module "babylonjs/Cameras/touchCamera" {
  38473. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38474. import { Scene } from "babylonjs/scene";
  38475. import { Vector3 } from "babylonjs/Maths/math";
  38476. /**
  38477. * This represents a FPS type of camera controlled by touch.
  38478. * This is like a universal camera minus the Gamepad controls.
  38479. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38480. */
  38481. export class TouchCamera extends FreeCamera {
  38482. /**
  38483. * Defines the touch sensibility for rotation.
  38484. * The higher the faster.
  38485. */
  38486. touchAngularSensibility: number;
  38487. /**
  38488. * Defines the touch sensibility for move.
  38489. * The higher the faster.
  38490. */
  38491. touchMoveSensibility: number;
  38492. /**
  38493. * Instantiates a new touch camera.
  38494. * This represents a FPS type of camera controlled by touch.
  38495. * This is like a universal camera minus the Gamepad controls.
  38496. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38497. * @param name Define the name of the camera in the scene
  38498. * @param position Define the start position of the camera in the scene
  38499. * @param scene Define the scene the camera belongs to
  38500. */
  38501. constructor(name: string, position: Vector3, scene: Scene);
  38502. /**
  38503. * Gets the current object class name.
  38504. * @return the class name
  38505. */
  38506. getClassName(): string;
  38507. /** @hidden */
  38508. _setupInputs(): void;
  38509. }
  38510. }
  38511. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38512. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38513. import { Scene } from "babylonjs/scene";
  38514. import { Vector3, Axis } from "babylonjs/Maths/math";
  38515. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38516. /**
  38517. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38518. * being tilted forward or back and left or right.
  38519. */
  38520. export class DeviceOrientationCamera extends FreeCamera {
  38521. private _initialQuaternion;
  38522. private _quaternionCache;
  38523. private _tmpDragQuaternion;
  38524. /**
  38525. * Creates a new device orientation camera
  38526. * @param name The name of the camera
  38527. * @param position The start position camera
  38528. * @param scene The scene the camera belongs to
  38529. */
  38530. constructor(name: string, position: Vector3, scene: Scene);
  38531. /**
  38532. * @hidden
  38533. * Disabled pointer input on first orientation sensor update (Default: true)
  38534. */
  38535. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38536. private _dragFactor;
  38537. /**
  38538. * Enabled turning on the y axis when the orientation sensor is active
  38539. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38540. */
  38541. enableHorizontalDragging(dragFactor?: number): void;
  38542. /**
  38543. * Gets the current instance class name ("DeviceOrientationCamera").
  38544. * This helps avoiding instanceof at run time.
  38545. * @returns the class name
  38546. */
  38547. getClassName(): string;
  38548. /**
  38549. * @hidden
  38550. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38551. */
  38552. _checkInputs(): void;
  38553. /**
  38554. * Reset the camera to its default orientation on the specified axis only.
  38555. * @param axis The axis to reset
  38556. */
  38557. resetToCurrentRotation(axis?: Axis): void;
  38558. }
  38559. }
  38560. declare module "babylonjs/Cameras/universalCamera" {
  38561. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38562. import { Scene } from "babylonjs/scene";
  38563. import { Vector3 } from "babylonjs/Maths/math";
  38564. /**
  38565. * 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,
  38566. * which still works and will still be found in many Playgrounds.
  38567. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38568. */
  38569. export class UniversalCamera extends TouchCamera {
  38570. /**
  38571. * Defines the gamepad rotation sensiblity.
  38572. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38573. */
  38574. gamepadAngularSensibility: number;
  38575. /**
  38576. * Defines the gamepad move sensiblity.
  38577. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38578. */
  38579. gamepadMoveSensibility: number;
  38580. /**
  38581. * 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,
  38582. * which still works and will still be found in many Playgrounds.
  38583. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38584. * @param name Define the name of the camera in the scene
  38585. * @param position Define the start position of the camera in the scene
  38586. * @param scene Define the scene the camera belongs to
  38587. */
  38588. constructor(name: string, position: Vector3, scene: Scene);
  38589. /**
  38590. * Gets the current object class name.
  38591. * @return the class name
  38592. */
  38593. getClassName(): string;
  38594. }
  38595. }
  38596. declare module "babylonjs/Cameras/gamepadCamera" {
  38597. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38598. import { Scene } from "babylonjs/scene";
  38599. import { Vector3 } from "babylonjs/Maths/math";
  38600. /**
  38601. * This represents a FPS type of camera. This is only here for back compat purpose.
  38602. * Please use the UniversalCamera instead as both are identical.
  38603. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38604. */
  38605. export class GamepadCamera extends UniversalCamera {
  38606. /**
  38607. * Instantiates a new Gamepad Camera
  38608. * This represents a FPS type of camera. This is only here for back compat purpose.
  38609. * Please use the UniversalCamera instead as both are identical.
  38610. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38611. * @param name Define the name of the camera in the scene
  38612. * @param position Define the start position of the camera in the scene
  38613. * @param scene Define the scene the camera belongs to
  38614. */
  38615. constructor(name: string, position: Vector3, scene: Scene);
  38616. /**
  38617. * Gets the current object class name.
  38618. * @return the class name
  38619. */
  38620. getClassName(): string;
  38621. }
  38622. }
  38623. declare module "babylonjs/Shaders/pass.fragment" {
  38624. /** @hidden */
  38625. export var passPixelShader: {
  38626. name: string;
  38627. shader: string;
  38628. };
  38629. }
  38630. declare module "babylonjs/Shaders/passCube.fragment" {
  38631. /** @hidden */
  38632. export var passCubePixelShader: {
  38633. name: string;
  38634. shader: string;
  38635. };
  38636. }
  38637. declare module "babylonjs/PostProcesses/passPostProcess" {
  38638. import { Nullable } from "babylonjs/types";
  38639. import { Camera } from "babylonjs/Cameras/camera";
  38640. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38641. import { Engine } from "babylonjs/Engines/engine";
  38642. import "babylonjs/Shaders/pass.fragment";
  38643. import "babylonjs/Shaders/passCube.fragment";
  38644. /**
  38645. * PassPostProcess which produces an output the same as it's input
  38646. */
  38647. export class PassPostProcess extends PostProcess {
  38648. /**
  38649. * Creates the PassPostProcess
  38650. * @param name The name of the effect.
  38651. * @param options The required width/height ratio to downsize to before computing the render pass.
  38652. * @param camera The camera to apply the render pass to.
  38653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38654. * @param engine The engine which the post process will be applied. (default: current engine)
  38655. * @param reusable If the post process can be reused on the same frame. (default: false)
  38656. * @param textureType The type of texture to be used when performing the post processing.
  38657. * @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)
  38658. */
  38659. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38660. }
  38661. /**
  38662. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38663. */
  38664. export class PassCubePostProcess extends PostProcess {
  38665. private _face;
  38666. /**
  38667. * Gets or sets the cube face to display.
  38668. * * 0 is +X
  38669. * * 1 is -X
  38670. * * 2 is +Y
  38671. * * 3 is -Y
  38672. * * 4 is +Z
  38673. * * 5 is -Z
  38674. */
  38675. face: number;
  38676. /**
  38677. * Creates the PassCubePostProcess
  38678. * @param name The name of the effect.
  38679. * @param options The required width/height ratio to downsize to before computing the render pass.
  38680. * @param camera The camera to apply the render pass to.
  38681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38682. * @param engine The engine which the post process will be applied. (default: current engine)
  38683. * @param reusable If the post process can be reused on the same frame. (default: false)
  38684. * @param textureType The type of texture to be used when performing the post processing.
  38685. * @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)
  38686. */
  38687. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38688. }
  38689. }
  38690. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38691. /** @hidden */
  38692. export var anaglyphPixelShader: {
  38693. name: string;
  38694. shader: string;
  38695. };
  38696. }
  38697. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38698. import { Engine } from "babylonjs/Engines/engine";
  38699. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38700. import { Camera } from "babylonjs/Cameras/camera";
  38701. import "babylonjs/Shaders/anaglyph.fragment";
  38702. /**
  38703. * Postprocess used to generate anaglyphic rendering
  38704. */
  38705. export class AnaglyphPostProcess extends PostProcess {
  38706. private _passedProcess;
  38707. /**
  38708. * Creates a new AnaglyphPostProcess
  38709. * @param name defines postprocess name
  38710. * @param options defines creation options or target ratio scale
  38711. * @param rigCameras defines cameras using this postprocess
  38712. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38713. * @param engine defines hosting engine
  38714. * @param reusable defines if the postprocess will be reused multiple times per frame
  38715. */
  38716. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38717. }
  38718. }
  38719. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38720. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38721. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38722. import { Scene } from "babylonjs/scene";
  38723. import { Vector3 } from "babylonjs/Maths/math";
  38724. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38725. /**
  38726. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38727. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38728. */
  38729. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38730. /**
  38731. * Creates a new AnaglyphArcRotateCamera
  38732. * @param name defines camera name
  38733. * @param alpha defines alpha angle (in radians)
  38734. * @param beta defines beta angle (in radians)
  38735. * @param radius defines radius
  38736. * @param target defines camera target
  38737. * @param interaxialDistance defines distance between each color axis
  38738. * @param scene defines the hosting scene
  38739. */
  38740. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38741. /**
  38742. * Gets camera class name
  38743. * @returns AnaglyphArcRotateCamera
  38744. */
  38745. getClassName(): string;
  38746. }
  38747. }
  38748. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38749. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38750. import { Scene } from "babylonjs/scene";
  38751. import { Vector3 } from "babylonjs/Maths/math";
  38752. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38753. /**
  38754. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38755. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38756. */
  38757. export class AnaglyphFreeCamera extends FreeCamera {
  38758. /**
  38759. * Creates a new AnaglyphFreeCamera
  38760. * @param name defines camera name
  38761. * @param position defines initial position
  38762. * @param interaxialDistance defines distance between each color axis
  38763. * @param scene defines the hosting scene
  38764. */
  38765. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38766. /**
  38767. * Gets camera class name
  38768. * @returns AnaglyphFreeCamera
  38769. */
  38770. getClassName(): string;
  38771. }
  38772. }
  38773. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38774. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38775. import { Scene } from "babylonjs/scene";
  38776. import { Vector3 } from "babylonjs/Maths/math";
  38777. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38778. /**
  38779. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38780. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38781. */
  38782. export class AnaglyphGamepadCamera extends GamepadCamera {
  38783. /**
  38784. * Creates a new AnaglyphGamepadCamera
  38785. * @param name defines camera name
  38786. * @param position defines initial position
  38787. * @param interaxialDistance defines distance between each color axis
  38788. * @param scene defines the hosting scene
  38789. */
  38790. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38791. /**
  38792. * Gets camera class name
  38793. * @returns AnaglyphGamepadCamera
  38794. */
  38795. getClassName(): string;
  38796. }
  38797. }
  38798. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38799. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38800. import { Scene } from "babylonjs/scene";
  38801. import { Vector3 } from "babylonjs/Maths/math";
  38802. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38803. /**
  38804. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38805. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38806. */
  38807. export class AnaglyphUniversalCamera extends UniversalCamera {
  38808. /**
  38809. * Creates a new AnaglyphUniversalCamera
  38810. * @param name defines camera name
  38811. * @param position defines initial position
  38812. * @param interaxialDistance defines distance between each color axis
  38813. * @param scene defines the hosting scene
  38814. */
  38815. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38816. /**
  38817. * Gets camera class name
  38818. * @returns AnaglyphUniversalCamera
  38819. */
  38820. getClassName(): string;
  38821. }
  38822. }
  38823. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38824. /** @hidden */
  38825. export var stereoscopicInterlacePixelShader: {
  38826. name: string;
  38827. shader: string;
  38828. };
  38829. }
  38830. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38831. import { Camera } from "babylonjs/Cameras/camera";
  38832. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38833. import { Engine } from "babylonjs/Engines/engine";
  38834. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38835. /**
  38836. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38837. */
  38838. export class StereoscopicInterlacePostProcess extends PostProcess {
  38839. private _stepSize;
  38840. private _passedProcess;
  38841. /**
  38842. * Initializes a StereoscopicInterlacePostProcess
  38843. * @param name The name of the effect.
  38844. * @param rigCameras The rig cameras to be appled to the post process
  38845. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38847. * @param engine The engine which the post process will be applied. (default: current engine)
  38848. * @param reusable If the post process can be reused on the same frame. (default: false)
  38849. */
  38850. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38851. }
  38852. }
  38853. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38854. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38855. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38856. import { Scene } from "babylonjs/scene";
  38857. import { Vector3 } from "babylonjs/Maths/math";
  38858. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38859. /**
  38860. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38861. * @see http://doc.babylonjs.com/features/cameras
  38862. */
  38863. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38864. /**
  38865. * Creates a new StereoscopicArcRotateCamera
  38866. * @param name defines camera name
  38867. * @param alpha defines alpha angle (in radians)
  38868. * @param beta defines beta angle (in radians)
  38869. * @param radius defines radius
  38870. * @param target defines camera target
  38871. * @param interaxialDistance defines distance between each color axis
  38872. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38873. * @param scene defines the hosting scene
  38874. */
  38875. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38876. /**
  38877. * Gets camera class name
  38878. * @returns StereoscopicArcRotateCamera
  38879. */
  38880. getClassName(): string;
  38881. }
  38882. }
  38883. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38884. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38885. import { Scene } from "babylonjs/scene";
  38886. import { Vector3 } from "babylonjs/Maths/math";
  38887. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38888. /**
  38889. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38890. * @see http://doc.babylonjs.com/features/cameras
  38891. */
  38892. export class StereoscopicFreeCamera extends FreeCamera {
  38893. /**
  38894. * Creates a new StereoscopicFreeCamera
  38895. * @param name defines camera name
  38896. * @param position defines initial position
  38897. * @param interaxialDistance defines distance between each color axis
  38898. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38899. * @param scene defines the hosting scene
  38900. */
  38901. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38902. /**
  38903. * Gets camera class name
  38904. * @returns StereoscopicFreeCamera
  38905. */
  38906. getClassName(): string;
  38907. }
  38908. }
  38909. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38910. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38911. import { Scene } from "babylonjs/scene";
  38912. import { Vector3 } from "babylonjs/Maths/math";
  38913. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38914. /**
  38915. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38916. * @see http://doc.babylonjs.com/features/cameras
  38917. */
  38918. export class StereoscopicGamepadCamera extends GamepadCamera {
  38919. /**
  38920. * Creates a new StereoscopicGamepadCamera
  38921. * @param name defines camera name
  38922. * @param position defines initial position
  38923. * @param interaxialDistance defines distance between each color axis
  38924. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38925. * @param scene defines the hosting scene
  38926. */
  38927. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38928. /**
  38929. * Gets camera class name
  38930. * @returns StereoscopicGamepadCamera
  38931. */
  38932. getClassName(): string;
  38933. }
  38934. }
  38935. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38936. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38937. import { Scene } from "babylonjs/scene";
  38938. import { Vector3 } from "babylonjs/Maths/math";
  38939. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38940. /**
  38941. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38942. * @see http://doc.babylonjs.com/features/cameras
  38943. */
  38944. export class StereoscopicUniversalCamera extends UniversalCamera {
  38945. /**
  38946. * Creates a new StereoscopicUniversalCamera
  38947. * @param name defines camera name
  38948. * @param position defines initial position
  38949. * @param interaxialDistance defines distance between each color axis
  38950. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38951. * @param scene defines the hosting scene
  38952. */
  38953. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38954. /**
  38955. * Gets camera class name
  38956. * @returns StereoscopicUniversalCamera
  38957. */
  38958. getClassName(): string;
  38959. }
  38960. }
  38961. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38962. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38963. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38964. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38965. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38966. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38967. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38968. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38969. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38970. }
  38971. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38972. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38973. import { Scene } from "babylonjs/scene";
  38974. import { Vector3 } from "babylonjs/Maths/math";
  38975. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38976. /**
  38977. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38978. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38979. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38980. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38981. */
  38982. export class VirtualJoysticksCamera extends FreeCamera {
  38983. /**
  38984. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38985. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38986. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38987. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38988. * @param name Define the name of the camera in the scene
  38989. * @param position Define the start position of the camera in the scene
  38990. * @param scene Define the scene the camera belongs to
  38991. */
  38992. constructor(name: string, position: Vector3, scene: Scene);
  38993. /**
  38994. * Gets the current object class name.
  38995. * @return the class name
  38996. */
  38997. getClassName(): string;
  38998. }
  38999. }
  39000. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39001. import { Matrix } from "babylonjs/Maths/math";
  39002. /**
  39003. * This represents all the required metrics to create a VR camera.
  39004. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39005. */
  39006. export class VRCameraMetrics {
  39007. /**
  39008. * Define the horizontal resolution off the screen.
  39009. */
  39010. hResolution: number;
  39011. /**
  39012. * Define the vertical resolution off the screen.
  39013. */
  39014. vResolution: number;
  39015. /**
  39016. * Define the horizontal screen size.
  39017. */
  39018. hScreenSize: number;
  39019. /**
  39020. * Define the vertical screen size.
  39021. */
  39022. vScreenSize: number;
  39023. /**
  39024. * Define the vertical screen center position.
  39025. */
  39026. vScreenCenter: number;
  39027. /**
  39028. * Define the distance of the eyes to the screen.
  39029. */
  39030. eyeToScreenDistance: number;
  39031. /**
  39032. * Define the distance between both lenses
  39033. */
  39034. lensSeparationDistance: number;
  39035. /**
  39036. * Define the distance between both viewer's eyes.
  39037. */
  39038. interpupillaryDistance: number;
  39039. /**
  39040. * Define the distortion factor of the VR postprocess.
  39041. * Please, touch with care.
  39042. */
  39043. distortionK: number[];
  39044. /**
  39045. * Define the chromatic aberration correction factors for the VR post process.
  39046. */
  39047. chromaAbCorrection: number[];
  39048. /**
  39049. * Define the scale factor of the post process.
  39050. * The smaller the better but the slower.
  39051. */
  39052. postProcessScaleFactor: number;
  39053. /**
  39054. * Define an offset for the lens center.
  39055. */
  39056. lensCenterOffset: number;
  39057. /**
  39058. * Define if the current vr camera should compensate the distortion of the lense or not.
  39059. */
  39060. compensateDistortion: boolean;
  39061. /**
  39062. * Defines if multiview should be enabled when rendering (Default: false)
  39063. */
  39064. multiviewEnabled: boolean;
  39065. /**
  39066. * Gets the rendering aspect ratio based on the provided resolutions.
  39067. */
  39068. readonly aspectRatio: number;
  39069. /**
  39070. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39071. */
  39072. readonly aspectRatioFov: number;
  39073. /**
  39074. * @hidden
  39075. */
  39076. readonly leftHMatrix: Matrix;
  39077. /**
  39078. * @hidden
  39079. */
  39080. readonly rightHMatrix: Matrix;
  39081. /**
  39082. * @hidden
  39083. */
  39084. readonly leftPreViewMatrix: Matrix;
  39085. /**
  39086. * @hidden
  39087. */
  39088. readonly rightPreViewMatrix: Matrix;
  39089. /**
  39090. * Get the default VRMetrics based on the most generic setup.
  39091. * @returns the default vr metrics
  39092. */
  39093. static GetDefault(): VRCameraMetrics;
  39094. }
  39095. }
  39096. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39097. /** @hidden */
  39098. export var vrDistortionCorrectionPixelShader: {
  39099. name: string;
  39100. shader: string;
  39101. };
  39102. }
  39103. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39104. import { Camera } from "babylonjs/Cameras/camera";
  39105. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39106. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39107. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39108. /**
  39109. * VRDistortionCorrectionPostProcess used for mobile VR
  39110. */
  39111. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39112. private _isRightEye;
  39113. private _distortionFactors;
  39114. private _postProcessScaleFactor;
  39115. private _lensCenterOffset;
  39116. private _scaleIn;
  39117. private _scaleFactor;
  39118. private _lensCenter;
  39119. /**
  39120. * Initializes the VRDistortionCorrectionPostProcess
  39121. * @param name The name of the effect.
  39122. * @param camera The camera to apply the render pass to.
  39123. * @param isRightEye If this is for the right eye distortion
  39124. * @param vrMetrics All the required metrics for the VR camera
  39125. */
  39126. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39127. }
  39128. }
  39129. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39130. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39131. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39132. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39133. import { Scene } from "babylonjs/scene";
  39134. import { Vector3 } from "babylonjs/Maths/math";
  39135. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39136. import "babylonjs/Cameras/RigModes/vrRigMode";
  39137. /**
  39138. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39139. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39140. */
  39141. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39142. /**
  39143. * Creates a new VRDeviceOrientationArcRotateCamera
  39144. * @param name defines camera name
  39145. * @param alpha defines the camera rotation along the logitudinal axis
  39146. * @param beta defines the camera rotation along the latitudinal axis
  39147. * @param radius defines the camera distance from its target
  39148. * @param target defines the camera target
  39149. * @param scene defines the scene the camera belongs to
  39150. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39151. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39152. */
  39153. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39154. /**
  39155. * Gets camera class name
  39156. * @returns VRDeviceOrientationArcRotateCamera
  39157. */
  39158. getClassName(): string;
  39159. }
  39160. }
  39161. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39162. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39163. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39164. import { Scene } from "babylonjs/scene";
  39165. import { Vector3 } from "babylonjs/Maths/math";
  39166. import "babylonjs/Cameras/RigModes/vrRigMode";
  39167. /**
  39168. * Camera used to simulate VR rendering (based on FreeCamera)
  39169. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39170. */
  39171. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39172. /**
  39173. * Creates a new VRDeviceOrientationFreeCamera
  39174. * @param name defines camera name
  39175. * @param position defines the start position of the camera
  39176. * @param scene defines the scene the camera belongs to
  39177. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39178. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39179. */
  39180. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39181. /**
  39182. * Gets camera class name
  39183. * @returns VRDeviceOrientationFreeCamera
  39184. */
  39185. getClassName(): string;
  39186. }
  39187. }
  39188. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39189. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39190. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39191. import { Scene } from "babylonjs/scene";
  39192. import { Vector3 } from "babylonjs/Maths/math";
  39193. /**
  39194. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39195. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39196. */
  39197. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39198. /**
  39199. * Creates a new VRDeviceOrientationGamepadCamera
  39200. * @param name defines camera name
  39201. * @param position defines the start position of the camera
  39202. * @param scene defines the scene the camera belongs to
  39203. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39204. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39205. */
  39206. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39207. /**
  39208. * Gets camera class name
  39209. * @returns VRDeviceOrientationGamepadCamera
  39210. */
  39211. getClassName(): string;
  39212. }
  39213. }
  39214. declare module "babylonjs/Gamepads/xboxGamepad" {
  39215. import { Observable } from "babylonjs/Misc/observable";
  39216. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39217. /**
  39218. * Defines supported buttons for XBox360 compatible gamepads
  39219. */
  39220. export enum Xbox360Button {
  39221. /** A */
  39222. A = 0,
  39223. /** B */
  39224. B = 1,
  39225. /** X */
  39226. X = 2,
  39227. /** Y */
  39228. Y = 3,
  39229. /** Start */
  39230. Start = 4,
  39231. /** Back */
  39232. Back = 5,
  39233. /** Left button */
  39234. LB = 6,
  39235. /** Right button */
  39236. RB = 7,
  39237. /** Left stick */
  39238. LeftStick = 8,
  39239. /** Right stick */
  39240. RightStick = 9
  39241. }
  39242. /** Defines values for XBox360 DPad */
  39243. export enum Xbox360Dpad {
  39244. /** Up */
  39245. Up = 0,
  39246. /** Down */
  39247. Down = 1,
  39248. /** Left */
  39249. Left = 2,
  39250. /** Right */
  39251. Right = 3
  39252. }
  39253. /**
  39254. * Defines a XBox360 gamepad
  39255. */
  39256. export class Xbox360Pad extends Gamepad {
  39257. private _leftTrigger;
  39258. private _rightTrigger;
  39259. private _onlefttriggerchanged;
  39260. private _onrighttriggerchanged;
  39261. private _onbuttondown;
  39262. private _onbuttonup;
  39263. private _ondpaddown;
  39264. private _ondpadup;
  39265. /** Observable raised when a button is pressed */
  39266. onButtonDownObservable: Observable<Xbox360Button>;
  39267. /** Observable raised when a button is released */
  39268. onButtonUpObservable: Observable<Xbox360Button>;
  39269. /** Observable raised when a pad is pressed */
  39270. onPadDownObservable: Observable<Xbox360Dpad>;
  39271. /** Observable raised when a pad is released */
  39272. onPadUpObservable: Observable<Xbox360Dpad>;
  39273. private _buttonA;
  39274. private _buttonB;
  39275. private _buttonX;
  39276. private _buttonY;
  39277. private _buttonBack;
  39278. private _buttonStart;
  39279. private _buttonLB;
  39280. private _buttonRB;
  39281. private _buttonLeftStick;
  39282. private _buttonRightStick;
  39283. private _dPadUp;
  39284. private _dPadDown;
  39285. private _dPadLeft;
  39286. private _dPadRight;
  39287. private _isXboxOnePad;
  39288. /**
  39289. * Creates a new XBox360 gamepad object
  39290. * @param id defines the id of this gamepad
  39291. * @param index defines its index
  39292. * @param gamepad defines the internal HTML gamepad object
  39293. * @param xboxOne defines if it is a XBox One gamepad
  39294. */
  39295. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39296. /**
  39297. * Defines the callback to call when left trigger is pressed
  39298. * @param callback defines the callback to use
  39299. */
  39300. onlefttriggerchanged(callback: (value: number) => void): void;
  39301. /**
  39302. * Defines the callback to call when right trigger is pressed
  39303. * @param callback defines the callback to use
  39304. */
  39305. onrighttriggerchanged(callback: (value: number) => void): void;
  39306. /**
  39307. * Gets the left trigger value
  39308. */
  39309. /**
  39310. * Sets the left trigger value
  39311. */
  39312. leftTrigger: number;
  39313. /**
  39314. * Gets the right trigger value
  39315. */
  39316. /**
  39317. * Sets the right trigger value
  39318. */
  39319. rightTrigger: number;
  39320. /**
  39321. * Defines the callback to call when a button is pressed
  39322. * @param callback defines the callback to use
  39323. */
  39324. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39325. /**
  39326. * Defines the callback to call when a button is released
  39327. * @param callback defines the callback to use
  39328. */
  39329. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39330. /**
  39331. * Defines the callback to call when a pad is pressed
  39332. * @param callback defines the callback to use
  39333. */
  39334. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39335. /**
  39336. * Defines the callback to call when a pad is released
  39337. * @param callback defines the callback to use
  39338. */
  39339. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39340. private _setButtonValue;
  39341. private _setDPadValue;
  39342. /**
  39343. * Gets the value of the `A` button
  39344. */
  39345. /**
  39346. * Sets the value of the `A` button
  39347. */
  39348. buttonA: number;
  39349. /**
  39350. * Gets the value of the `B` button
  39351. */
  39352. /**
  39353. * Sets the value of the `B` button
  39354. */
  39355. buttonB: number;
  39356. /**
  39357. * Gets the value of the `X` button
  39358. */
  39359. /**
  39360. * Sets the value of the `X` button
  39361. */
  39362. buttonX: number;
  39363. /**
  39364. * Gets the value of the `Y` button
  39365. */
  39366. /**
  39367. * Sets the value of the `Y` button
  39368. */
  39369. buttonY: number;
  39370. /**
  39371. * Gets the value of the `Start` button
  39372. */
  39373. /**
  39374. * Sets the value of the `Start` button
  39375. */
  39376. buttonStart: number;
  39377. /**
  39378. * Gets the value of the `Back` button
  39379. */
  39380. /**
  39381. * Sets the value of the `Back` button
  39382. */
  39383. buttonBack: number;
  39384. /**
  39385. * Gets the value of the `Left` button
  39386. */
  39387. /**
  39388. * Sets the value of the `Left` button
  39389. */
  39390. buttonLB: number;
  39391. /**
  39392. * Gets the value of the `Right` button
  39393. */
  39394. /**
  39395. * Sets the value of the `Right` button
  39396. */
  39397. buttonRB: number;
  39398. /**
  39399. * Gets the value of the Left joystick
  39400. */
  39401. /**
  39402. * Sets the value of the Left joystick
  39403. */
  39404. buttonLeftStick: number;
  39405. /**
  39406. * Gets the value of the Right joystick
  39407. */
  39408. /**
  39409. * Sets the value of the Right joystick
  39410. */
  39411. buttonRightStick: number;
  39412. /**
  39413. * Gets the value of D-pad up
  39414. */
  39415. /**
  39416. * Sets the value of D-pad up
  39417. */
  39418. dPadUp: number;
  39419. /**
  39420. * Gets the value of D-pad down
  39421. */
  39422. /**
  39423. * Sets the value of D-pad down
  39424. */
  39425. dPadDown: number;
  39426. /**
  39427. * Gets the value of D-pad left
  39428. */
  39429. /**
  39430. * Sets the value of D-pad left
  39431. */
  39432. dPadLeft: number;
  39433. /**
  39434. * Gets the value of D-pad right
  39435. */
  39436. /**
  39437. * Sets the value of D-pad right
  39438. */
  39439. dPadRight: number;
  39440. /**
  39441. * Force the gamepad to synchronize with device values
  39442. */
  39443. update(): void;
  39444. /**
  39445. * Disposes the gamepad
  39446. */
  39447. dispose(): void;
  39448. }
  39449. }
  39450. declare module "babylonjs/Materials/pushMaterial" {
  39451. import { Nullable } from "babylonjs/types";
  39452. import { Scene } from "babylonjs/scene";
  39453. import { Matrix } from "babylonjs/Maths/math";
  39454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39455. import { Mesh } from "babylonjs/Meshes/mesh";
  39456. import { Material } from "babylonjs/Materials/material";
  39457. import { Effect } from "babylonjs/Materials/effect";
  39458. /**
  39459. * Base class of materials working in push mode in babylon JS
  39460. * @hidden
  39461. */
  39462. export class PushMaterial extends Material {
  39463. protected _activeEffect: Effect;
  39464. protected _normalMatrix: Matrix;
  39465. /**
  39466. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39467. * This means that the material can keep using a previous shader while a new one is being compiled.
  39468. * This is mostly used when shader parallel compilation is supported (true by default)
  39469. */
  39470. allowShaderHotSwapping: boolean;
  39471. constructor(name: string, scene: Scene);
  39472. getEffect(): Effect;
  39473. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39474. /**
  39475. * Binds the given world matrix to the active effect
  39476. *
  39477. * @param world the matrix to bind
  39478. */
  39479. bindOnlyWorldMatrix(world: Matrix): void;
  39480. /**
  39481. * Binds the given normal matrix to the active effect
  39482. *
  39483. * @param normalMatrix the matrix to bind
  39484. */
  39485. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39486. bind(world: Matrix, mesh?: Mesh): void;
  39487. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39488. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39489. }
  39490. }
  39491. declare module "babylonjs/Materials/materialFlags" {
  39492. /**
  39493. * This groups all the flags used to control the materials channel.
  39494. */
  39495. export class MaterialFlags {
  39496. private static _DiffuseTextureEnabled;
  39497. /**
  39498. * Are diffuse textures enabled in the application.
  39499. */
  39500. static DiffuseTextureEnabled: boolean;
  39501. private static _AmbientTextureEnabled;
  39502. /**
  39503. * Are ambient textures enabled in the application.
  39504. */
  39505. static AmbientTextureEnabled: boolean;
  39506. private static _OpacityTextureEnabled;
  39507. /**
  39508. * Are opacity textures enabled in the application.
  39509. */
  39510. static OpacityTextureEnabled: boolean;
  39511. private static _ReflectionTextureEnabled;
  39512. /**
  39513. * Are reflection textures enabled in the application.
  39514. */
  39515. static ReflectionTextureEnabled: boolean;
  39516. private static _EmissiveTextureEnabled;
  39517. /**
  39518. * Are emissive textures enabled in the application.
  39519. */
  39520. static EmissiveTextureEnabled: boolean;
  39521. private static _SpecularTextureEnabled;
  39522. /**
  39523. * Are specular textures enabled in the application.
  39524. */
  39525. static SpecularTextureEnabled: boolean;
  39526. private static _BumpTextureEnabled;
  39527. /**
  39528. * Are bump textures enabled in the application.
  39529. */
  39530. static BumpTextureEnabled: boolean;
  39531. private static _LightmapTextureEnabled;
  39532. /**
  39533. * Are lightmap textures enabled in the application.
  39534. */
  39535. static LightmapTextureEnabled: boolean;
  39536. private static _RefractionTextureEnabled;
  39537. /**
  39538. * Are refraction textures enabled in the application.
  39539. */
  39540. static RefractionTextureEnabled: boolean;
  39541. private static _ColorGradingTextureEnabled;
  39542. /**
  39543. * Are color grading textures enabled in the application.
  39544. */
  39545. static ColorGradingTextureEnabled: boolean;
  39546. private static _FresnelEnabled;
  39547. /**
  39548. * Are fresnels enabled in the application.
  39549. */
  39550. static FresnelEnabled: boolean;
  39551. private static _ClearCoatTextureEnabled;
  39552. /**
  39553. * Are clear coat textures enabled in the application.
  39554. */
  39555. static ClearCoatTextureEnabled: boolean;
  39556. private static _ClearCoatBumpTextureEnabled;
  39557. /**
  39558. * Are clear coat bump textures enabled in the application.
  39559. */
  39560. static ClearCoatBumpTextureEnabled: boolean;
  39561. private static _ClearCoatTintTextureEnabled;
  39562. /**
  39563. * Are clear coat tint textures enabled in the application.
  39564. */
  39565. static ClearCoatTintTextureEnabled: boolean;
  39566. private static _SheenTextureEnabled;
  39567. /**
  39568. * Are sheen textures enabled in the application.
  39569. */
  39570. static SheenTextureEnabled: boolean;
  39571. private static _AnisotropicTextureEnabled;
  39572. /**
  39573. * Are anisotropic textures enabled in the application.
  39574. */
  39575. static AnisotropicTextureEnabled: boolean;
  39576. private static _ThicknessTextureEnabled;
  39577. /**
  39578. * Are thickness textures enabled in the application.
  39579. */
  39580. static ThicknessTextureEnabled: boolean;
  39581. }
  39582. }
  39583. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39584. /** @hidden */
  39585. export var defaultFragmentDeclaration: {
  39586. name: string;
  39587. shader: string;
  39588. };
  39589. }
  39590. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39591. /** @hidden */
  39592. export var defaultUboDeclaration: {
  39593. name: string;
  39594. shader: string;
  39595. };
  39596. }
  39597. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39598. /** @hidden */
  39599. export var lightFragmentDeclaration: {
  39600. name: string;
  39601. shader: string;
  39602. };
  39603. }
  39604. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39605. /** @hidden */
  39606. export var lightUboDeclaration: {
  39607. name: string;
  39608. shader: string;
  39609. };
  39610. }
  39611. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39612. /** @hidden */
  39613. export var lightsFragmentFunctions: {
  39614. name: string;
  39615. shader: string;
  39616. };
  39617. }
  39618. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39619. /** @hidden */
  39620. export var shadowsFragmentFunctions: {
  39621. name: string;
  39622. shader: string;
  39623. };
  39624. }
  39625. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39626. /** @hidden */
  39627. export var fresnelFunction: {
  39628. name: string;
  39629. shader: string;
  39630. };
  39631. }
  39632. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39633. /** @hidden */
  39634. export var reflectionFunction: {
  39635. name: string;
  39636. shader: string;
  39637. };
  39638. }
  39639. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39640. /** @hidden */
  39641. export var bumpFragmentFunctions: {
  39642. name: string;
  39643. shader: string;
  39644. };
  39645. }
  39646. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39647. /** @hidden */
  39648. export var logDepthDeclaration: {
  39649. name: string;
  39650. shader: string;
  39651. };
  39652. }
  39653. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39654. /** @hidden */
  39655. export var bumpFragment: {
  39656. name: string;
  39657. shader: string;
  39658. };
  39659. }
  39660. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39661. /** @hidden */
  39662. export var depthPrePass: {
  39663. name: string;
  39664. shader: string;
  39665. };
  39666. }
  39667. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39668. /** @hidden */
  39669. export var lightFragment: {
  39670. name: string;
  39671. shader: string;
  39672. };
  39673. }
  39674. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39675. /** @hidden */
  39676. export var logDepthFragment: {
  39677. name: string;
  39678. shader: string;
  39679. };
  39680. }
  39681. declare module "babylonjs/Shaders/default.fragment" {
  39682. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39683. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39684. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39685. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39686. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39687. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39688. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39689. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39690. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39691. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39692. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39693. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39694. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39695. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39696. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39697. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39698. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39699. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39700. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39701. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39702. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39703. /** @hidden */
  39704. export var defaultPixelShader: {
  39705. name: string;
  39706. shader: string;
  39707. };
  39708. }
  39709. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39710. /** @hidden */
  39711. export var defaultVertexDeclaration: {
  39712. name: string;
  39713. shader: string;
  39714. };
  39715. }
  39716. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39717. /** @hidden */
  39718. export var bumpVertexDeclaration: {
  39719. name: string;
  39720. shader: string;
  39721. };
  39722. }
  39723. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39724. /** @hidden */
  39725. export var bumpVertex: {
  39726. name: string;
  39727. shader: string;
  39728. };
  39729. }
  39730. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39731. /** @hidden */
  39732. export var fogVertex: {
  39733. name: string;
  39734. shader: string;
  39735. };
  39736. }
  39737. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39738. /** @hidden */
  39739. export var shadowsVertex: {
  39740. name: string;
  39741. shader: string;
  39742. };
  39743. }
  39744. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39745. /** @hidden */
  39746. export var pointCloudVertex: {
  39747. name: string;
  39748. shader: string;
  39749. };
  39750. }
  39751. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39752. /** @hidden */
  39753. export var logDepthVertex: {
  39754. name: string;
  39755. shader: string;
  39756. };
  39757. }
  39758. declare module "babylonjs/Shaders/default.vertex" {
  39759. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39760. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39761. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39762. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39763. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39764. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39765. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39766. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39767. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39768. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39769. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39770. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39771. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39772. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39773. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39774. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39775. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39776. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39777. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39778. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39779. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39780. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39781. /** @hidden */
  39782. export var defaultVertexShader: {
  39783. name: string;
  39784. shader: string;
  39785. };
  39786. }
  39787. declare module "babylonjs/Materials/standardMaterial" {
  39788. import { SmartArray } from "babylonjs/Misc/smartArray";
  39789. import { IAnimatable } from "babylonjs/Misc/tools";
  39790. import { Nullable } from "babylonjs/types";
  39791. import { Scene } from "babylonjs/scene";
  39792. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39793. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39795. import { Mesh } from "babylonjs/Meshes/mesh";
  39796. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39797. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39798. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39799. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39800. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39801. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39802. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39803. import "babylonjs/Shaders/default.fragment";
  39804. import "babylonjs/Shaders/default.vertex";
  39805. /** @hidden */
  39806. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39807. MAINUV1: boolean;
  39808. MAINUV2: boolean;
  39809. DIFFUSE: boolean;
  39810. DIFFUSEDIRECTUV: number;
  39811. AMBIENT: boolean;
  39812. AMBIENTDIRECTUV: number;
  39813. OPACITY: boolean;
  39814. OPACITYDIRECTUV: number;
  39815. OPACITYRGB: boolean;
  39816. REFLECTION: boolean;
  39817. EMISSIVE: boolean;
  39818. EMISSIVEDIRECTUV: number;
  39819. SPECULAR: boolean;
  39820. SPECULARDIRECTUV: number;
  39821. BUMP: boolean;
  39822. BUMPDIRECTUV: number;
  39823. PARALLAX: boolean;
  39824. PARALLAXOCCLUSION: boolean;
  39825. SPECULAROVERALPHA: boolean;
  39826. CLIPPLANE: boolean;
  39827. CLIPPLANE2: boolean;
  39828. CLIPPLANE3: boolean;
  39829. CLIPPLANE4: boolean;
  39830. ALPHATEST: boolean;
  39831. DEPTHPREPASS: boolean;
  39832. ALPHAFROMDIFFUSE: boolean;
  39833. POINTSIZE: boolean;
  39834. FOG: boolean;
  39835. SPECULARTERM: boolean;
  39836. DIFFUSEFRESNEL: boolean;
  39837. OPACITYFRESNEL: boolean;
  39838. REFLECTIONFRESNEL: boolean;
  39839. REFRACTIONFRESNEL: boolean;
  39840. EMISSIVEFRESNEL: boolean;
  39841. FRESNEL: boolean;
  39842. NORMAL: boolean;
  39843. UV1: boolean;
  39844. UV2: boolean;
  39845. VERTEXCOLOR: boolean;
  39846. VERTEXALPHA: boolean;
  39847. NUM_BONE_INFLUENCERS: number;
  39848. BonesPerMesh: number;
  39849. BONETEXTURE: boolean;
  39850. INSTANCES: boolean;
  39851. GLOSSINESS: boolean;
  39852. ROUGHNESS: boolean;
  39853. EMISSIVEASILLUMINATION: boolean;
  39854. LINKEMISSIVEWITHDIFFUSE: boolean;
  39855. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39856. LIGHTMAP: boolean;
  39857. LIGHTMAPDIRECTUV: number;
  39858. OBJECTSPACE_NORMALMAP: boolean;
  39859. USELIGHTMAPASSHADOWMAP: boolean;
  39860. REFLECTIONMAP_3D: boolean;
  39861. REFLECTIONMAP_SPHERICAL: boolean;
  39862. REFLECTIONMAP_PLANAR: boolean;
  39863. REFLECTIONMAP_CUBIC: boolean;
  39864. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39865. REFLECTIONMAP_PROJECTION: boolean;
  39866. REFLECTIONMAP_SKYBOX: boolean;
  39867. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39868. REFLECTIONMAP_EXPLICIT: boolean;
  39869. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39870. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39871. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39872. INVERTCUBICMAP: boolean;
  39873. LOGARITHMICDEPTH: boolean;
  39874. REFRACTION: boolean;
  39875. REFRACTIONMAP_3D: boolean;
  39876. REFLECTIONOVERALPHA: boolean;
  39877. TWOSIDEDLIGHTING: boolean;
  39878. SHADOWFLOAT: boolean;
  39879. MORPHTARGETS: boolean;
  39880. MORPHTARGETS_NORMAL: boolean;
  39881. MORPHTARGETS_TANGENT: boolean;
  39882. NUM_MORPH_INFLUENCERS: number;
  39883. NONUNIFORMSCALING: boolean;
  39884. PREMULTIPLYALPHA: boolean;
  39885. IMAGEPROCESSING: boolean;
  39886. VIGNETTE: boolean;
  39887. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39888. VIGNETTEBLENDMODEOPAQUE: boolean;
  39889. TONEMAPPING: boolean;
  39890. TONEMAPPING_ACES: boolean;
  39891. CONTRAST: boolean;
  39892. COLORCURVES: boolean;
  39893. COLORGRADING: boolean;
  39894. COLORGRADING3D: boolean;
  39895. SAMPLER3DGREENDEPTH: boolean;
  39896. SAMPLER3DBGRMAP: boolean;
  39897. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39898. MULTIVIEW: boolean;
  39899. /**
  39900. * If the reflection texture on this material is in linear color space
  39901. * @hidden
  39902. */
  39903. IS_REFLECTION_LINEAR: boolean;
  39904. /**
  39905. * If the refraction texture on this material is in linear color space
  39906. * @hidden
  39907. */
  39908. IS_REFRACTION_LINEAR: boolean;
  39909. EXPOSURE: boolean;
  39910. constructor();
  39911. setReflectionMode(modeToEnable: string): void;
  39912. }
  39913. /**
  39914. * This is the default material used in Babylon. It is the best trade off between quality
  39915. * and performances.
  39916. * @see http://doc.babylonjs.com/babylon101/materials
  39917. */
  39918. export class StandardMaterial extends PushMaterial {
  39919. private _diffuseTexture;
  39920. /**
  39921. * The basic texture of the material as viewed under a light.
  39922. */
  39923. diffuseTexture: Nullable<BaseTexture>;
  39924. private _ambientTexture;
  39925. /**
  39926. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39927. */
  39928. ambientTexture: Nullable<BaseTexture>;
  39929. private _opacityTexture;
  39930. /**
  39931. * Define the transparency of the material from a texture.
  39932. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39933. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39934. */
  39935. opacityTexture: Nullable<BaseTexture>;
  39936. private _reflectionTexture;
  39937. /**
  39938. * Define the texture used to display the reflection.
  39939. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39940. */
  39941. reflectionTexture: Nullable<BaseTexture>;
  39942. private _emissiveTexture;
  39943. /**
  39944. * Define texture of the material as if self lit.
  39945. * This will be mixed in the final result even in the absence of light.
  39946. */
  39947. emissiveTexture: Nullable<BaseTexture>;
  39948. private _specularTexture;
  39949. /**
  39950. * Define how the color and intensity of the highlight given by the light in the material.
  39951. */
  39952. specularTexture: Nullable<BaseTexture>;
  39953. private _bumpTexture;
  39954. /**
  39955. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39956. * 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.
  39957. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39958. */
  39959. bumpTexture: Nullable<BaseTexture>;
  39960. private _lightmapTexture;
  39961. /**
  39962. * Complex lighting can be computationally expensive to compute at runtime.
  39963. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39964. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39965. */
  39966. lightmapTexture: Nullable<BaseTexture>;
  39967. private _refractionTexture;
  39968. /**
  39969. * Define the texture used to display the refraction.
  39970. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39971. */
  39972. refractionTexture: Nullable<BaseTexture>;
  39973. /**
  39974. * The color of the material lit by the environmental background lighting.
  39975. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39976. */
  39977. ambientColor: Color3;
  39978. /**
  39979. * The basic color of the material as viewed under a light.
  39980. */
  39981. diffuseColor: Color3;
  39982. /**
  39983. * Define how the color and intensity of the highlight given by the light in the material.
  39984. */
  39985. specularColor: Color3;
  39986. /**
  39987. * Define the color of the material as if self lit.
  39988. * This will be mixed in the final result even in the absence of light.
  39989. */
  39990. emissiveColor: Color3;
  39991. /**
  39992. * Defines how sharp are the highlights in the material.
  39993. * The bigger the value the sharper giving a more glossy feeling to the result.
  39994. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39995. */
  39996. specularPower: number;
  39997. private _useAlphaFromDiffuseTexture;
  39998. /**
  39999. * Does the transparency come from the diffuse texture alpha channel.
  40000. */
  40001. useAlphaFromDiffuseTexture: boolean;
  40002. private _useEmissiveAsIllumination;
  40003. /**
  40004. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40005. */
  40006. useEmissiveAsIllumination: boolean;
  40007. private _linkEmissiveWithDiffuse;
  40008. /**
  40009. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40010. * the emissive level when the final color is close to one.
  40011. */
  40012. linkEmissiveWithDiffuse: boolean;
  40013. private _useSpecularOverAlpha;
  40014. /**
  40015. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40016. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40017. */
  40018. useSpecularOverAlpha: boolean;
  40019. private _useReflectionOverAlpha;
  40020. /**
  40021. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40022. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40023. */
  40024. useReflectionOverAlpha: boolean;
  40025. private _disableLighting;
  40026. /**
  40027. * Does lights from the scene impacts this material.
  40028. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40029. */
  40030. disableLighting: boolean;
  40031. private _useObjectSpaceNormalMap;
  40032. /**
  40033. * Allows using an object space normal map (instead of tangent space).
  40034. */
  40035. useObjectSpaceNormalMap: boolean;
  40036. private _useParallax;
  40037. /**
  40038. * Is parallax enabled or not.
  40039. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40040. */
  40041. useParallax: boolean;
  40042. private _useParallaxOcclusion;
  40043. /**
  40044. * Is parallax occlusion enabled or not.
  40045. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40046. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40047. */
  40048. useParallaxOcclusion: boolean;
  40049. /**
  40050. * 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.
  40051. */
  40052. parallaxScaleBias: number;
  40053. private _roughness;
  40054. /**
  40055. * Helps to define how blurry the reflections should appears in the material.
  40056. */
  40057. roughness: number;
  40058. /**
  40059. * In case of refraction, define the value of the indice of refraction.
  40060. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40061. */
  40062. indexOfRefraction: number;
  40063. /**
  40064. * Invert the refraction texture alongside the y axis.
  40065. * It can be useful with procedural textures or probe for instance.
  40066. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40067. */
  40068. invertRefractionY: boolean;
  40069. /**
  40070. * Defines the alpha limits in alpha test mode.
  40071. */
  40072. alphaCutOff: number;
  40073. private _useLightmapAsShadowmap;
  40074. /**
  40075. * In case of light mapping, define whether the map contains light or shadow informations.
  40076. */
  40077. useLightmapAsShadowmap: boolean;
  40078. private _diffuseFresnelParameters;
  40079. /**
  40080. * Define the diffuse fresnel parameters of the material.
  40081. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40082. */
  40083. diffuseFresnelParameters: FresnelParameters;
  40084. private _opacityFresnelParameters;
  40085. /**
  40086. * Define the opacity fresnel parameters of the material.
  40087. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40088. */
  40089. opacityFresnelParameters: FresnelParameters;
  40090. private _reflectionFresnelParameters;
  40091. /**
  40092. * Define the reflection fresnel parameters of the material.
  40093. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40094. */
  40095. reflectionFresnelParameters: FresnelParameters;
  40096. private _refractionFresnelParameters;
  40097. /**
  40098. * Define the refraction fresnel parameters of the material.
  40099. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40100. */
  40101. refractionFresnelParameters: FresnelParameters;
  40102. private _emissiveFresnelParameters;
  40103. /**
  40104. * Define the emissive fresnel parameters of the material.
  40105. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40106. */
  40107. emissiveFresnelParameters: FresnelParameters;
  40108. private _useReflectionFresnelFromSpecular;
  40109. /**
  40110. * If true automatically deducts the fresnels values from the material specularity.
  40111. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40112. */
  40113. useReflectionFresnelFromSpecular: boolean;
  40114. private _useGlossinessFromSpecularMapAlpha;
  40115. /**
  40116. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40117. */
  40118. useGlossinessFromSpecularMapAlpha: boolean;
  40119. private _maxSimultaneousLights;
  40120. /**
  40121. * Defines the maximum number of lights that can be used in the material
  40122. */
  40123. maxSimultaneousLights: number;
  40124. private _invertNormalMapX;
  40125. /**
  40126. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40127. */
  40128. invertNormalMapX: boolean;
  40129. private _invertNormalMapY;
  40130. /**
  40131. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40132. */
  40133. invertNormalMapY: boolean;
  40134. private _twoSidedLighting;
  40135. /**
  40136. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40137. */
  40138. twoSidedLighting: boolean;
  40139. /**
  40140. * Default configuration related to image processing available in the standard Material.
  40141. */
  40142. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40143. /**
  40144. * Gets the image processing configuration used either in this material.
  40145. */
  40146. /**
  40147. * Sets the Default image processing configuration used either in the this material.
  40148. *
  40149. * If sets to null, the scene one is in use.
  40150. */
  40151. imageProcessingConfiguration: ImageProcessingConfiguration;
  40152. /**
  40153. * Keep track of the image processing observer to allow dispose and replace.
  40154. */
  40155. private _imageProcessingObserver;
  40156. /**
  40157. * Attaches a new image processing configuration to the Standard Material.
  40158. * @param configuration
  40159. */
  40160. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40161. /**
  40162. * Gets wether the color curves effect is enabled.
  40163. */
  40164. /**
  40165. * Sets wether the color curves effect is enabled.
  40166. */
  40167. cameraColorCurvesEnabled: boolean;
  40168. /**
  40169. * Gets wether the color grading effect is enabled.
  40170. */
  40171. /**
  40172. * Gets wether the color grading effect is enabled.
  40173. */
  40174. cameraColorGradingEnabled: boolean;
  40175. /**
  40176. * Gets wether tonemapping is enabled or not.
  40177. */
  40178. /**
  40179. * Sets wether tonemapping is enabled or not
  40180. */
  40181. cameraToneMappingEnabled: boolean;
  40182. /**
  40183. * The camera exposure used on this material.
  40184. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40185. * This corresponds to a photographic exposure.
  40186. */
  40187. /**
  40188. * The camera exposure used on this material.
  40189. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40190. * This corresponds to a photographic exposure.
  40191. */
  40192. cameraExposure: number;
  40193. /**
  40194. * Gets The camera contrast used on this material.
  40195. */
  40196. /**
  40197. * Sets The camera contrast used on this material.
  40198. */
  40199. cameraContrast: number;
  40200. /**
  40201. * Gets the Color Grading 2D Lookup Texture.
  40202. */
  40203. /**
  40204. * Sets the Color Grading 2D Lookup Texture.
  40205. */
  40206. cameraColorGradingTexture: Nullable<BaseTexture>;
  40207. /**
  40208. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40209. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40210. * 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;
  40211. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40212. */
  40213. /**
  40214. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40215. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40216. * 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;
  40217. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40218. */
  40219. cameraColorCurves: Nullable<ColorCurves>;
  40220. /**
  40221. * Custom callback helping to override the default shader used in the material.
  40222. */
  40223. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40224. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40225. protected _worldViewProjectionMatrix: Matrix;
  40226. protected _globalAmbientColor: Color3;
  40227. protected _useLogarithmicDepth: boolean;
  40228. /**
  40229. * Instantiates a new standard material.
  40230. * This is the default material used in Babylon. It is the best trade off between quality
  40231. * and performances.
  40232. * @see http://doc.babylonjs.com/babylon101/materials
  40233. * @param name Define the name of the material in the scene
  40234. * @param scene Define the scene the material belong to
  40235. */
  40236. constructor(name: string, scene: Scene);
  40237. /**
  40238. * Gets a boolean indicating that current material needs to register RTT
  40239. */
  40240. readonly hasRenderTargetTextures: boolean;
  40241. /**
  40242. * Gets the current class name of the material e.g. "StandardMaterial"
  40243. * Mainly use in serialization.
  40244. * @returns the class name
  40245. */
  40246. getClassName(): string;
  40247. /**
  40248. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40249. * You can try switching to logarithmic depth.
  40250. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40251. */
  40252. useLogarithmicDepth: boolean;
  40253. /**
  40254. * Specifies if the material will require alpha blending
  40255. * @returns a boolean specifying if alpha blending is needed
  40256. */
  40257. needAlphaBlending(): boolean;
  40258. /**
  40259. * Specifies if this material should be rendered in alpha test mode
  40260. * @returns a boolean specifying if an alpha test is needed.
  40261. */
  40262. needAlphaTesting(): boolean;
  40263. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40264. /**
  40265. * Get the texture used for alpha test purpose.
  40266. * @returns the diffuse texture in case of the standard material.
  40267. */
  40268. getAlphaTestTexture(): Nullable<BaseTexture>;
  40269. /**
  40270. * Get if the submesh is ready to be used and all its information available.
  40271. * Child classes can use it to update shaders
  40272. * @param mesh defines the mesh to check
  40273. * @param subMesh defines which submesh to check
  40274. * @param useInstances specifies that instances should be used
  40275. * @returns a boolean indicating that the submesh is ready or not
  40276. */
  40277. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40278. /**
  40279. * Builds the material UBO layouts.
  40280. * Used internally during the effect preparation.
  40281. */
  40282. buildUniformLayout(): void;
  40283. /**
  40284. * Unbinds the material from the mesh
  40285. */
  40286. unbind(): void;
  40287. /**
  40288. * Binds the submesh to this material by preparing the effect and shader to draw
  40289. * @param world defines the world transformation matrix
  40290. * @param mesh defines the mesh containing the submesh
  40291. * @param subMesh defines the submesh to bind the material to
  40292. */
  40293. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40294. /**
  40295. * Get the list of animatables in the material.
  40296. * @returns the list of animatables object used in the material
  40297. */
  40298. getAnimatables(): IAnimatable[];
  40299. /**
  40300. * Gets the active textures from the material
  40301. * @returns an array of textures
  40302. */
  40303. getActiveTextures(): BaseTexture[];
  40304. /**
  40305. * Specifies if the material uses a texture
  40306. * @param texture defines the texture to check against the material
  40307. * @returns a boolean specifying if the material uses the texture
  40308. */
  40309. hasTexture(texture: BaseTexture): boolean;
  40310. /**
  40311. * Disposes the material
  40312. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40313. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40314. */
  40315. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40316. /**
  40317. * Makes a duplicate of the material, and gives it a new name
  40318. * @param name defines the new name for the duplicated material
  40319. * @returns the cloned material
  40320. */
  40321. clone(name: string): StandardMaterial;
  40322. /**
  40323. * Serializes this material in a JSON representation
  40324. * @returns the serialized material object
  40325. */
  40326. serialize(): any;
  40327. /**
  40328. * Creates a standard material from parsed material data
  40329. * @param source defines the JSON representation of the material
  40330. * @param scene defines the hosting scene
  40331. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40332. * @returns a new standard material
  40333. */
  40334. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40335. /**
  40336. * Are diffuse textures enabled in the application.
  40337. */
  40338. static DiffuseTextureEnabled: boolean;
  40339. /**
  40340. * Are ambient textures enabled in the application.
  40341. */
  40342. static AmbientTextureEnabled: boolean;
  40343. /**
  40344. * Are opacity textures enabled in the application.
  40345. */
  40346. static OpacityTextureEnabled: boolean;
  40347. /**
  40348. * Are reflection textures enabled in the application.
  40349. */
  40350. static ReflectionTextureEnabled: boolean;
  40351. /**
  40352. * Are emissive textures enabled in the application.
  40353. */
  40354. static EmissiveTextureEnabled: boolean;
  40355. /**
  40356. * Are specular textures enabled in the application.
  40357. */
  40358. static SpecularTextureEnabled: boolean;
  40359. /**
  40360. * Are bump textures enabled in the application.
  40361. */
  40362. static BumpTextureEnabled: boolean;
  40363. /**
  40364. * Are lightmap textures enabled in the application.
  40365. */
  40366. static LightmapTextureEnabled: boolean;
  40367. /**
  40368. * Are refraction textures enabled in the application.
  40369. */
  40370. static RefractionTextureEnabled: boolean;
  40371. /**
  40372. * Are color grading textures enabled in the application.
  40373. */
  40374. static ColorGradingTextureEnabled: boolean;
  40375. /**
  40376. * Are fresnels enabled in the application.
  40377. */
  40378. static FresnelEnabled: boolean;
  40379. }
  40380. }
  40381. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40382. import { Scene } from "babylonjs/scene";
  40383. import { Texture } from "babylonjs/Materials/Textures/texture";
  40384. /**
  40385. * A class extending Texture allowing drawing on a texture
  40386. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40387. */
  40388. export class DynamicTexture extends Texture {
  40389. private _generateMipMaps;
  40390. private _canvas;
  40391. private _context;
  40392. private _engine;
  40393. /**
  40394. * Creates a DynamicTexture
  40395. * @param name defines the name of the texture
  40396. * @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
  40397. * @param scene defines the scene where you want the texture
  40398. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40399. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40400. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40401. */
  40402. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40403. /**
  40404. * Get the current class name of the texture useful for serialization or dynamic coding.
  40405. * @returns "DynamicTexture"
  40406. */
  40407. getClassName(): string;
  40408. /**
  40409. * Gets the current state of canRescale
  40410. */
  40411. readonly canRescale: boolean;
  40412. private _recreate;
  40413. /**
  40414. * Scales the texture
  40415. * @param ratio the scale factor to apply to both width and height
  40416. */
  40417. scale(ratio: number): void;
  40418. /**
  40419. * Resizes the texture
  40420. * @param width the new width
  40421. * @param height the new height
  40422. */
  40423. scaleTo(width: number, height: number): void;
  40424. /**
  40425. * Gets the context of the canvas used by the texture
  40426. * @returns the canvas context of the dynamic texture
  40427. */
  40428. getContext(): CanvasRenderingContext2D;
  40429. /**
  40430. * Clears the texture
  40431. */
  40432. clear(): void;
  40433. /**
  40434. * Updates the texture
  40435. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40436. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40437. */
  40438. update(invertY?: boolean, premulAlpha?: boolean): void;
  40439. /**
  40440. * Draws text onto the texture
  40441. * @param text defines the text to be drawn
  40442. * @param x defines the placement of the text from the left
  40443. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40444. * @param font defines the font to be used with font-style, font-size, font-name
  40445. * @param color defines the color used for the text
  40446. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40447. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40448. * @param update defines whether texture is immediately update (default is true)
  40449. */
  40450. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40451. /**
  40452. * Clones the texture
  40453. * @returns the clone of the texture.
  40454. */
  40455. clone(): DynamicTexture;
  40456. /**
  40457. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40458. * @returns a serialized dynamic texture object
  40459. */
  40460. serialize(): any;
  40461. /** @hidden */
  40462. _rebuild(): void;
  40463. }
  40464. }
  40465. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40466. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40467. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40468. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40469. /** @hidden */
  40470. export var imageProcessingPixelShader: {
  40471. name: string;
  40472. shader: string;
  40473. };
  40474. }
  40475. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40476. import { Nullable } from "babylonjs/types";
  40477. import { Color4 } from "babylonjs/Maths/math";
  40478. import { Camera } from "babylonjs/Cameras/camera";
  40479. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40480. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40481. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40482. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40483. import { Engine } from "babylonjs/Engines/engine";
  40484. import "babylonjs/Shaders/imageProcessing.fragment";
  40485. import "babylonjs/Shaders/postprocess.vertex";
  40486. /**
  40487. * ImageProcessingPostProcess
  40488. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40489. */
  40490. export class ImageProcessingPostProcess extends PostProcess {
  40491. /**
  40492. * Default configuration related to image processing available in the PBR Material.
  40493. */
  40494. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40495. /**
  40496. * Gets the image processing configuration used either in this material.
  40497. */
  40498. /**
  40499. * Sets the Default image processing configuration used either in the this material.
  40500. *
  40501. * If sets to null, the scene one is in use.
  40502. */
  40503. imageProcessingConfiguration: ImageProcessingConfiguration;
  40504. /**
  40505. * Keep track of the image processing observer to allow dispose and replace.
  40506. */
  40507. private _imageProcessingObserver;
  40508. /**
  40509. * Attaches a new image processing configuration to the PBR Material.
  40510. * @param configuration
  40511. */
  40512. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40513. /**
  40514. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40515. */
  40516. /**
  40517. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40518. */
  40519. colorCurves: Nullable<ColorCurves>;
  40520. /**
  40521. * Gets wether the color curves effect is enabled.
  40522. */
  40523. /**
  40524. * Sets wether the color curves effect is enabled.
  40525. */
  40526. colorCurvesEnabled: boolean;
  40527. /**
  40528. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40529. */
  40530. /**
  40531. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40532. */
  40533. colorGradingTexture: Nullable<BaseTexture>;
  40534. /**
  40535. * Gets wether the color grading effect is enabled.
  40536. */
  40537. /**
  40538. * Gets wether the color grading effect is enabled.
  40539. */
  40540. colorGradingEnabled: boolean;
  40541. /**
  40542. * Gets exposure used in the effect.
  40543. */
  40544. /**
  40545. * Sets exposure used in the effect.
  40546. */
  40547. exposure: number;
  40548. /**
  40549. * Gets wether tonemapping is enabled or not.
  40550. */
  40551. /**
  40552. * Sets wether tonemapping is enabled or not
  40553. */
  40554. toneMappingEnabled: boolean;
  40555. /**
  40556. * Gets the type of tone mapping effect.
  40557. */
  40558. /**
  40559. * Sets the type of tone mapping effect.
  40560. */
  40561. toneMappingType: number;
  40562. /**
  40563. * Gets contrast used in the effect.
  40564. */
  40565. /**
  40566. * Sets contrast used in the effect.
  40567. */
  40568. contrast: number;
  40569. /**
  40570. * Gets Vignette stretch size.
  40571. */
  40572. /**
  40573. * Sets Vignette stretch size.
  40574. */
  40575. vignetteStretch: number;
  40576. /**
  40577. * Gets Vignette centre X Offset.
  40578. */
  40579. /**
  40580. * Sets Vignette centre X Offset.
  40581. */
  40582. vignetteCentreX: number;
  40583. /**
  40584. * Gets Vignette centre Y Offset.
  40585. */
  40586. /**
  40587. * Sets Vignette centre Y Offset.
  40588. */
  40589. vignetteCentreY: number;
  40590. /**
  40591. * Gets Vignette weight or intensity of the vignette effect.
  40592. */
  40593. /**
  40594. * Sets Vignette weight or intensity of the vignette effect.
  40595. */
  40596. vignetteWeight: number;
  40597. /**
  40598. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40599. * if vignetteEnabled is set to true.
  40600. */
  40601. /**
  40602. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40603. * if vignetteEnabled is set to true.
  40604. */
  40605. vignetteColor: Color4;
  40606. /**
  40607. * Gets Camera field of view used by the Vignette effect.
  40608. */
  40609. /**
  40610. * Sets Camera field of view used by the Vignette effect.
  40611. */
  40612. vignetteCameraFov: number;
  40613. /**
  40614. * Gets the vignette blend mode allowing different kind of effect.
  40615. */
  40616. /**
  40617. * Sets the vignette blend mode allowing different kind of effect.
  40618. */
  40619. vignetteBlendMode: number;
  40620. /**
  40621. * Gets wether the vignette effect is enabled.
  40622. */
  40623. /**
  40624. * Sets wether the vignette effect is enabled.
  40625. */
  40626. vignetteEnabled: boolean;
  40627. private _fromLinearSpace;
  40628. /**
  40629. * Gets wether the input of the processing is in Gamma or Linear Space.
  40630. */
  40631. /**
  40632. * Sets wether the input of the processing is in Gamma or Linear Space.
  40633. */
  40634. fromLinearSpace: boolean;
  40635. /**
  40636. * Defines cache preventing GC.
  40637. */
  40638. private _defines;
  40639. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40640. /**
  40641. * "ImageProcessingPostProcess"
  40642. * @returns "ImageProcessingPostProcess"
  40643. */
  40644. getClassName(): string;
  40645. protected _updateParameters(): void;
  40646. dispose(camera?: Camera): void;
  40647. }
  40648. }
  40649. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40650. import { Scene } from "babylonjs/scene";
  40651. import { Color3 } from "babylonjs/Maths/math";
  40652. import { Mesh } from "babylonjs/Meshes/mesh";
  40653. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40654. import { Nullable } from "babylonjs/types";
  40655. /**
  40656. * Class containing static functions to help procedurally build meshes
  40657. */
  40658. export class GroundBuilder {
  40659. /**
  40660. * Creates a ground mesh
  40661. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40662. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40664. * @param name defines the name of the mesh
  40665. * @param options defines the options used to create the mesh
  40666. * @param scene defines the hosting scene
  40667. * @returns the ground mesh
  40668. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40669. */
  40670. static CreateGround(name: string, options: {
  40671. width?: number;
  40672. height?: number;
  40673. subdivisions?: number;
  40674. subdivisionsX?: number;
  40675. subdivisionsY?: number;
  40676. updatable?: boolean;
  40677. }, scene: any): Mesh;
  40678. /**
  40679. * Creates a tiled ground mesh
  40680. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40681. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40682. * * 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
  40683. * * 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
  40684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40685. * @param name defines the name of the mesh
  40686. * @param options defines the options used to create the mesh
  40687. * @param scene defines the hosting scene
  40688. * @returns the tiled ground mesh
  40689. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40690. */
  40691. static CreateTiledGround(name: string, options: {
  40692. xmin: number;
  40693. zmin: number;
  40694. xmax: number;
  40695. zmax: number;
  40696. subdivisions?: {
  40697. w: number;
  40698. h: number;
  40699. };
  40700. precision?: {
  40701. w: number;
  40702. h: number;
  40703. };
  40704. updatable?: boolean;
  40705. }, scene?: Nullable<Scene>): Mesh;
  40706. /**
  40707. * Creates a ground mesh from a height map
  40708. * * The parameter `url` sets the URL of the height map image resource.
  40709. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40710. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40711. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40712. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40713. * * 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.
  40714. * * 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).
  40715. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40717. * @param name defines the name of the mesh
  40718. * @param url defines the url to the height map
  40719. * @param options defines the options used to create the mesh
  40720. * @param scene defines the hosting scene
  40721. * @returns the ground mesh
  40722. * @see https://doc.babylonjs.com/babylon101/height_map
  40723. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40724. */
  40725. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40726. width?: number;
  40727. height?: number;
  40728. subdivisions?: number;
  40729. minHeight?: number;
  40730. maxHeight?: number;
  40731. colorFilter?: Color3;
  40732. alphaFilter?: number;
  40733. updatable?: boolean;
  40734. onReady?: (mesh: GroundMesh) => void;
  40735. }, scene?: Nullable<Scene>): GroundMesh;
  40736. }
  40737. }
  40738. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40739. import { Vector4 } from "babylonjs/Maths/math";
  40740. import { Mesh } from "babylonjs/Meshes/mesh";
  40741. /**
  40742. * Class containing static functions to help procedurally build meshes
  40743. */
  40744. export class TorusBuilder {
  40745. /**
  40746. * Creates a torus mesh
  40747. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40748. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40749. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40753. * @param name defines the name of the mesh
  40754. * @param options defines the options used to create the mesh
  40755. * @param scene defines the hosting scene
  40756. * @returns the torus mesh
  40757. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40758. */
  40759. static CreateTorus(name: string, options: {
  40760. diameter?: number;
  40761. thickness?: number;
  40762. tessellation?: number;
  40763. updatable?: boolean;
  40764. sideOrientation?: number;
  40765. frontUVs?: Vector4;
  40766. backUVs?: Vector4;
  40767. }, scene: any): Mesh;
  40768. }
  40769. }
  40770. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40771. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40772. import { Mesh } from "babylonjs/Meshes/mesh";
  40773. /**
  40774. * Class containing static functions to help procedurally build meshes
  40775. */
  40776. export class CylinderBuilder {
  40777. /**
  40778. * Creates a cylinder or a cone mesh
  40779. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40780. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40781. * * 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.
  40782. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40783. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40784. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40785. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40786. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40787. * * 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).
  40788. * * 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
  40789. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40790. * * 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
  40791. * * 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.
  40792. * * If `enclose` is false, a ring surface is one element.
  40793. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40794. * * 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
  40795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40796. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40798. * @param name defines the name of the mesh
  40799. * @param options defines the options used to create the mesh
  40800. * @param scene defines the hosting scene
  40801. * @returns the cylinder mesh
  40802. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40803. */
  40804. static CreateCylinder(name: string, options: {
  40805. height?: number;
  40806. diameterTop?: number;
  40807. diameterBottom?: number;
  40808. diameter?: number;
  40809. tessellation?: number;
  40810. subdivisions?: number;
  40811. arc?: number;
  40812. faceColors?: Color4[];
  40813. faceUV?: Vector4[];
  40814. updatable?: boolean;
  40815. hasRings?: boolean;
  40816. enclose?: boolean;
  40817. sideOrientation?: number;
  40818. frontUVs?: Vector4;
  40819. backUVs?: Vector4;
  40820. }, scene: any): Mesh;
  40821. }
  40822. }
  40823. declare module "babylonjs/Gamepads/gamepadManager" {
  40824. import { Observable } from "babylonjs/Misc/observable";
  40825. import { Nullable } from "babylonjs/types";
  40826. import { Scene } from "babylonjs/scene";
  40827. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40828. /**
  40829. * Manager for handling gamepads
  40830. */
  40831. export class GamepadManager {
  40832. private _scene?;
  40833. private _babylonGamepads;
  40834. private _oneGamepadConnected;
  40835. /** @hidden */
  40836. _isMonitoring: boolean;
  40837. private _gamepadEventSupported;
  40838. private _gamepadSupport;
  40839. /**
  40840. * observable to be triggered when the gamepad controller has been connected
  40841. */
  40842. onGamepadConnectedObservable: Observable<Gamepad>;
  40843. /**
  40844. * observable to be triggered when the gamepad controller has been disconnected
  40845. */
  40846. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40847. private _onGamepadConnectedEvent;
  40848. private _onGamepadDisconnectedEvent;
  40849. /**
  40850. * Initializes the gamepad manager
  40851. * @param _scene BabylonJS scene
  40852. */
  40853. constructor(_scene?: Scene | undefined);
  40854. /**
  40855. * The gamepads in the game pad manager
  40856. */
  40857. readonly gamepads: Gamepad[];
  40858. /**
  40859. * Get the gamepad controllers based on type
  40860. * @param type The type of gamepad controller
  40861. * @returns Nullable gamepad
  40862. */
  40863. getGamepadByType(type?: number): Nullable<Gamepad>;
  40864. /**
  40865. * Disposes the gamepad manager
  40866. */
  40867. dispose(): void;
  40868. private _addNewGamepad;
  40869. private _startMonitoringGamepads;
  40870. private _stopMonitoringGamepads;
  40871. /** @hidden */
  40872. _checkGamepadsStatus(): void;
  40873. private _updateGamepadObjects;
  40874. }
  40875. }
  40876. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40877. import { Nullable } from "babylonjs/types";
  40878. import { Scene } from "babylonjs/scene";
  40879. import { ISceneComponent } from "babylonjs/sceneComponent";
  40880. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40881. module "babylonjs/scene" {
  40882. interface Scene {
  40883. /** @hidden */
  40884. _gamepadManager: Nullable<GamepadManager>;
  40885. /**
  40886. * Gets the gamepad manager associated with the scene
  40887. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40888. */
  40889. gamepadManager: GamepadManager;
  40890. }
  40891. }
  40892. module "babylonjs/Cameras/freeCameraInputsManager" {
  40893. /**
  40894. * Interface representing a free camera inputs manager
  40895. */
  40896. interface FreeCameraInputsManager {
  40897. /**
  40898. * Adds gamepad input support to the FreeCameraInputsManager.
  40899. * @returns the FreeCameraInputsManager
  40900. */
  40901. addGamepad(): FreeCameraInputsManager;
  40902. }
  40903. }
  40904. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40905. /**
  40906. * Interface representing an arc rotate camera inputs manager
  40907. */
  40908. interface ArcRotateCameraInputsManager {
  40909. /**
  40910. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40911. * @returns the camera inputs manager
  40912. */
  40913. addGamepad(): ArcRotateCameraInputsManager;
  40914. }
  40915. }
  40916. /**
  40917. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40918. */
  40919. export class GamepadSystemSceneComponent implements ISceneComponent {
  40920. /**
  40921. * The component name helpfull to identify the component in the list of scene components.
  40922. */
  40923. readonly name: string;
  40924. /**
  40925. * The scene the component belongs to.
  40926. */
  40927. scene: Scene;
  40928. /**
  40929. * Creates a new instance of the component for the given scene
  40930. * @param scene Defines the scene to register the component in
  40931. */
  40932. constructor(scene: Scene);
  40933. /**
  40934. * Registers the component in a given scene
  40935. */
  40936. register(): void;
  40937. /**
  40938. * Rebuilds the elements related to this component in case of
  40939. * context lost for instance.
  40940. */
  40941. rebuild(): void;
  40942. /**
  40943. * Disposes the component and the associated ressources
  40944. */
  40945. dispose(): void;
  40946. private _beforeCameraUpdate;
  40947. }
  40948. }
  40949. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40950. import { Observable } from "babylonjs/Misc/observable";
  40951. import { Nullable } from "babylonjs/types";
  40952. import { Camera } from "babylonjs/Cameras/camera";
  40953. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40954. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40955. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40956. import { Scene } from "babylonjs/scene";
  40957. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40958. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40960. import { Mesh } from "babylonjs/Meshes/mesh";
  40961. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40962. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40963. import "babylonjs/Meshes/Builders/groundBuilder";
  40964. import "babylonjs/Meshes/Builders/torusBuilder";
  40965. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40966. import "babylonjs/Gamepads/gamepadSceneComponent";
  40967. import "babylonjs/Animations/animatable";
  40968. /**
  40969. * Options to modify the vr teleportation behavior.
  40970. */
  40971. export interface VRTeleportationOptions {
  40972. /**
  40973. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40974. */
  40975. floorMeshName?: string;
  40976. /**
  40977. * A list of meshes to be used as the teleportation floor. (default: empty)
  40978. */
  40979. floorMeshes?: Mesh[];
  40980. }
  40981. /**
  40982. * Options to modify the vr experience helper's behavior.
  40983. */
  40984. export interface VRExperienceHelperOptions extends WebVROptions {
  40985. /**
  40986. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40987. */
  40988. createDeviceOrientationCamera?: boolean;
  40989. /**
  40990. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40991. */
  40992. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40993. /**
  40994. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40995. */
  40996. laserToggle?: boolean;
  40997. /**
  40998. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40999. */
  41000. floorMeshes?: Mesh[];
  41001. /**
  41002. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41003. */
  41004. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41005. }
  41006. /**
  41007. * Event containing information after VR has been entered
  41008. */
  41009. export class OnAfterEnteringVRObservableEvent {
  41010. /**
  41011. * If entering vr was successful
  41012. */
  41013. success: boolean;
  41014. }
  41015. /**
  41016. * Helps to quickly add VR support to an existing scene.
  41017. * See http://doc.babylonjs.com/how_to/webvr_helper
  41018. */
  41019. export class VRExperienceHelper {
  41020. /** Options to modify the vr experience helper's behavior. */
  41021. webVROptions: VRExperienceHelperOptions;
  41022. private _scene;
  41023. private _position;
  41024. private _btnVR;
  41025. private _btnVRDisplayed;
  41026. private _webVRsupported;
  41027. private _webVRready;
  41028. private _webVRrequesting;
  41029. private _webVRpresenting;
  41030. private _hasEnteredVR;
  41031. private _fullscreenVRpresenting;
  41032. private _canvas;
  41033. private _webVRCamera;
  41034. private _vrDeviceOrientationCamera;
  41035. private _deviceOrientationCamera;
  41036. private _existingCamera;
  41037. private _onKeyDown;
  41038. private _onVrDisplayPresentChange;
  41039. private _onVRDisplayChanged;
  41040. private _onVRRequestPresentStart;
  41041. private _onVRRequestPresentComplete;
  41042. /**
  41043. * Observable raised right before entering VR.
  41044. */
  41045. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41046. /**
  41047. * Observable raised when entering VR has completed.
  41048. */
  41049. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41050. /**
  41051. * Observable raised when exiting VR.
  41052. */
  41053. onExitingVRObservable: Observable<VRExperienceHelper>;
  41054. /**
  41055. * Observable raised when controller mesh is loaded.
  41056. */
  41057. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41058. /** Return this.onEnteringVRObservable
  41059. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41060. */
  41061. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41062. /** Return this.onExitingVRObservable
  41063. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41064. */
  41065. readonly onExitingVR: Observable<VRExperienceHelper>;
  41066. /** Return this.onControllerMeshLoadedObservable
  41067. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41068. */
  41069. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41070. private _rayLength;
  41071. private _useCustomVRButton;
  41072. private _teleportationRequested;
  41073. private _teleportActive;
  41074. private _floorMeshName;
  41075. private _floorMeshesCollection;
  41076. private _rotationAllowed;
  41077. private _teleportBackwardsVector;
  41078. private _teleportationTarget;
  41079. private _isDefaultTeleportationTarget;
  41080. private _postProcessMove;
  41081. private _teleportationFillColor;
  41082. private _teleportationBorderColor;
  41083. private _rotationAngle;
  41084. private _haloCenter;
  41085. private _cameraGazer;
  41086. private _padSensibilityUp;
  41087. private _padSensibilityDown;
  41088. private _leftController;
  41089. private _rightController;
  41090. /**
  41091. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41092. */
  41093. onNewMeshSelected: Observable<AbstractMesh>;
  41094. /**
  41095. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41096. */
  41097. onNewMeshPicked: Observable<PickingInfo>;
  41098. private _circleEase;
  41099. /**
  41100. * Observable raised before camera teleportation
  41101. */
  41102. onBeforeCameraTeleport: Observable<Vector3>;
  41103. /**
  41104. * Observable raised after camera teleportation
  41105. */
  41106. onAfterCameraTeleport: Observable<Vector3>;
  41107. /**
  41108. * Observable raised when current selected mesh gets unselected
  41109. */
  41110. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41111. private _raySelectionPredicate;
  41112. /**
  41113. * To be optionaly changed by user to define custom ray selection
  41114. */
  41115. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41116. /**
  41117. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41118. */
  41119. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41120. /**
  41121. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41122. */
  41123. teleportationEnabled: boolean;
  41124. private _defaultHeight;
  41125. private _teleportationInitialized;
  41126. private _interactionsEnabled;
  41127. private _interactionsRequested;
  41128. private _displayGaze;
  41129. private _displayLaserPointer;
  41130. /**
  41131. * The mesh used to display where the user is going to teleport.
  41132. */
  41133. /**
  41134. * Sets the mesh to be used to display where the user is going to teleport.
  41135. */
  41136. teleportationTarget: Mesh;
  41137. /**
  41138. * 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
  41139. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41140. * See http://doc.babylonjs.com/resources/baking_transformations
  41141. */
  41142. gazeTrackerMesh: Mesh;
  41143. /**
  41144. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41145. */
  41146. updateGazeTrackerScale: boolean;
  41147. /**
  41148. * If the gaze trackers color should be updated when selecting meshes
  41149. */
  41150. updateGazeTrackerColor: boolean;
  41151. /**
  41152. * The gaze tracking mesh corresponding to the left controller
  41153. */
  41154. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41155. /**
  41156. * The gaze tracking mesh corresponding to the right controller
  41157. */
  41158. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41159. /**
  41160. * If the ray of the gaze should be displayed.
  41161. */
  41162. /**
  41163. * Sets if the ray of the gaze should be displayed.
  41164. */
  41165. displayGaze: boolean;
  41166. /**
  41167. * If the ray of the LaserPointer should be displayed.
  41168. */
  41169. /**
  41170. * Sets if the ray of the LaserPointer should be displayed.
  41171. */
  41172. displayLaserPointer: boolean;
  41173. /**
  41174. * The deviceOrientationCamera used as the camera when not in VR.
  41175. */
  41176. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41177. /**
  41178. * Based on the current WebVR support, returns the current VR camera used.
  41179. */
  41180. readonly currentVRCamera: Nullable<Camera>;
  41181. /**
  41182. * The webVRCamera which is used when in VR.
  41183. */
  41184. readonly webVRCamera: WebVRFreeCamera;
  41185. /**
  41186. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41187. */
  41188. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41189. private readonly _teleportationRequestInitiated;
  41190. /**
  41191. * Defines wether or not Pointer lock should be requested when switching to
  41192. * full screen.
  41193. */
  41194. requestPointerLockOnFullScreen: boolean;
  41195. /**
  41196. * Instantiates a VRExperienceHelper.
  41197. * Helps to quickly add VR support to an existing scene.
  41198. * @param scene The scene the VRExperienceHelper belongs to.
  41199. * @param webVROptions Options to modify the vr experience helper's behavior.
  41200. */
  41201. constructor(scene: Scene,
  41202. /** Options to modify the vr experience helper's behavior. */
  41203. webVROptions?: VRExperienceHelperOptions);
  41204. private _onDefaultMeshLoaded;
  41205. private _onResize;
  41206. private _onFullscreenChange;
  41207. /**
  41208. * Gets a value indicating if we are currently in VR mode.
  41209. */
  41210. readonly isInVRMode: boolean;
  41211. private onVrDisplayPresentChange;
  41212. private onVRDisplayChanged;
  41213. private moveButtonToBottomRight;
  41214. private displayVRButton;
  41215. private updateButtonVisibility;
  41216. private _cachedAngularSensibility;
  41217. /**
  41218. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41219. * Otherwise, will use the fullscreen API.
  41220. */
  41221. enterVR(): void;
  41222. /**
  41223. * Attempt to exit VR, or fullscreen.
  41224. */
  41225. exitVR(): void;
  41226. /**
  41227. * The position of the vr experience helper.
  41228. */
  41229. /**
  41230. * Sets the position of the vr experience helper.
  41231. */
  41232. position: Vector3;
  41233. /**
  41234. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41235. */
  41236. enableInteractions(): void;
  41237. private readonly _noControllerIsActive;
  41238. private beforeRender;
  41239. private _isTeleportationFloor;
  41240. /**
  41241. * Adds a floor mesh to be used for teleportation.
  41242. * @param floorMesh the mesh to be used for teleportation.
  41243. */
  41244. addFloorMesh(floorMesh: Mesh): void;
  41245. /**
  41246. * Removes a floor mesh from being used for teleportation.
  41247. * @param floorMesh the mesh to be removed.
  41248. */
  41249. removeFloorMesh(floorMesh: Mesh): void;
  41250. /**
  41251. * Enables interactions and teleportation using the VR controllers and gaze.
  41252. * @param vrTeleportationOptions options to modify teleportation behavior.
  41253. */
  41254. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41255. private _onNewGamepadConnected;
  41256. private _tryEnableInteractionOnController;
  41257. private _onNewGamepadDisconnected;
  41258. private _enableInteractionOnController;
  41259. private _checkTeleportWithRay;
  41260. private _checkRotate;
  41261. private _checkTeleportBackwards;
  41262. private _enableTeleportationOnController;
  41263. private _createTeleportationCircles;
  41264. private _displayTeleportationTarget;
  41265. private _hideTeleportationTarget;
  41266. private _rotateCamera;
  41267. private _moveTeleportationSelectorTo;
  41268. private _workingVector;
  41269. private _workingQuaternion;
  41270. private _workingMatrix;
  41271. /**
  41272. * Teleports the users feet to the desired location
  41273. * @param location The location where the user's feet should be placed
  41274. */
  41275. teleportCamera(location: Vector3): void;
  41276. private _convertNormalToDirectionOfRay;
  41277. private _castRayAndSelectObject;
  41278. private _notifySelectedMeshUnselected;
  41279. /**
  41280. * Sets the color of the laser ray from the vr controllers.
  41281. * @param color new color for the ray.
  41282. */
  41283. changeLaserColor(color: Color3): void;
  41284. /**
  41285. * Sets the color of the ray from the vr headsets gaze.
  41286. * @param color new color for the ray.
  41287. */
  41288. changeGazeColor(color: Color3): void;
  41289. /**
  41290. * Exits VR and disposes of the vr experience helper
  41291. */
  41292. dispose(): void;
  41293. /**
  41294. * Gets the name of the VRExperienceHelper class
  41295. * @returns "VRExperienceHelper"
  41296. */
  41297. getClassName(): string;
  41298. }
  41299. }
  41300. declare module "babylonjs/Cameras/VR/index" {
  41301. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41302. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41303. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41304. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41305. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41306. export * from "babylonjs/Cameras/VR/webVRCamera";
  41307. }
  41308. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41309. import { Observable } from "babylonjs/Misc/observable";
  41310. import { Nullable } from "babylonjs/types";
  41311. import { IDisposable, Scene } from "babylonjs/scene";
  41312. import { Vector3 } from "babylonjs/Maths/math";
  41313. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41314. import { Ray } from "babylonjs/Culling/ray";
  41315. /**
  41316. * Manages an XRSession
  41317. * @see https://doc.babylonjs.com/how_to/webxr
  41318. */
  41319. export class WebXRSessionManager implements IDisposable {
  41320. private scene;
  41321. /**
  41322. * Fires every time a new xrFrame arrives which can be used to update the camera
  41323. */
  41324. onXRFrameObservable: Observable<any>;
  41325. /**
  41326. * Fires when the xr session is ended either by the device or manually done
  41327. */
  41328. onXRSessionEnded: Observable<any>;
  41329. /** @hidden */
  41330. _xrSession: XRSession;
  41331. /** @hidden */
  41332. _frameOfReference: XRFrameOfReference;
  41333. /** @hidden */
  41334. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41335. /** @hidden */
  41336. _currentXRFrame: Nullable<XRFrame>;
  41337. private _xrNavigator;
  41338. private _xrDevice;
  41339. private _tmpMatrix;
  41340. /**
  41341. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41342. * @param scene The scene which the session should be created for
  41343. */
  41344. constructor(scene: Scene);
  41345. /**
  41346. * Initializes the manager
  41347. * After initialization enterXR can be called to start an XR session
  41348. * @returns Promise which resolves after it is initialized
  41349. */
  41350. initializeAsync(): Promise<void>;
  41351. /**
  41352. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41353. * @param sessionCreationOptions xr options to create the session with
  41354. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41355. * @returns Promise which resolves after it enters XR
  41356. */
  41357. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41358. /**
  41359. * Stops the xrSession and restores the renderloop
  41360. * @returns Promise which resolves after it exits XR
  41361. */
  41362. exitXRAsync(): Promise<void>;
  41363. /**
  41364. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41365. * @param ray ray to cast into the environment
  41366. * @returns Promise which resolves with a collision point in the environment if it exists
  41367. */
  41368. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41369. /**
  41370. * Checks if a session would be supported for the creation options specified
  41371. * @param options creation options to check if they are supported
  41372. * @returns true if supported
  41373. */
  41374. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41375. /**
  41376. * @hidden
  41377. * Converts the render layer of xrSession to a render target
  41378. * @param session session to create render target for
  41379. * @param scene scene the new render target should be created for
  41380. */
  41381. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41382. /**
  41383. * Disposes of the session manager
  41384. */
  41385. dispose(): void;
  41386. }
  41387. }
  41388. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41389. import { Scene } from "babylonjs/scene";
  41390. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41391. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41392. /**
  41393. * WebXR Camera which holds the views for the xrSession
  41394. * @see https://doc.babylonjs.com/how_to/webxr
  41395. */
  41396. export class WebXRCamera extends FreeCamera {
  41397. private static _TmpMatrix;
  41398. /**
  41399. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41400. * @param name the name of the camera
  41401. * @param scene the scene to add the camera to
  41402. */
  41403. constructor(name: string, scene: Scene);
  41404. private _updateNumberOfRigCameras;
  41405. /** @hidden */
  41406. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41407. /**
  41408. * Updates the cameras position from the current pose information of the XR session
  41409. * @param xrSessionManager the session containing pose information
  41410. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41411. */
  41412. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41413. }
  41414. }
  41415. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41416. import { Nullable } from "babylonjs/types";
  41417. import { Observable } from "babylonjs/Misc/observable";
  41418. import { IDisposable, Scene } from "babylonjs/scene";
  41419. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41421. import { Ray } from "babylonjs/Culling/ray";
  41422. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41423. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41424. /**
  41425. * States of the webXR experience
  41426. */
  41427. export enum WebXRState {
  41428. /**
  41429. * Transitioning to being in XR mode
  41430. */
  41431. ENTERING_XR = 0,
  41432. /**
  41433. * Transitioning to non XR mode
  41434. */
  41435. EXITING_XR = 1,
  41436. /**
  41437. * In XR mode and presenting
  41438. */
  41439. IN_XR = 2,
  41440. /**
  41441. * Not entered XR mode
  41442. */
  41443. NOT_IN_XR = 3
  41444. }
  41445. /**
  41446. * Helper class used to enable XR
  41447. * @see https://doc.babylonjs.com/how_to/webxr
  41448. */
  41449. export class WebXRExperienceHelper implements IDisposable {
  41450. private scene;
  41451. /**
  41452. * 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
  41453. */
  41454. container: AbstractMesh;
  41455. /**
  41456. * Camera used to render xr content
  41457. */
  41458. camera: WebXRCamera;
  41459. /**
  41460. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41461. */
  41462. state: WebXRState;
  41463. private _setState;
  41464. private static _TmpVector;
  41465. /**
  41466. * Fires when the state of the experience helper has changed
  41467. */
  41468. onStateChangedObservable: Observable<WebXRState>;
  41469. /** @hidden */
  41470. _sessionManager: WebXRSessionManager;
  41471. private _nonVRCamera;
  41472. private _originalSceneAutoClear;
  41473. private _supported;
  41474. /**
  41475. * Creates the experience helper
  41476. * @param scene the scene to attach the experience helper to
  41477. * @returns a promise for the experience helper
  41478. */
  41479. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41480. /**
  41481. * Creates a WebXRExperienceHelper
  41482. * @param scene The scene the helper should be created in
  41483. */
  41484. private constructor();
  41485. /**
  41486. * Exits XR mode and returns the scene to its original state
  41487. * @returns promise that resolves after xr mode has exited
  41488. */
  41489. exitXRAsync(): Promise<void>;
  41490. /**
  41491. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41492. * @param sessionCreationOptions options for the XR session
  41493. * @param frameOfReference frame of reference of the XR session
  41494. * @returns promise that resolves after xr mode has entered
  41495. */
  41496. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41497. /**
  41498. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41499. * @param ray ray to cast into the environment
  41500. * @returns Promise which resolves with a collision point in the environment if it exists
  41501. */
  41502. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41503. /**
  41504. * Updates the global position of the camera by moving the camera's container
  41505. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41506. * @param position The desired global position of the camera
  41507. */
  41508. setPositionOfCameraUsingContainer(position: Vector3): void;
  41509. /**
  41510. * Rotates the xr camera by rotating the camera's container around the camera's position
  41511. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41512. * @param rotation the desired quaternion rotation to apply to the camera
  41513. */
  41514. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41515. /**
  41516. * Checks if the creation options are supported by the xr session
  41517. * @param options creation options
  41518. * @returns true if supported
  41519. */
  41520. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41521. /**
  41522. * Disposes of the experience helper
  41523. */
  41524. dispose(): void;
  41525. }
  41526. }
  41527. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41528. import { Nullable } from "babylonjs/types";
  41529. import { Observable } from "babylonjs/Misc/observable";
  41530. import { IDisposable, Scene } from "babylonjs/scene";
  41531. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41532. /**
  41533. * Button which can be used to enter a different mode of XR
  41534. */
  41535. export class WebXREnterExitUIButton {
  41536. /** button element */
  41537. element: HTMLElement;
  41538. /** XR initialization options for the button */
  41539. initializationOptions: XRSessionCreationOptions;
  41540. /**
  41541. * Creates a WebXREnterExitUIButton
  41542. * @param element button element
  41543. * @param initializationOptions XR initialization options for the button
  41544. */
  41545. constructor(
  41546. /** button element */
  41547. element: HTMLElement,
  41548. /** XR initialization options for the button */
  41549. initializationOptions: XRSessionCreationOptions);
  41550. /**
  41551. * Overwritable function which can be used to update the button's visuals when the state changes
  41552. * @param activeButton the current active button in the UI
  41553. */
  41554. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41555. }
  41556. /**
  41557. * Options to create the webXR UI
  41558. */
  41559. export class WebXREnterExitUIOptions {
  41560. /**
  41561. * Context to enter xr with
  41562. */
  41563. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41564. /**
  41565. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41566. */
  41567. customButtons?: Array<WebXREnterExitUIButton>;
  41568. }
  41569. /**
  41570. * UI to allow the user to enter/exit XR mode
  41571. */
  41572. export class WebXREnterExitUI implements IDisposable {
  41573. private scene;
  41574. private _overlay;
  41575. private _buttons;
  41576. private _activeButton;
  41577. /**
  41578. * Fired every time the active button is changed.
  41579. *
  41580. * When xr is entered via a button that launches xr that button will be the callback parameter
  41581. *
  41582. * When exiting xr the callback parameter will be null)
  41583. */
  41584. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41585. /**
  41586. * Creates UI to allow the user to enter/exit XR mode
  41587. * @param scene the scene to add the ui to
  41588. * @param helper the xr experience helper to enter/exit xr with
  41589. * @param options options to configure the UI
  41590. * @returns the created ui
  41591. */
  41592. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41593. private constructor();
  41594. private _updateButtons;
  41595. /**
  41596. * Disposes of the object
  41597. */
  41598. dispose(): void;
  41599. }
  41600. }
  41601. declare module "babylonjs/Cameras/XR/webXRInput" {
  41602. import { IDisposable, Scene } from "babylonjs/scene";
  41603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41604. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41605. /**
  41606. * Represents an XR input
  41607. */
  41608. export class WebXRController {
  41609. /**
  41610. * 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
  41611. */
  41612. grip?: AbstractMesh;
  41613. /**
  41614. * Pointer which can be used to select objects or attach a visible laser to
  41615. */
  41616. pointer: AbstractMesh;
  41617. /**
  41618. * Creates the controller
  41619. * @see https://doc.babylonjs.com/how_to/webxr
  41620. * @param scene the scene which the controller should be associated to
  41621. */
  41622. constructor(scene: Scene);
  41623. /**
  41624. * Disposes of the object
  41625. */
  41626. dispose(): void;
  41627. }
  41628. /**
  41629. * XR input used to track XR inputs such as controllers/rays
  41630. */
  41631. export class WebXRInput implements IDisposable {
  41632. private helper;
  41633. /**
  41634. * XR controllers being tracked
  41635. */
  41636. controllers: Array<WebXRController>;
  41637. private _tmpMatrix;
  41638. private _frameObserver;
  41639. /**
  41640. * Initializes the WebXRInput
  41641. * @param helper experience helper which the input should be created for
  41642. */
  41643. constructor(helper: WebXRExperienceHelper);
  41644. /**
  41645. * Disposes of the object
  41646. */
  41647. dispose(): void;
  41648. }
  41649. }
  41650. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41651. import { Nullable } from "babylonjs/types";
  41652. import { IDisposable } from "babylonjs/scene";
  41653. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41654. /**
  41655. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41656. */
  41657. export class WebXRManagedOutputCanvas implements IDisposable {
  41658. private _canvas;
  41659. /**
  41660. * xrpresent context of the canvas which can be used to display/mirror xr content
  41661. */
  41662. canvasContext: Nullable<WebGLRenderingContext>;
  41663. /**
  41664. * Initializes the canvas to be added/removed upon entering/exiting xr
  41665. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41666. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41667. */
  41668. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41669. /**
  41670. * Disposes of the object
  41671. */
  41672. dispose(): void;
  41673. private _setManagedOutputCanvas;
  41674. private _addCanvas;
  41675. private _removeCanvas;
  41676. }
  41677. }
  41678. declare module "babylonjs/Cameras/XR/index" {
  41679. export * from "babylonjs/Cameras/XR/webXRCamera";
  41680. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41681. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41682. export * from "babylonjs/Cameras/XR/webXRInput";
  41683. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41684. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41685. }
  41686. declare module "babylonjs/Cameras/RigModes/index" {
  41687. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41688. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41689. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41690. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41691. }
  41692. declare module "babylonjs/Cameras/index" {
  41693. export * from "babylonjs/Cameras/Inputs/index";
  41694. export * from "babylonjs/Cameras/cameraInputsManager";
  41695. export * from "babylonjs/Cameras/camera";
  41696. export * from "babylonjs/Cameras/targetCamera";
  41697. export * from "babylonjs/Cameras/freeCamera";
  41698. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41699. export * from "babylonjs/Cameras/touchCamera";
  41700. export * from "babylonjs/Cameras/arcRotateCamera";
  41701. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41702. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41703. export * from "babylonjs/Cameras/flyCamera";
  41704. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41705. export * from "babylonjs/Cameras/followCamera";
  41706. export * from "babylonjs/Cameras/gamepadCamera";
  41707. export * from "babylonjs/Cameras/Stereoscopic/index";
  41708. export * from "babylonjs/Cameras/universalCamera";
  41709. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41710. export * from "babylonjs/Cameras/VR/index";
  41711. export * from "babylonjs/Cameras/XR/index";
  41712. export * from "babylonjs/Cameras/RigModes/index";
  41713. }
  41714. declare module "babylonjs/Collisions/index" {
  41715. export * from "babylonjs/Collisions/collider";
  41716. export * from "babylonjs/Collisions/collisionCoordinator";
  41717. export * from "babylonjs/Collisions/pickingInfo";
  41718. export * from "babylonjs/Collisions/intersectionInfo";
  41719. }
  41720. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41721. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41722. import { Vector3, Plane } from "babylonjs/Maths/math";
  41723. import { Ray } from "babylonjs/Culling/ray";
  41724. /**
  41725. * Contains an array of blocks representing the octree
  41726. */
  41727. export interface IOctreeContainer<T> {
  41728. /**
  41729. * Blocks within the octree
  41730. */
  41731. blocks: Array<OctreeBlock<T>>;
  41732. }
  41733. /**
  41734. * Class used to store a cell in an octree
  41735. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41736. */
  41737. export class OctreeBlock<T> {
  41738. /**
  41739. * Gets the content of the current block
  41740. */
  41741. entries: T[];
  41742. /**
  41743. * Gets the list of block children
  41744. */
  41745. blocks: Array<OctreeBlock<T>>;
  41746. private _depth;
  41747. private _maxDepth;
  41748. private _capacity;
  41749. private _minPoint;
  41750. private _maxPoint;
  41751. private _boundingVectors;
  41752. private _creationFunc;
  41753. /**
  41754. * Creates a new block
  41755. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41756. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41757. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41758. * @param depth defines the current depth of this block in the octree
  41759. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41760. * @param creationFunc defines a callback to call when an element is added to the block
  41761. */
  41762. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41763. /**
  41764. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41765. */
  41766. readonly capacity: number;
  41767. /**
  41768. * Gets the minimum vector (in world space) of the block's bounding box
  41769. */
  41770. readonly minPoint: Vector3;
  41771. /**
  41772. * Gets the maximum vector (in world space) of the block's bounding box
  41773. */
  41774. readonly maxPoint: Vector3;
  41775. /**
  41776. * Add a new element to this block
  41777. * @param entry defines the element to add
  41778. */
  41779. addEntry(entry: T): void;
  41780. /**
  41781. * Remove an element from this block
  41782. * @param entry defines the element to remove
  41783. */
  41784. removeEntry(entry: T): void;
  41785. /**
  41786. * Add an array of elements to this block
  41787. * @param entries defines the array of elements to add
  41788. */
  41789. addEntries(entries: T[]): void;
  41790. /**
  41791. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41792. * @param frustumPlanes defines the frustum planes to test
  41793. * @param selection defines the array to store current content if selection is positive
  41794. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41795. */
  41796. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41797. /**
  41798. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41799. * @param sphereCenter defines the bounding sphere center
  41800. * @param sphereRadius defines the bounding sphere radius
  41801. * @param selection defines the array to store current content if selection is positive
  41802. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41803. */
  41804. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41805. /**
  41806. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41807. * @param ray defines the ray to test with
  41808. * @param selection defines the array to store current content if selection is positive
  41809. */
  41810. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41811. /**
  41812. * Subdivide the content into child blocks (this block will then be empty)
  41813. */
  41814. createInnerBlocks(): void;
  41815. /**
  41816. * @hidden
  41817. */
  41818. 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;
  41819. }
  41820. }
  41821. declare module "babylonjs/Culling/Octrees/octree" {
  41822. import { SmartArray } from "babylonjs/Misc/smartArray";
  41823. import { Vector3, Plane } from "babylonjs/Maths/math";
  41824. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41826. import { Ray } from "babylonjs/Culling/ray";
  41827. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41828. /**
  41829. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41830. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41831. */
  41832. export class Octree<T> {
  41833. /** 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.) */
  41834. maxDepth: number;
  41835. /**
  41836. * Blocks within the octree containing objects
  41837. */
  41838. blocks: Array<OctreeBlock<T>>;
  41839. /**
  41840. * Content stored in the octree
  41841. */
  41842. dynamicContent: T[];
  41843. private _maxBlockCapacity;
  41844. private _selectionContent;
  41845. private _creationFunc;
  41846. /**
  41847. * Creates a octree
  41848. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41849. * @param creationFunc function to be used to instatiate the octree
  41850. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41851. * @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.)
  41852. */
  41853. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41854. /** 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.) */
  41855. maxDepth?: number);
  41856. /**
  41857. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41858. * @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);
  41859. * @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);
  41860. * @param entries meshes to be added to the octree blocks
  41861. */
  41862. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41863. /**
  41864. * Adds a mesh to the octree
  41865. * @param entry Mesh to add to the octree
  41866. */
  41867. addMesh(entry: T): void;
  41868. /**
  41869. * Remove an element from the octree
  41870. * @param entry defines the element to remove
  41871. */
  41872. removeMesh(entry: T): void;
  41873. /**
  41874. * Selects an array of meshes within the frustum
  41875. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41876. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41877. * @returns array of meshes within the frustum
  41878. */
  41879. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41880. /**
  41881. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41882. * @param sphereCenter defines the bounding sphere center
  41883. * @param sphereRadius defines the bounding sphere radius
  41884. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41885. * @returns an array of objects that intersect the sphere
  41886. */
  41887. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41888. /**
  41889. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41890. * @param ray defines the ray to test with
  41891. * @returns array of intersected objects
  41892. */
  41893. intersectsRay(ray: Ray): SmartArray<T>;
  41894. /**
  41895. * Adds a mesh into the octree block if it intersects the block
  41896. */
  41897. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41898. /**
  41899. * Adds a submesh into the octree block if it intersects the block
  41900. */
  41901. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41902. }
  41903. }
  41904. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41905. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41906. import { Scene } from "babylonjs/scene";
  41907. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41909. import { Ray } from "babylonjs/Culling/ray";
  41910. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41911. import { Collider } from "babylonjs/Collisions/collider";
  41912. module "babylonjs/scene" {
  41913. interface Scene {
  41914. /**
  41915. * @hidden
  41916. * Backing Filed
  41917. */
  41918. _selectionOctree: Octree<AbstractMesh>;
  41919. /**
  41920. * Gets the octree used to boost mesh selection (picking)
  41921. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41922. */
  41923. selectionOctree: Octree<AbstractMesh>;
  41924. /**
  41925. * Creates or updates the octree used to boost selection (picking)
  41926. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41927. * @param maxCapacity defines the maximum capacity per leaf
  41928. * @param maxDepth defines the maximum depth of the octree
  41929. * @returns an octree of AbstractMesh
  41930. */
  41931. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41932. }
  41933. }
  41934. module "babylonjs/Meshes/abstractMesh" {
  41935. interface AbstractMesh {
  41936. /**
  41937. * @hidden
  41938. * Backing Field
  41939. */
  41940. _submeshesOctree: Octree<SubMesh>;
  41941. /**
  41942. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41943. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41944. * @param maxCapacity defines the maximum size of each block (64 by default)
  41945. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41946. * @returns the new octree
  41947. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41948. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41949. */
  41950. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41951. }
  41952. }
  41953. /**
  41954. * Defines the octree scene component responsible to manage any octrees
  41955. * in a given scene.
  41956. */
  41957. export class OctreeSceneComponent {
  41958. /**
  41959. * The component name help to identify the component in the list of scene components.
  41960. */
  41961. readonly name: string;
  41962. /**
  41963. * The scene the component belongs to.
  41964. */
  41965. scene: Scene;
  41966. /**
  41967. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41968. */
  41969. readonly checksIsEnabled: boolean;
  41970. /**
  41971. * Creates a new instance of the component for the given scene
  41972. * @param scene Defines the scene to register the component in
  41973. */
  41974. constructor(scene: Scene);
  41975. /**
  41976. * Registers the component in a given scene
  41977. */
  41978. register(): void;
  41979. /**
  41980. * Return the list of active meshes
  41981. * @returns the list of active meshes
  41982. */
  41983. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41984. /**
  41985. * Return the list of active sub meshes
  41986. * @param mesh The mesh to get the candidates sub meshes from
  41987. * @returns the list of active sub meshes
  41988. */
  41989. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41990. private _tempRay;
  41991. /**
  41992. * Return the list of sub meshes intersecting with a given local ray
  41993. * @param mesh defines the mesh to find the submesh for
  41994. * @param localRay defines the ray in local space
  41995. * @returns the list of intersecting sub meshes
  41996. */
  41997. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41998. /**
  41999. * Return the list of sub meshes colliding with a collider
  42000. * @param mesh defines the mesh to find the submesh for
  42001. * @param collider defines the collider to evaluate the collision against
  42002. * @returns the list of colliding sub meshes
  42003. */
  42004. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42005. /**
  42006. * Rebuilds the elements related to this component in case of
  42007. * context lost for instance.
  42008. */
  42009. rebuild(): void;
  42010. /**
  42011. * Disposes the component and the associated ressources.
  42012. */
  42013. dispose(): void;
  42014. }
  42015. }
  42016. declare module "babylonjs/Culling/Octrees/index" {
  42017. export * from "babylonjs/Culling/Octrees/octree";
  42018. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42019. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42020. }
  42021. declare module "babylonjs/Culling/index" {
  42022. export * from "babylonjs/Culling/boundingBox";
  42023. export * from "babylonjs/Culling/boundingInfo";
  42024. export * from "babylonjs/Culling/boundingSphere";
  42025. export * from "babylonjs/Culling/Octrees/index";
  42026. export * from "babylonjs/Culling/ray";
  42027. }
  42028. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42029. import { IDisposable, Scene } from "babylonjs/scene";
  42030. import { Nullable } from "babylonjs/types";
  42031. import { Observable } from "babylonjs/Misc/observable";
  42032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42033. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42034. /**
  42035. * Renders a layer on top of an existing scene
  42036. */
  42037. export class UtilityLayerRenderer implements IDisposable {
  42038. /** the original scene that will be rendered on top of */
  42039. originalScene: Scene;
  42040. private _pointerCaptures;
  42041. private _lastPointerEvents;
  42042. private static _DefaultUtilityLayer;
  42043. private static _DefaultKeepDepthUtilityLayer;
  42044. private _sharedGizmoLight;
  42045. /**
  42046. * @hidden
  42047. * Light which used by gizmos to get light shading
  42048. */
  42049. _getSharedGizmoLight(): HemisphericLight;
  42050. /**
  42051. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42052. */
  42053. pickUtilitySceneFirst: boolean;
  42054. /**
  42055. * 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)
  42056. */
  42057. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42058. /**
  42059. * 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)
  42060. */
  42061. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42062. /**
  42063. * The scene that is rendered on top of the original scene
  42064. */
  42065. utilityLayerScene: Scene;
  42066. /**
  42067. * If the utility layer should automatically be rendered on top of existing scene
  42068. */
  42069. shouldRender: boolean;
  42070. /**
  42071. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42072. */
  42073. onlyCheckPointerDownEvents: boolean;
  42074. /**
  42075. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42076. */
  42077. processAllEvents: boolean;
  42078. /**
  42079. * Observable raised when the pointer move from the utility layer scene to the main scene
  42080. */
  42081. onPointerOutObservable: Observable<number>;
  42082. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42083. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42084. private _afterRenderObserver;
  42085. private _sceneDisposeObserver;
  42086. private _originalPointerObserver;
  42087. /**
  42088. * Instantiates a UtilityLayerRenderer
  42089. * @param originalScene the original scene that will be rendered on top of
  42090. * @param handleEvents boolean indicating if the utility layer should handle events
  42091. */
  42092. constructor(
  42093. /** the original scene that will be rendered on top of */
  42094. originalScene: Scene, handleEvents?: boolean);
  42095. private _notifyObservers;
  42096. /**
  42097. * Renders the utility layers scene on top of the original scene
  42098. */
  42099. render(): void;
  42100. /**
  42101. * Disposes of the renderer
  42102. */
  42103. dispose(): void;
  42104. private _updateCamera;
  42105. }
  42106. }
  42107. declare module "babylonjs/Gizmos/gizmo" {
  42108. import { Nullable } from "babylonjs/types";
  42109. import { IDisposable } from "babylonjs/scene";
  42110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42111. import { Mesh } from "babylonjs/Meshes/mesh";
  42112. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42113. /**
  42114. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42115. */
  42116. export class Gizmo implements IDisposable {
  42117. /** The utility layer the gizmo will be added to */
  42118. gizmoLayer: UtilityLayerRenderer;
  42119. /**
  42120. * The root mesh of the gizmo
  42121. */
  42122. _rootMesh: Mesh;
  42123. private _attachedMesh;
  42124. /**
  42125. * Ratio for the scale of the gizmo (Default: 1)
  42126. */
  42127. scaleRatio: number;
  42128. /**
  42129. * If a custom mesh has been set (Default: false)
  42130. */
  42131. protected _customMeshSet: boolean;
  42132. /**
  42133. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42134. * * When set, interactions will be enabled
  42135. */
  42136. attachedMesh: Nullable<AbstractMesh>;
  42137. /**
  42138. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42139. * @param mesh The mesh to replace the default mesh of the gizmo
  42140. */
  42141. setCustomMesh(mesh: Mesh): void;
  42142. /**
  42143. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42144. */
  42145. updateGizmoRotationToMatchAttachedMesh: boolean;
  42146. /**
  42147. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42148. */
  42149. updateGizmoPositionToMatchAttachedMesh: boolean;
  42150. /**
  42151. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42152. */
  42153. protected _updateScale: boolean;
  42154. protected _interactionsEnabled: boolean;
  42155. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42156. private _beforeRenderObserver;
  42157. private _tempVector;
  42158. /**
  42159. * Creates a gizmo
  42160. * @param gizmoLayer The utility layer the gizmo will be added to
  42161. */
  42162. constructor(
  42163. /** The utility layer the gizmo will be added to */
  42164. gizmoLayer?: UtilityLayerRenderer);
  42165. /**
  42166. * Updates the gizmo to match the attached mesh's position/rotation
  42167. */
  42168. protected _update(): void;
  42169. /**
  42170. * Disposes of the gizmo
  42171. */
  42172. dispose(): void;
  42173. }
  42174. }
  42175. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42176. import { Observable } from "babylonjs/Misc/observable";
  42177. import { Nullable } from "babylonjs/types";
  42178. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42179. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42181. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42182. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42183. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42184. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42185. import { Scene } from "babylonjs/scene";
  42186. /**
  42187. * Single axis drag gizmo
  42188. */
  42189. export class AxisDragGizmo extends Gizmo {
  42190. /**
  42191. * Drag behavior responsible for the gizmos dragging interactions
  42192. */
  42193. dragBehavior: PointerDragBehavior;
  42194. private _pointerObserver;
  42195. /**
  42196. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42197. */
  42198. snapDistance: number;
  42199. /**
  42200. * Event that fires each time the gizmo snaps to a new location.
  42201. * * snapDistance is the the change in distance
  42202. */
  42203. onSnapObservable: Observable<{
  42204. snapDistance: number;
  42205. }>;
  42206. /** @hidden */
  42207. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42208. /** @hidden */
  42209. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42210. /**
  42211. * Creates an AxisDragGizmo
  42212. * @param gizmoLayer The utility layer the gizmo will be added to
  42213. * @param dragAxis The axis which the gizmo will be able to drag on
  42214. * @param color The color of the gizmo
  42215. */
  42216. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42217. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42218. /**
  42219. * Disposes of the gizmo
  42220. */
  42221. dispose(): void;
  42222. }
  42223. }
  42224. declare module "babylonjs/Debug/axesViewer" {
  42225. import { Vector3 } from "babylonjs/Maths/math";
  42226. import { Nullable } from "babylonjs/types";
  42227. import { Scene } from "babylonjs/scene";
  42228. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42229. /**
  42230. * The Axes viewer will show 3 axes in a specific point in space
  42231. */
  42232. export class AxesViewer {
  42233. private _xAxis;
  42234. private _yAxis;
  42235. private _zAxis;
  42236. private _scaleLinesFactor;
  42237. private _instanced;
  42238. /**
  42239. * Gets the hosting scene
  42240. */
  42241. scene: Scene;
  42242. /**
  42243. * Gets or sets a number used to scale line length
  42244. */
  42245. scaleLines: number;
  42246. /** Gets the node hierarchy used to render x-axis */
  42247. readonly xAxis: TransformNode;
  42248. /** Gets the node hierarchy used to render y-axis */
  42249. readonly yAxis: TransformNode;
  42250. /** Gets the node hierarchy used to render z-axis */
  42251. readonly zAxis: TransformNode;
  42252. /**
  42253. * Creates a new AxesViewer
  42254. * @param scene defines the hosting scene
  42255. * @param scaleLines defines a number used to scale line length (1 by default)
  42256. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42257. * @param xAxis defines the node hierarchy used to render the x-axis
  42258. * @param yAxis defines the node hierarchy used to render the y-axis
  42259. * @param zAxis defines the node hierarchy used to render the z-axis
  42260. */
  42261. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42262. /**
  42263. * Force the viewer to update
  42264. * @param position defines the position of the viewer
  42265. * @param xaxis defines the x axis of the viewer
  42266. * @param yaxis defines the y axis of the viewer
  42267. * @param zaxis defines the z axis of the viewer
  42268. */
  42269. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42270. /**
  42271. * Creates an instance of this axes viewer.
  42272. * @returns a new axes viewer with instanced meshes
  42273. */
  42274. createInstance(): AxesViewer;
  42275. /** Releases resources */
  42276. dispose(): void;
  42277. private static _SetRenderingGroupId;
  42278. }
  42279. }
  42280. declare module "babylonjs/Debug/boneAxesViewer" {
  42281. import { Nullable } from "babylonjs/types";
  42282. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42283. import { Vector3 } from "babylonjs/Maths/math";
  42284. import { Mesh } from "babylonjs/Meshes/mesh";
  42285. import { Bone } from "babylonjs/Bones/bone";
  42286. import { Scene } from "babylonjs/scene";
  42287. /**
  42288. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42289. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42290. */
  42291. export class BoneAxesViewer extends AxesViewer {
  42292. /**
  42293. * Gets or sets the target mesh where to display the axes viewer
  42294. */
  42295. mesh: Nullable<Mesh>;
  42296. /**
  42297. * Gets or sets the target bone where to display the axes viewer
  42298. */
  42299. bone: Nullable<Bone>;
  42300. /** Gets current position */
  42301. pos: Vector3;
  42302. /** Gets direction of X axis */
  42303. xaxis: Vector3;
  42304. /** Gets direction of Y axis */
  42305. yaxis: Vector3;
  42306. /** Gets direction of Z axis */
  42307. zaxis: Vector3;
  42308. /**
  42309. * Creates a new BoneAxesViewer
  42310. * @param scene defines the hosting scene
  42311. * @param bone defines the target bone
  42312. * @param mesh defines the target mesh
  42313. * @param scaleLines defines a scaling factor for line length (1 by default)
  42314. */
  42315. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42316. /**
  42317. * Force the viewer to update
  42318. */
  42319. update(): void;
  42320. /** Releases resources */
  42321. dispose(): void;
  42322. }
  42323. }
  42324. declare module "babylonjs/Debug/debugLayer" {
  42325. import { Observable } from "babylonjs/Misc/observable";
  42326. import { Scene } from "babylonjs/scene";
  42327. /**
  42328. * Interface used to define scene explorer extensibility option
  42329. */
  42330. export interface IExplorerExtensibilityOption {
  42331. /**
  42332. * Define the option label
  42333. */
  42334. label: string;
  42335. /**
  42336. * Defines the action to execute on click
  42337. */
  42338. action: (entity: any) => void;
  42339. }
  42340. /**
  42341. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42342. */
  42343. export interface IExplorerExtensibilityGroup {
  42344. /**
  42345. * Defines a predicate to test if a given type mut be extended
  42346. */
  42347. predicate: (entity: any) => boolean;
  42348. /**
  42349. * Gets the list of options added to a type
  42350. */
  42351. entries: IExplorerExtensibilityOption[];
  42352. }
  42353. /**
  42354. * Interface used to define the options to use to create the Inspector
  42355. */
  42356. export interface IInspectorOptions {
  42357. /**
  42358. * Display in overlay mode (default: false)
  42359. */
  42360. overlay?: boolean;
  42361. /**
  42362. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42363. */
  42364. globalRoot?: HTMLElement;
  42365. /**
  42366. * Display the Scene explorer
  42367. */
  42368. showExplorer?: boolean;
  42369. /**
  42370. * Display the property inspector
  42371. */
  42372. showInspector?: boolean;
  42373. /**
  42374. * Display in embed mode (both panes on the right)
  42375. */
  42376. embedMode?: boolean;
  42377. /**
  42378. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42379. */
  42380. handleResize?: boolean;
  42381. /**
  42382. * Allow the panes to popup (default: true)
  42383. */
  42384. enablePopup?: boolean;
  42385. /**
  42386. * Allow the panes to be closed by users (default: true)
  42387. */
  42388. enableClose?: boolean;
  42389. /**
  42390. * Optional list of extensibility entries
  42391. */
  42392. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42393. /**
  42394. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42395. */
  42396. inspectorURL?: string;
  42397. }
  42398. module "babylonjs/scene" {
  42399. interface Scene {
  42400. /**
  42401. * @hidden
  42402. * Backing field
  42403. */
  42404. _debugLayer: DebugLayer;
  42405. /**
  42406. * Gets the debug layer (aka Inspector) associated with the scene
  42407. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42408. */
  42409. debugLayer: DebugLayer;
  42410. }
  42411. }
  42412. /**
  42413. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42414. * what is happening in your scene
  42415. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42416. */
  42417. export class DebugLayer {
  42418. /**
  42419. * Define the url to get the inspector script from.
  42420. * By default it uses the babylonjs CDN.
  42421. * @ignoreNaming
  42422. */
  42423. static InspectorURL: string;
  42424. private _scene;
  42425. private BJSINSPECTOR;
  42426. /**
  42427. * Observable triggered when a property is changed through the inspector.
  42428. */
  42429. onPropertyChangedObservable: Observable<{
  42430. object: any;
  42431. property: string;
  42432. value: any;
  42433. initialValue: any;
  42434. }>;
  42435. /**
  42436. * Instantiates a new debug layer.
  42437. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42438. * what is happening in your scene
  42439. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42440. * @param scene Defines the scene to inspect
  42441. */
  42442. constructor(scene: Scene);
  42443. /** Creates the inspector window. */
  42444. private _createInspector;
  42445. /**
  42446. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42447. * @param entity defines the entity to select
  42448. * @param lineContainerTitle defines the specific block to highlight
  42449. */
  42450. select(entity: any, lineContainerTitle?: string): void;
  42451. /** Get the inspector from bundle or global */
  42452. private _getGlobalInspector;
  42453. /**
  42454. * Get if the inspector is visible or not.
  42455. * @returns true if visible otherwise, false
  42456. */
  42457. isVisible(): boolean;
  42458. /**
  42459. * Hide the inspector and close its window.
  42460. */
  42461. hide(): void;
  42462. /**
  42463. * Launch the debugLayer.
  42464. * @param config Define the configuration of the inspector
  42465. * @return a promise fulfilled when the debug layer is visible
  42466. */
  42467. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42468. }
  42469. }
  42470. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42471. import { Nullable } from "babylonjs/types";
  42472. import { Scene } from "babylonjs/scene";
  42473. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42474. import { Mesh } from "babylonjs/Meshes/mesh";
  42475. /**
  42476. * Class containing static functions to help procedurally build meshes
  42477. */
  42478. export class BoxBuilder {
  42479. /**
  42480. * Creates a box mesh
  42481. * * The parameter `size` sets the size (float) of each box side (default 1)
  42482. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42483. * * 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)
  42484. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42488. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42489. * @param name defines the name of the mesh
  42490. * @param options defines the options used to create the mesh
  42491. * @param scene defines the hosting scene
  42492. * @returns the box mesh
  42493. */
  42494. static CreateBox(name: string, options: {
  42495. size?: number;
  42496. width?: number;
  42497. height?: number;
  42498. depth?: number;
  42499. faceUV?: Vector4[];
  42500. faceColors?: Color4[];
  42501. sideOrientation?: number;
  42502. frontUVs?: Vector4;
  42503. backUVs?: Vector4;
  42504. wrap?: boolean;
  42505. topBaseAt?: number;
  42506. bottomBaseAt?: number;
  42507. updatable?: boolean;
  42508. }, scene?: Nullable<Scene>): Mesh;
  42509. }
  42510. }
  42511. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42512. import { Vector4 } from "babylonjs/Maths/math";
  42513. import { Mesh } from "babylonjs/Meshes/mesh";
  42514. /**
  42515. * Class containing static functions to help procedurally build meshes
  42516. */
  42517. export class SphereBuilder {
  42518. /**
  42519. * Creates a sphere mesh
  42520. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42521. * * 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`)
  42522. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42523. * * 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
  42524. * * 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)
  42525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42528. * @param name defines the name of the mesh
  42529. * @param options defines the options used to create the mesh
  42530. * @param scene defines the hosting scene
  42531. * @returns the sphere mesh
  42532. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42533. */
  42534. static CreateSphere(name: string, options: {
  42535. segments?: number;
  42536. diameter?: number;
  42537. diameterX?: number;
  42538. diameterY?: number;
  42539. diameterZ?: number;
  42540. arc?: number;
  42541. slice?: number;
  42542. sideOrientation?: number;
  42543. frontUVs?: Vector4;
  42544. backUVs?: Vector4;
  42545. updatable?: boolean;
  42546. }, scene: any): Mesh;
  42547. }
  42548. }
  42549. declare module "babylonjs/Debug/physicsViewer" {
  42550. import { Nullable } from "babylonjs/types";
  42551. import { Scene } from "babylonjs/scene";
  42552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42553. import { Mesh } from "babylonjs/Meshes/mesh";
  42554. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42555. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42556. /**
  42557. * Used to show the physics impostor around the specific mesh
  42558. */
  42559. export class PhysicsViewer {
  42560. /** @hidden */
  42561. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42562. /** @hidden */
  42563. protected _meshes: Array<Nullable<AbstractMesh>>;
  42564. /** @hidden */
  42565. protected _scene: Nullable<Scene>;
  42566. /** @hidden */
  42567. protected _numMeshes: number;
  42568. /** @hidden */
  42569. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42570. private _renderFunction;
  42571. private _utilityLayer;
  42572. private _debugBoxMesh;
  42573. private _debugSphereMesh;
  42574. private _debugCylinderMesh;
  42575. private _debugMaterial;
  42576. private _debugMeshMeshes;
  42577. /**
  42578. * Creates a new PhysicsViewer
  42579. * @param scene defines the hosting scene
  42580. */
  42581. constructor(scene: Scene);
  42582. /** @hidden */
  42583. protected _updateDebugMeshes(): void;
  42584. /**
  42585. * Renders a specified physic impostor
  42586. * @param impostor defines the impostor to render
  42587. * @param targetMesh defines the mesh represented by the impostor
  42588. * @returns the new debug mesh used to render the impostor
  42589. */
  42590. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42591. /**
  42592. * Hides a specified physic impostor
  42593. * @param impostor defines the impostor to hide
  42594. */
  42595. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42596. private _getDebugMaterial;
  42597. private _getDebugBoxMesh;
  42598. private _getDebugSphereMesh;
  42599. private _getDebugCylinderMesh;
  42600. private _getDebugMeshMesh;
  42601. private _getDebugMesh;
  42602. /** Releases all resources */
  42603. dispose(): void;
  42604. }
  42605. }
  42606. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42607. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42608. import { Nullable } from "babylonjs/types";
  42609. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42610. import { Scene } from "babylonjs/scene";
  42611. /**
  42612. * Class containing static functions to help procedurally build meshes
  42613. */
  42614. export class LinesBuilder {
  42615. /**
  42616. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42617. * * 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
  42618. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42619. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42620. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42621. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42622. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42623. * * 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
  42624. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42626. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42627. * @param name defines the name of the new line system
  42628. * @param options defines the options used to create the line system
  42629. * @param scene defines the hosting scene
  42630. * @returns a new line system mesh
  42631. */
  42632. static CreateLineSystem(name: string, options: {
  42633. lines: Vector3[][];
  42634. updatable?: boolean;
  42635. instance?: Nullable<LinesMesh>;
  42636. colors?: Nullable<Color4[][]>;
  42637. useVertexAlpha?: boolean;
  42638. }, scene: Nullable<Scene>): LinesMesh;
  42639. /**
  42640. * Creates a line mesh
  42641. * 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
  42642. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42643. * * The parameter `points` is an array successive Vector3
  42644. * * 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
  42645. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42646. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42647. * * When updating an instance, remember that only point positions can change, not the number of points
  42648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42650. * @param name defines the name of the new line system
  42651. * @param options defines the options used to create the line system
  42652. * @param scene defines the hosting scene
  42653. * @returns a new line mesh
  42654. */
  42655. static CreateLines(name: string, options: {
  42656. points: Vector3[];
  42657. updatable?: boolean;
  42658. instance?: Nullable<LinesMesh>;
  42659. colors?: Color4[];
  42660. useVertexAlpha?: boolean;
  42661. }, scene?: Nullable<Scene>): LinesMesh;
  42662. /**
  42663. * Creates a dashed line mesh
  42664. * * 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
  42665. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42666. * * The parameter `points` is an array successive Vector3
  42667. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42668. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42669. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42670. * * 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
  42671. * * When updating an instance, remember that only point positions can change, not the number of points
  42672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42673. * @param name defines the name of the mesh
  42674. * @param options defines the options used to create the mesh
  42675. * @param scene defines the hosting scene
  42676. * @returns the dashed line mesh
  42677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42678. */
  42679. static CreateDashedLines(name: string, options: {
  42680. points: Vector3[];
  42681. dashSize?: number;
  42682. gapSize?: number;
  42683. dashNb?: number;
  42684. updatable?: boolean;
  42685. instance?: LinesMesh;
  42686. }, scene?: Nullable<Scene>): LinesMesh;
  42687. }
  42688. }
  42689. declare module "babylonjs/Debug/rayHelper" {
  42690. import { Nullable } from "babylonjs/types";
  42691. import { Ray } from "babylonjs/Culling/ray";
  42692. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42693. import { Scene } from "babylonjs/scene";
  42694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42695. import "babylonjs/Meshes/Builders/linesBuilder";
  42696. /**
  42697. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42698. * in order to better appreciate the issue one might have.
  42699. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42700. */
  42701. export class RayHelper {
  42702. /**
  42703. * Defines the ray we are currently tryin to visualize.
  42704. */
  42705. ray: Nullable<Ray>;
  42706. private _renderPoints;
  42707. private _renderLine;
  42708. private _renderFunction;
  42709. private _scene;
  42710. private _updateToMeshFunction;
  42711. private _attachedToMesh;
  42712. private _meshSpaceDirection;
  42713. private _meshSpaceOrigin;
  42714. /**
  42715. * Helper function to create a colored helper in a scene in one line.
  42716. * @param ray Defines the ray we are currently tryin to visualize
  42717. * @param scene Defines the scene the ray is used in
  42718. * @param color Defines the color we want to see the ray in
  42719. * @returns The newly created ray helper.
  42720. */
  42721. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42722. /**
  42723. * Instantiate a new ray helper.
  42724. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42725. * in order to better appreciate the issue one might have.
  42726. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42727. * @param ray Defines the ray we are currently tryin to visualize
  42728. */
  42729. constructor(ray: Ray);
  42730. /**
  42731. * Shows the ray we are willing to debug.
  42732. * @param scene Defines the scene the ray needs to be rendered in
  42733. * @param color Defines the color the ray needs to be rendered in
  42734. */
  42735. show(scene: Scene, color?: Color3): void;
  42736. /**
  42737. * Hides the ray we are debugging.
  42738. */
  42739. hide(): void;
  42740. private _render;
  42741. /**
  42742. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42743. * @param mesh Defines the mesh we want the helper attached to
  42744. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42745. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42746. * @param length Defines the length of the ray
  42747. */
  42748. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42749. /**
  42750. * Detach the ray helper from the mesh it has previously been attached to.
  42751. */
  42752. detachFromMesh(): void;
  42753. private _updateToMesh;
  42754. /**
  42755. * Dispose the helper and release its associated resources.
  42756. */
  42757. dispose(): void;
  42758. }
  42759. }
  42760. declare module "babylonjs/Debug/skeletonViewer" {
  42761. import { Color3 } from "babylonjs/Maths/math";
  42762. import { Scene } from "babylonjs/scene";
  42763. import { Nullable } from "babylonjs/types";
  42764. import { Skeleton } from "babylonjs/Bones/skeleton";
  42765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42766. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42767. /**
  42768. * Class used to render a debug view of a given skeleton
  42769. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42770. */
  42771. export class SkeletonViewer {
  42772. /** defines the skeleton to render */
  42773. skeleton: Skeleton;
  42774. /** defines the mesh attached to the skeleton */
  42775. mesh: AbstractMesh;
  42776. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42777. autoUpdateBonesMatrices: boolean;
  42778. /** defines the rendering group id to use with the viewer */
  42779. renderingGroupId: number;
  42780. /** Gets or sets the color used to render the skeleton */
  42781. color: Color3;
  42782. private _scene;
  42783. private _debugLines;
  42784. private _debugMesh;
  42785. private _isEnabled;
  42786. private _renderFunction;
  42787. private _utilityLayer;
  42788. /**
  42789. * Returns the mesh used to render the bones
  42790. */
  42791. readonly debugMesh: Nullable<LinesMesh>;
  42792. /**
  42793. * Creates a new SkeletonViewer
  42794. * @param skeleton defines the skeleton to render
  42795. * @param mesh defines the mesh attached to the skeleton
  42796. * @param scene defines the hosting scene
  42797. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42798. * @param renderingGroupId defines the rendering group id to use with the viewer
  42799. */
  42800. constructor(
  42801. /** defines the skeleton to render */
  42802. skeleton: Skeleton,
  42803. /** defines the mesh attached to the skeleton */
  42804. mesh: AbstractMesh, scene: Scene,
  42805. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42806. autoUpdateBonesMatrices?: boolean,
  42807. /** defines the rendering group id to use with the viewer */
  42808. renderingGroupId?: number);
  42809. /** Gets or sets a boolean indicating if the viewer is enabled */
  42810. isEnabled: boolean;
  42811. private _getBonePosition;
  42812. private _getLinesForBonesWithLength;
  42813. private _getLinesForBonesNoLength;
  42814. /** Update the viewer to sync with current skeleton state */
  42815. update(): void;
  42816. /** Release associated resources */
  42817. dispose(): void;
  42818. }
  42819. }
  42820. declare module "babylonjs/Debug/index" {
  42821. export * from "babylonjs/Debug/axesViewer";
  42822. export * from "babylonjs/Debug/boneAxesViewer";
  42823. export * from "babylonjs/Debug/debugLayer";
  42824. export * from "babylonjs/Debug/physicsViewer";
  42825. export * from "babylonjs/Debug/rayHelper";
  42826. export * from "babylonjs/Debug/skeletonViewer";
  42827. }
  42828. declare module "babylonjs/Engines/nullEngine" {
  42829. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42830. import { Scene } from "babylonjs/scene";
  42831. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42832. import { Engine } from "babylonjs/Engines/engine";
  42833. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42834. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42835. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42836. import { Effect } from "babylonjs/Materials/effect";
  42837. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42838. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42839. /**
  42840. * Options to create the null engine
  42841. */
  42842. export class NullEngineOptions {
  42843. /**
  42844. * Render width (Default: 512)
  42845. */
  42846. renderWidth: number;
  42847. /**
  42848. * Render height (Default: 256)
  42849. */
  42850. renderHeight: number;
  42851. /**
  42852. * Texture size (Default: 512)
  42853. */
  42854. textureSize: number;
  42855. /**
  42856. * If delta time between frames should be constant
  42857. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42858. */
  42859. deterministicLockstep: boolean;
  42860. /**
  42861. * Maximum about of steps between frames (Default: 4)
  42862. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42863. */
  42864. lockstepMaxSteps: number;
  42865. }
  42866. /**
  42867. * The null engine class provides support for headless version of babylon.js.
  42868. * This can be used in server side scenario or for testing purposes
  42869. */
  42870. export class NullEngine extends Engine {
  42871. private _options;
  42872. /**
  42873. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42874. */
  42875. isDeterministicLockStep(): boolean;
  42876. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42877. getLockstepMaxSteps(): number;
  42878. /**
  42879. * Sets hardware scaling, used to save performance if needed
  42880. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42881. */
  42882. getHardwareScalingLevel(): number;
  42883. constructor(options?: NullEngineOptions);
  42884. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42885. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42886. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42887. getRenderWidth(useScreen?: boolean): number;
  42888. getRenderHeight(useScreen?: boolean): number;
  42889. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42890. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42891. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42892. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42893. bindSamplers(effect: Effect): void;
  42894. enableEffect(effect: Effect): void;
  42895. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42896. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42897. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42898. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42899. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42900. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42901. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42902. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42903. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42904. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42905. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42906. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42907. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42908. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42909. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42910. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42911. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42912. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42913. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42914. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42915. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42916. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42917. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42918. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42919. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42920. bindBuffers(vertexBuffers: {
  42921. [key: string]: VertexBuffer;
  42922. }, indexBuffer: DataBuffer, effect: Effect): void;
  42923. wipeCaches(bruteForce?: boolean): void;
  42924. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42925. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42926. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42927. /** @hidden */
  42928. _createTexture(): WebGLTexture;
  42929. /** @hidden */
  42930. _releaseTexture(texture: InternalTexture): void;
  42931. 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;
  42932. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42933. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42934. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42935. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42936. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42937. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42938. areAllEffectsReady(): boolean;
  42939. /**
  42940. * @hidden
  42941. * Get the current error code of the webGL context
  42942. * @returns the error code
  42943. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42944. */
  42945. getError(): number;
  42946. /** @hidden */
  42947. _getUnpackAlignement(): number;
  42948. /** @hidden */
  42949. _unpackFlipY(value: boolean): void;
  42950. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42951. /**
  42952. * Updates a dynamic vertex buffer.
  42953. * @param vertexBuffer the vertex buffer to update
  42954. * @param data the data used to update the vertex buffer
  42955. * @param byteOffset the byte offset of the data (optional)
  42956. * @param byteLength the byte length of the data (optional)
  42957. */
  42958. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42959. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42960. /** @hidden */
  42961. _bindTexture(channel: number, texture: InternalTexture): void;
  42962. /** @hidden */
  42963. _releaseBuffer(buffer: DataBuffer): boolean;
  42964. releaseEffects(): void;
  42965. displayLoadingUI(): void;
  42966. hideLoadingUI(): void;
  42967. /** @hidden */
  42968. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42969. /** @hidden */
  42970. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42971. /** @hidden */
  42972. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42973. /** @hidden */
  42974. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42975. }
  42976. }
  42977. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42978. import { Nullable, int } from "babylonjs/types";
  42979. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42980. /** @hidden */
  42981. export class _OcclusionDataStorage {
  42982. /** @hidden */
  42983. occlusionInternalRetryCounter: number;
  42984. /** @hidden */
  42985. isOcclusionQueryInProgress: boolean;
  42986. /** @hidden */
  42987. isOccluded: boolean;
  42988. /** @hidden */
  42989. occlusionRetryCount: number;
  42990. /** @hidden */
  42991. occlusionType: number;
  42992. /** @hidden */
  42993. occlusionQueryAlgorithmType: number;
  42994. }
  42995. module "babylonjs/Engines/engine" {
  42996. interface Engine {
  42997. /**
  42998. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42999. * @return the new query
  43000. */
  43001. createQuery(): WebGLQuery;
  43002. /**
  43003. * Delete and release a webGL query
  43004. * @param query defines the query to delete
  43005. * @return the current engine
  43006. */
  43007. deleteQuery(query: WebGLQuery): Engine;
  43008. /**
  43009. * Check if a given query has resolved and got its value
  43010. * @param query defines the query to check
  43011. * @returns true if the query got its value
  43012. */
  43013. isQueryResultAvailable(query: WebGLQuery): boolean;
  43014. /**
  43015. * Gets the value of a given query
  43016. * @param query defines the query to check
  43017. * @returns the value of the query
  43018. */
  43019. getQueryResult(query: WebGLQuery): number;
  43020. /**
  43021. * Initiates an occlusion query
  43022. * @param algorithmType defines the algorithm to use
  43023. * @param query defines the query to use
  43024. * @returns the current engine
  43025. * @see http://doc.babylonjs.com/features/occlusionquery
  43026. */
  43027. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43028. /**
  43029. * Ends an occlusion query
  43030. * @see http://doc.babylonjs.com/features/occlusionquery
  43031. * @param algorithmType defines the algorithm to use
  43032. * @returns the current engine
  43033. */
  43034. endOcclusionQuery(algorithmType: number): Engine;
  43035. /**
  43036. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43037. * Please note that only one query can be issued at a time
  43038. * @returns a time token used to track the time span
  43039. */
  43040. startTimeQuery(): Nullable<_TimeToken>;
  43041. /**
  43042. * Ends a time query
  43043. * @param token defines the token used to measure the time span
  43044. * @returns the time spent (in ns)
  43045. */
  43046. endTimeQuery(token: _TimeToken): int;
  43047. /** @hidden */
  43048. _currentNonTimestampToken: Nullable<_TimeToken>;
  43049. /** @hidden */
  43050. _createTimeQuery(): WebGLQuery;
  43051. /** @hidden */
  43052. _deleteTimeQuery(query: WebGLQuery): void;
  43053. /** @hidden */
  43054. _getGlAlgorithmType(algorithmType: number): number;
  43055. /** @hidden */
  43056. _getTimeQueryResult(query: WebGLQuery): any;
  43057. /** @hidden */
  43058. _getTimeQueryAvailability(query: WebGLQuery): any;
  43059. }
  43060. }
  43061. module "babylonjs/Meshes/abstractMesh" {
  43062. interface AbstractMesh {
  43063. /**
  43064. * Backing filed
  43065. * @hidden
  43066. */
  43067. __occlusionDataStorage: _OcclusionDataStorage;
  43068. /**
  43069. * Access property
  43070. * @hidden
  43071. */
  43072. _occlusionDataStorage: _OcclusionDataStorage;
  43073. /**
  43074. * 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.
  43075. * The default value is -1 which means don't break the query and wait till the result
  43076. * @see http://doc.babylonjs.com/features/occlusionquery
  43077. */
  43078. occlusionRetryCount: number;
  43079. /**
  43080. * 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:
  43081. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43082. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43083. * * 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.
  43084. * @see http://doc.babylonjs.com/features/occlusionquery
  43085. */
  43086. occlusionType: number;
  43087. /**
  43088. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43089. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43090. * * 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.
  43091. * @see http://doc.babylonjs.com/features/occlusionquery
  43092. */
  43093. occlusionQueryAlgorithmType: number;
  43094. /**
  43095. * 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
  43096. * @see http://doc.babylonjs.com/features/occlusionquery
  43097. */
  43098. isOccluded: boolean;
  43099. /**
  43100. * Flag to check the progress status of the query
  43101. * @see http://doc.babylonjs.com/features/occlusionquery
  43102. */
  43103. isOcclusionQueryInProgress: boolean;
  43104. }
  43105. }
  43106. }
  43107. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43108. import { Nullable } from "babylonjs/types";
  43109. /** @hidden */
  43110. export var _forceTransformFeedbackToBundle: boolean;
  43111. module "babylonjs/Engines/engine" {
  43112. interface Engine {
  43113. /**
  43114. * Creates a webGL transform feedback object
  43115. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43116. * @returns the webGL transform feedback object
  43117. */
  43118. createTransformFeedback(): WebGLTransformFeedback;
  43119. /**
  43120. * Delete a webGL transform feedback object
  43121. * @param value defines the webGL transform feedback object to delete
  43122. */
  43123. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43124. /**
  43125. * Bind a webGL transform feedback object to the webgl context
  43126. * @param value defines the webGL transform feedback object to bind
  43127. */
  43128. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43129. /**
  43130. * Begins a transform feedback operation
  43131. * @param usePoints defines if points or triangles must be used
  43132. */
  43133. beginTransformFeedback(usePoints: boolean): void;
  43134. /**
  43135. * Ends a transform feedback operation
  43136. */
  43137. endTransformFeedback(): void;
  43138. /**
  43139. * Specify the varyings to use with transform feedback
  43140. * @param program defines the associated webGL program
  43141. * @param value defines the list of strings representing the varying names
  43142. */
  43143. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43144. /**
  43145. * Bind a webGL buffer for a transform feedback operation
  43146. * @param value defines the webGL buffer to bind
  43147. */
  43148. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43149. }
  43150. }
  43151. }
  43152. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43153. import { Scene } from "babylonjs/scene";
  43154. import { Engine } from "babylonjs/Engines/engine";
  43155. import { Texture } from "babylonjs/Materials/Textures/texture";
  43156. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43157. import "babylonjs/Engines/Extensions/engine.multiRender";
  43158. /**
  43159. * Creation options of the multi render target texture.
  43160. */
  43161. export interface IMultiRenderTargetOptions {
  43162. /**
  43163. * Define if the texture needs to create mip maps after render.
  43164. */
  43165. generateMipMaps?: boolean;
  43166. /**
  43167. * Define the types of all the draw buffers we want to create
  43168. */
  43169. types?: number[];
  43170. /**
  43171. * Define the sampling modes of all the draw buffers we want to create
  43172. */
  43173. samplingModes?: number[];
  43174. /**
  43175. * Define if a depth buffer is required
  43176. */
  43177. generateDepthBuffer?: boolean;
  43178. /**
  43179. * Define if a stencil buffer is required
  43180. */
  43181. generateStencilBuffer?: boolean;
  43182. /**
  43183. * Define if a depth texture is required instead of a depth buffer
  43184. */
  43185. generateDepthTexture?: boolean;
  43186. /**
  43187. * Define the number of desired draw buffers
  43188. */
  43189. textureCount?: number;
  43190. /**
  43191. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43192. */
  43193. doNotChangeAspectRatio?: boolean;
  43194. /**
  43195. * Define the default type of the buffers we are creating
  43196. */
  43197. defaultType?: number;
  43198. }
  43199. /**
  43200. * A multi render target, like a render target provides the ability to render to a texture.
  43201. * Unlike the render target, it can render to several draw buffers in one draw.
  43202. * This is specially interesting in deferred rendering or for any effects requiring more than
  43203. * just one color from a single pass.
  43204. */
  43205. export class MultiRenderTarget extends RenderTargetTexture {
  43206. private _internalTextures;
  43207. private _textures;
  43208. private _multiRenderTargetOptions;
  43209. /**
  43210. * Get if draw buffers are currently supported by the used hardware and browser.
  43211. */
  43212. readonly isSupported: boolean;
  43213. /**
  43214. * Get the list of textures generated by the multi render target.
  43215. */
  43216. readonly textures: Texture[];
  43217. /**
  43218. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43219. */
  43220. readonly depthTexture: Texture;
  43221. /**
  43222. * Set the wrapping mode on U of all the textures we are rendering to.
  43223. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43224. */
  43225. wrapU: number;
  43226. /**
  43227. * Set the wrapping mode on V of all the textures we are rendering to.
  43228. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43229. */
  43230. wrapV: number;
  43231. /**
  43232. * Instantiate a new multi render target texture.
  43233. * A multi render target, like a render target provides the ability to render to a texture.
  43234. * Unlike the render target, it can render to several draw buffers in one draw.
  43235. * This is specially interesting in deferred rendering or for any effects requiring more than
  43236. * just one color from a single pass.
  43237. * @param name Define the name of the texture
  43238. * @param size Define the size of the buffers to render to
  43239. * @param count Define the number of target we are rendering into
  43240. * @param scene Define the scene the texture belongs to
  43241. * @param options Define the options used to create the multi render target
  43242. */
  43243. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43244. /** @hidden */
  43245. _rebuild(): void;
  43246. private _createInternalTextures;
  43247. private _createTextures;
  43248. /**
  43249. * Define the number of samples used if MSAA is enabled.
  43250. */
  43251. samples: number;
  43252. /**
  43253. * Resize all the textures in the multi render target.
  43254. * Be carrefull as it will recreate all the data in the new texture.
  43255. * @param size Define the new size
  43256. */
  43257. resize(size: any): void;
  43258. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43259. /**
  43260. * Dispose the render targets and their associated resources
  43261. */
  43262. dispose(): void;
  43263. /**
  43264. * Release all the underlying texture used as draw buffers.
  43265. */
  43266. releaseInternalTextures(): void;
  43267. }
  43268. }
  43269. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43270. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43271. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43272. import { Nullable } from "babylonjs/types";
  43273. module "babylonjs/Engines/engine" {
  43274. interface Engine {
  43275. /**
  43276. * Unbind a list of render target textures from the webGL context
  43277. * This is used only when drawBuffer extension or webGL2 are active
  43278. * @param textures defines the render target textures to unbind
  43279. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43280. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43281. */
  43282. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43283. /**
  43284. * Create a multi render target texture
  43285. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43286. * @param size defines the size of the texture
  43287. * @param options defines the creation options
  43288. * @returns the cube texture as an InternalTexture
  43289. */
  43290. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43291. /**
  43292. * Update the sample count for a given multiple render target texture
  43293. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43294. * @param textures defines the textures to update
  43295. * @param samples defines the sample count to set
  43296. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43297. */
  43298. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43299. }
  43300. }
  43301. }
  43302. declare module "babylonjs/Engines/Extensions/index" {
  43303. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43304. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43305. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43306. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43307. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43308. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43309. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43310. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43311. }
  43312. declare module "babylonjs/Engines/index" {
  43313. export * from "babylonjs/Engines/constants";
  43314. export * from "babylonjs/Engines/engine";
  43315. export * from "babylonjs/Engines/engineStore";
  43316. export * from "babylonjs/Engines/nullEngine";
  43317. export * from "babylonjs/Engines/Extensions/index";
  43318. export * from "babylonjs/Engines/IPipelineContext";
  43319. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43320. }
  43321. declare module "babylonjs/Events/clipboardEvents" {
  43322. /**
  43323. * Gather the list of clipboard event types as constants.
  43324. */
  43325. export class ClipboardEventTypes {
  43326. /**
  43327. * The clipboard event is fired when a copy command is active (pressed).
  43328. */
  43329. static readonly COPY: number;
  43330. /**
  43331. * The clipboard event is fired when a cut command is active (pressed).
  43332. */
  43333. static readonly CUT: number;
  43334. /**
  43335. * The clipboard event is fired when a paste command is active (pressed).
  43336. */
  43337. static readonly PASTE: number;
  43338. }
  43339. /**
  43340. * This class is used to store clipboard related info for the onClipboardObservable event.
  43341. */
  43342. export class ClipboardInfo {
  43343. /**
  43344. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43345. */
  43346. type: number;
  43347. /**
  43348. * Defines the related dom event
  43349. */
  43350. event: ClipboardEvent;
  43351. /**
  43352. *Creates an instance of ClipboardInfo.
  43353. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43354. * @param event Defines the related dom event
  43355. */
  43356. constructor(
  43357. /**
  43358. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43359. */
  43360. type: number,
  43361. /**
  43362. * Defines the related dom event
  43363. */
  43364. event: ClipboardEvent);
  43365. /**
  43366. * Get the clipboard event's type from the keycode.
  43367. * @param keyCode Defines the keyCode for the current keyboard event.
  43368. * @return {number}
  43369. */
  43370. static GetTypeFromCharacter(keyCode: number): number;
  43371. }
  43372. }
  43373. declare module "babylonjs/Events/index" {
  43374. export * from "babylonjs/Events/keyboardEvents";
  43375. export * from "babylonjs/Events/pointerEvents";
  43376. export * from "babylonjs/Events/clipboardEvents";
  43377. }
  43378. declare module "babylonjs/Loading/sceneLoader" {
  43379. import { Observable } from "babylonjs/Misc/observable";
  43380. import { Nullable } from "babylonjs/types";
  43381. import { Scene } from "babylonjs/scene";
  43382. import { Engine } from "babylonjs/Engines/engine";
  43383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43384. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43385. import { AssetContainer } from "babylonjs/assetContainer";
  43386. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43387. import { Skeleton } from "babylonjs/Bones/skeleton";
  43388. /**
  43389. * Class used to represent data loading progression
  43390. */
  43391. export class SceneLoaderProgressEvent {
  43392. /** defines if data length to load can be evaluated */
  43393. readonly lengthComputable: boolean;
  43394. /** defines the loaded data length */
  43395. readonly loaded: number;
  43396. /** defines the data length to load */
  43397. readonly total: number;
  43398. /**
  43399. * Create a new progress event
  43400. * @param lengthComputable defines if data length to load can be evaluated
  43401. * @param loaded defines the loaded data length
  43402. * @param total defines the data length to load
  43403. */
  43404. constructor(
  43405. /** defines if data length to load can be evaluated */
  43406. lengthComputable: boolean,
  43407. /** defines the loaded data length */
  43408. loaded: number,
  43409. /** defines the data length to load */
  43410. total: number);
  43411. /**
  43412. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43413. * @param event defines the source event
  43414. * @returns a new SceneLoaderProgressEvent
  43415. */
  43416. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43417. }
  43418. /**
  43419. * Interface used by SceneLoader plugins to define supported file extensions
  43420. */
  43421. export interface ISceneLoaderPluginExtensions {
  43422. /**
  43423. * Defines the list of supported extensions
  43424. */
  43425. [extension: string]: {
  43426. isBinary: boolean;
  43427. };
  43428. }
  43429. /**
  43430. * Interface used by SceneLoader plugin factory
  43431. */
  43432. export interface ISceneLoaderPluginFactory {
  43433. /**
  43434. * Defines the name of the factory
  43435. */
  43436. name: string;
  43437. /**
  43438. * Function called to create a new plugin
  43439. * @return the new plugin
  43440. */
  43441. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43442. /**
  43443. * Boolean indicating if the plugin can direct load specific data
  43444. */
  43445. canDirectLoad?: (data: string) => boolean;
  43446. }
  43447. /**
  43448. * Interface used to define a SceneLoader plugin
  43449. */
  43450. export interface ISceneLoaderPlugin {
  43451. /**
  43452. * The friendly name of this plugin.
  43453. */
  43454. name: string;
  43455. /**
  43456. * The file extensions supported by this plugin.
  43457. */
  43458. extensions: string | ISceneLoaderPluginExtensions;
  43459. /**
  43460. * Import meshes into a scene.
  43461. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43462. * @param scene The scene to import into
  43463. * @param data The data to import
  43464. * @param rootUrl The root url for scene and resources
  43465. * @param meshes The meshes array to import into
  43466. * @param particleSystems The particle systems array to import into
  43467. * @param skeletons The skeletons array to import into
  43468. * @param onError The callback when import fails
  43469. * @returns True if successful or false otherwise
  43470. */
  43471. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43472. /**
  43473. * Load into a scene.
  43474. * @param scene The scene to load into
  43475. * @param data The data to import
  43476. * @param rootUrl The root url for scene and resources
  43477. * @param onError The callback when import fails
  43478. * @returns true if successful or false otherwise
  43479. */
  43480. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43481. /**
  43482. * The callback that returns true if the data can be directly loaded.
  43483. */
  43484. canDirectLoad?: (data: string) => boolean;
  43485. /**
  43486. * The callback that allows custom handling of the root url based on the response url.
  43487. */
  43488. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43489. /**
  43490. * Load into an asset container.
  43491. * @param scene The scene to load into
  43492. * @param data The data to import
  43493. * @param rootUrl The root url for scene and resources
  43494. * @param onError The callback when import fails
  43495. * @returns The loaded asset container
  43496. */
  43497. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43498. }
  43499. /**
  43500. * Interface used to define an async SceneLoader plugin
  43501. */
  43502. export interface ISceneLoaderPluginAsync {
  43503. /**
  43504. * The friendly name of this plugin.
  43505. */
  43506. name: string;
  43507. /**
  43508. * The file extensions supported by this plugin.
  43509. */
  43510. extensions: string | ISceneLoaderPluginExtensions;
  43511. /**
  43512. * Import meshes into a scene.
  43513. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43514. * @param scene The scene to import into
  43515. * @param data The data to import
  43516. * @param rootUrl The root url for scene and resources
  43517. * @param onProgress The callback when the load progresses
  43518. * @param fileName Defines the name of the file to load
  43519. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43520. */
  43521. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43522. meshes: AbstractMesh[];
  43523. particleSystems: IParticleSystem[];
  43524. skeletons: Skeleton[];
  43525. animationGroups: AnimationGroup[];
  43526. }>;
  43527. /**
  43528. * Load into a scene.
  43529. * @param scene The scene to load into
  43530. * @param data The data to import
  43531. * @param rootUrl The root url for scene and resources
  43532. * @param onProgress The callback when the load progresses
  43533. * @param fileName Defines the name of the file to load
  43534. * @returns Nothing
  43535. */
  43536. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43537. /**
  43538. * The callback that returns true if the data can be directly loaded.
  43539. */
  43540. canDirectLoad?: (data: string) => boolean;
  43541. /**
  43542. * The callback that allows custom handling of the root url based on the response url.
  43543. */
  43544. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43545. /**
  43546. * Load into an asset container.
  43547. * @param scene The scene to load into
  43548. * @param data The data to import
  43549. * @param rootUrl The root url for scene and resources
  43550. * @param onProgress The callback when the load progresses
  43551. * @param fileName Defines the name of the file to load
  43552. * @returns The loaded asset container
  43553. */
  43554. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43555. }
  43556. /**
  43557. * Class used to load scene from various file formats using registered plugins
  43558. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43559. */
  43560. export class SceneLoader {
  43561. /**
  43562. * No logging while loading
  43563. */
  43564. static readonly NO_LOGGING: number;
  43565. /**
  43566. * Minimal logging while loading
  43567. */
  43568. static readonly MINIMAL_LOGGING: number;
  43569. /**
  43570. * Summary logging while loading
  43571. */
  43572. static readonly SUMMARY_LOGGING: number;
  43573. /**
  43574. * Detailled logging while loading
  43575. */
  43576. static readonly DETAILED_LOGGING: number;
  43577. /**
  43578. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43579. */
  43580. static ForceFullSceneLoadingForIncremental: boolean;
  43581. /**
  43582. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43583. */
  43584. static ShowLoadingScreen: boolean;
  43585. /**
  43586. * Defines the current logging level (while loading the scene)
  43587. * @ignorenaming
  43588. */
  43589. static loggingLevel: number;
  43590. /**
  43591. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43592. */
  43593. static CleanBoneMatrixWeights: boolean;
  43594. /**
  43595. * Event raised when a plugin is used to load a scene
  43596. */
  43597. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43598. private static _registeredPlugins;
  43599. private static _getDefaultPlugin;
  43600. private static _getPluginForExtension;
  43601. private static _getPluginForDirectLoad;
  43602. private static _getPluginForFilename;
  43603. private static _getDirectLoad;
  43604. private static _loadData;
  43605. private static _getFileInfo;
  43606. /**
  43607. * Gets a plugin that can load the given extension
  43608. * @param extension defines the extension to load
  43609. * @returns a plugin or null if none works
  43610. */
  43611. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43612. /**
  43613. * Gets a boolean indicating that the given extension can be loaded
  43614. * @param extension defines the extension to load
  43615. * @returns true if the extension is supported
  43616. */
  43617. static IsPluginForExtensionAvailable(extension: string): boolean;
  43618. /**
  43619. * Adds a new plugin to the list of registered plugins
  43620. * @param plugin defines the plugin to add
  43621. */
  43622. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43623. /**
  43624. * Import meshes into a scene
  43625. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43626. * @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)
  43627. * @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)
  43628. * @param scene the instance of BABYLON.Scene to append to
  43629. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43630. * @param onProgress a callback with a progress event for each file being loaded
  43631. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43632. * @param pluginExtension the extension used to determine the plugin
  43633. * @returns The loaded plugin
  43634. */
  43635. 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>;
  43636. /**
  43637. * Import meshes into a scene
  43638. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43639. * @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)
  43640. * @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)
  43641. * @param scene the instance of BABYLON.Scene to append to
  43642. * @param onProgress a callback with a progress event for each file being loaded
  43643. * @param pluginExtension the extension used to determine the plugin
  43644. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43645. */
  43646. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43647. meshes: AbstractMesh[];
  43648. particleSystems: IParticleSystem[];
  43649. skeletons: Skeleton[];
  43650. animationGroups: AnimationGroup[];
  43651. }>;
  43652. /**
  43653. * Load a scene
  43654. * @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)
  43655. * @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)
  43656. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43657. * @param onSuccess a callback with the scene when import succeeds
  43658. * @param onProgress a callback with a progress event for each file being loaded
  43659. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43660. * @param pluginExtension the extension used to determine the plugin
  43661. * @returns The loaded plugin
  43662. */
  43663. 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>;
  43664. /**
  43665. * Load a scene
  43666. * @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)
  43667. * @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)
  43668. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43669. * @param onProgress a callback with a progress event for each file being loaded
  43670. * @param pluginExtension the extension used to determine the plugin
  43671. * @returns The loaded scene
  43672. */
  43673. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43674. /**
  43675. * Append a scene
  43676. * @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)
  43677. * @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)
  43678. * @param scene is the instance of BABYLON.Scene to append to
  43679. * @param onSuccess a callback with the scene when import succeeds
  43680. * @param onProgress a callback with a progress event for each file being loaded
  43681. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43682. * @param pluginExtension the extension used to determine the plugin
  43683. * @returns The loaded plugin
  43684. */
  43685. 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>;
  43686. /**
  43687. * Append a scene
  43688. * @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)
  43689. * @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)
  43690. * @param scene is the instance of BABYLON.Scene to append to
  43691. * @param onProgress a callback with a progress event for each file being loaded
  43692. * @param pluginExtension the extension used to determine the plugin
  43693. * @returns The given scene
  43694. */
  43695. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43696. /**
  43697. * Load a scene into an asset container
  43698. * @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)
  43699. * @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)
  43700. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43701. * @param onSuccess a callback with the scene when import succeeds
  43702. * @param onProgress a callback with a progress event for each file being loaded
  43703. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43704. * @param pluginExtension the extension used to determine the plugin
  43705. * @returns The loaded plugin
  43706. */
  43707. 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>;
  43708. /**
  43709. * Load a scene into an asset container
  43710. * @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)
  43711. * @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)
  43712. * @param scene is the instance of Scene to append to
  43713. * @param onProgress a callback with a progress event for each file being loaded
  43714. * @param pluginExtension the extension used to determine the plugin
  43715. * @returns The loaded asset container
  43716. */
  43717. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43718. }
  43719. }
  43720. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43721. import { Scene } from "babylonjs/scene";
  43722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43723. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43724. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43725. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43726. /**
  43727. * Google Daydream controller
  43728. */
  43729. export class DaydreamController extends WebVRController {
  43730. /**
  43731. * Base Url for the controller model.
  43732. */
  43733. static MODEL_BASE_URL: string;
  43734. /**
  43735. * File name for the controller model.
  43736. */
  43737. static MODEL_FILENAME: string;
  43738. /**
  43739. * Gamepad Id prefix used to identify Daydream Controller.
  43740. */
  43741. static readonly GAMEPAD_ID_PREFIX: string;
  43742. /**
  43743. * Creates a new DaydreamController from a gamepad
  43744. * @param vrGamepad the gamepad that the controller should be created from
  43745. */
  43746. constructor(vrGamepad: any);
  43747. /**
  43748. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43749. * @param scene scene in which to add meshes
  43750. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43751. */
  43752. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43753. /**
  43754. * Called once for each button that changed state since the last frame
  43755. * @param buttonIdx Which button index changed
  43756. * @param state New state of the button
  43757. * @param changes Which properties on the state changed since last frame
  43758. */
  43759. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43760. }
  43761. }
  43762. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43763. import { Scene } from "babylonjs/scene";
  43764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43765. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43766. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43767. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43768. /**
  43769. * Gear VR Controller
  43770. */
  43771. export class GearVRController extends WebVRController {
  43772. /**
  43773. * Base Url for the controller model.
  43774. */
  43775. static MODEL_BASE_URL: string;
  43776. /**
  43777. * File name for the controller model.
  43778. */
  43779. static MODEL_FILENAME: string;
  43780. /**
  43781. * Gamepad Id prefix used to identify this controller.
  43782. */
  43783. static readonly GAMEPAD_ID_PREFIX: string;
  43784. private readonly _buttonIndexToObservableNameMap;
  43785. /**
  43786. * Creates a new GearVRController from a gamepad
  43787. * @param vrGamepad the gamepad that the controller should be created from
  43788. */
  43789. constructor(vrGamepad: any);
  43790. /**
  43791. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43792. * @param scene scene in which to add meshes
  43793. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43794. */
  43795. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43796. /**
  43797. * Called once for each button that changed state since the last frame
  43798. * @param buttonIdx Which button index changed
  43799. * @param state New state of the button
  43800. * @param changes Which properties on the state changed since last frame
  43801. */
  43802. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43803. }
  43804. }
  43805. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43806. import { Scene } from "babylonjs/scene";
  43807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43808. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43809. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43810. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43811. /**
  43812. * Generic Controller
  43813. */
  43814. export class GenericController extends WebVRController {
  43815. /**
  43816. * Base Url for the controller model.
  43817. */
  43818. static readonly MODEL_BASE_URL: string;
  43819. /**
  43820. * File name for the controller model.
  43821. */
  43822. static readonly MODEL_FILENAME: string;
  43823. /**
  43824. * Creates a new GenericController from a gamepad
  43825. * @param vrGamepad the gamepad that the controller should be created from
  43826. */
  43827. constructor(vrGamepad: any);
  43828. /**
  43829. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43830. * @param scene scene in which to add meshes
  43831. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43832. */
  43833. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43834. /**
  43835. * Called once for each button that changed state since the last frame
  43836. * @param buttonIdx Which button index changed
  43837. * @param state New state of the button
  43838. * @param changes Which properties on the state changed since last frame
  43839. */
  43840. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43841. }
  43842. }
  43843. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43844. import { Observable } from "babylonjs/Misc/observable";
  43845. import { Scene } from "babylonjs/scene";
  43846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43847. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43848. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43849. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43850. /**
  43851. * Oculus Touch Controller
  43852. */
  43853. export class OculusTouchController extends WebVRController {
  43854. /**
  43855. * Base Url for the controller model.
  43856. */
  43857. static MODEL_BASE_URL: string;
  43858. /**
  43859. * File name for the left controller model.
  43860. */
  43861. static MODEL_LEFT_FILENAME: string;
  43862. /**
  43863. * File name for the right controller model.
  43864. */
  43865. static MODEL_RIGHT_FILENAME: string;
  43866. /**
  43867. * Fired when the secondary trigger on this controller is modified
  43868. */
  43869. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43870. /**
  43871. * Fired when the thumb rest on this controller is modified
  43872. */
  43873. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43874. /**
  43875. * Creates a new OculusTouchController from a gamepad
  43876. * @param vrGamepad the gamepad that the controller should be created from
  43877. */
  43878. constructor(vrGamepad: any);
  43879. /**
  43880. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43881. * @param scene scene in which to add meshes
  43882. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43883. */
  43884. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43885. /**
  43886. * Fired when the A button on this controller is modified
  43887. */
  43888. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43889. /**
  43890. * Fired when the B button on this controller is modified
  43891. */
  43892. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43893. /**
  43894. * Fired when the X button on this controller is modified
  43895. */
  43896. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43897. /**
  43898. * Fired when the Y button on this controller is modified
  43899. */
  43900. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43901. /**
  43902. * Called once for each button that changed state since the last frame
  43903. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43904. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43905. * 2) secondary trigger (same)
  43906. * 3) A (right) X (left), touch, pressed = value
  43907. * 4) B / Y
  43908. * 5) thumb rest
  43909. * @param buttonIdx Which button index changed
  43910. * @param state New state of the button
  43911. * @param changes Which properties on the state changed since last frame
  43912. */
  43913. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43914. }
  43915. }
  43916. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43917. import { Scene } from "babylonjs/scene";
  43918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43919. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43920. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43921. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43922. import { Observable } from "babylonjs/Misc/observable";
  43923. /**
  43924. * Vive Controller
  43925. */
  43926. export class ViveController extends WebVRController {
  43927. /**
  43928. * Base Url for the controller model.
  43929. */
  43930. static MODEL_BASE_URL: string;
  43931. /**
  43932. * File name for the controller model.
  43933. */
  43934. static MODEL_FILENAME: string;
  43935. /**
  43936. * Creates a new ViveController from a gamepad
  43937. * @param vrGamepad the gamepad that the controller should be created from
  43938. */
  43939. constructor(vrGamepad: any);
  43940. /**
  43941. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43942. * @param scene scene in which to add meshes
  43943. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43944. */
  43945. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43946. /**
  43947. * Fired when the left button on this controller is modified
  43948. */
  43949. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43950. /**
  43951. * Fired when the right button on this controller is modified
  43952. */
  43953. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43954. /**
  43955. * Fired when the menu button on this controller is modified
  43956. */
  43957. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43958. /**
  43959. * Called once for each button that changed state since the last frame
  43960. * Vive mapping:
  43961. * 0: touchpad
  43962. * 1: trigger
  43963. * 2: left AND right buttons
  43964. * 3: menu button
  43965. * @param buttonIdx Which button index changed
  43966. * @param state New state of the button
  43967. * @param changes Which properties on the state changed since last frame
  43968. */
  43969. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43970. }
  43971. }
  43972. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43973. import { Observable } from "babylonjs/Misc/observable";
  43974. import { Scene } from "babylonjs/scene";
  43975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43976. import { Ray } from "babylonjs/Culling/ray";
  43977. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43978. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43979. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43980. /**
  43981. * Defines the WindowsMotionController object that the state of the windows motion controller
  43982. */
  43983. export class WindowsMotionController extends WebVRController {
  43984. /**
  43985. * The base url used to load the left and right controller models
  43986. */
  43987. static MODEL_BASE_URL: string;
  43988. /**
  43989. * The name of the left controller model file
  43990. */
  43991. static MODEL_LEFT_FILENAME: string;
  43992. /**
  43993. * The name of the right controller model file
  43994. */
  43995. static MODEL_RIGHT_FILENAME: string;
  43996. /**
  43997. * The controller name prefix for this controller type
  43998. */
  43999. static readonly GAMEPAD_ID_PREFIX: string;
  44000. /**
  44001. * The controller id pattern for this controller type
  44002. */
  44003. private static readonly GAMEPAD_ID_PATTERN;
  44004. private _loadedMeshInfo;
  44005. private readonly _mapping;
  44006. /**
  44007. * Fired when the trackpad on this controller is clicked
  44008. */
  44009. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44010. /**
  44011. * Fired when the trackpad on this controller is modified
  44012. */
  44013. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44014. /**
  44015. * The current x and y values of this controller's trackpad
  44016. */
  44017. trackpad: StickValues;
  44018. /**
  44019. * Creates a new WindowsMotionController from a gamepad
  44020. * @param vrGamepad the gamepad that the controller should be created from
  44021. */
  44022. constructor(vrGamepad: any);
  44023. /**
  44024. * Fired when the trigger on this controller is modified
  44025. */
  44026. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44027. /**
  44028. * Fired when the menu button on this controller is modified
  44029. */
  44030. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44031. /**
  44032. * Fired when the grip button on this controller is modified
  44033. */
  44034. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44035. /**
  44036. * Fired when the thumbstick button on this controller is modified
  44037. */
  44038. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44039. /**
  44040. * Fired when the touchpad button on this controller is modified
  44041. */
  44042. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44043. /**
  44044. * Fired when the touchpad values on this controller are modified
  44045. */
  44046. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44047. private _updateTrackpad;
  44048. /**
  44049. * Called once per frame by the engine.
  44050. */
  44051. update(): void;
  44052. /**
  44053. * Called once for each button that changed state since the last frame
  44054. * @param buttonIdx Which button index changed
  44055. * @param state New state of the button
  44056. * @param changes Which properties on the state changed since last frame
  44057. */
  44058. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44059. /**
  44060. * Moves the buttons on the controller mesh based on their current state
  44061. * @param buttonName the name of the button to move
  44062. * @param buttonValue the value of the button which determines the buttons new position
  44063. */
  44064. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44065. /**
  44066. * Moves the axis on the controller mesh based on its current state
  44067. * @param axis the index of the axis
  44068. * @param axisValue the value of the axis which determines the meshes new position
  44069. * @hidden
  44070. */
  44071. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44072. /**
  44073. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44074. * @param scene scene in which to add meshes
  44075. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44076. */
  44077. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44078. /**
  44079. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44080. * can be transformed by button presses and axes values, based on this._mapping.
  44081. *
  44082. * @param scene scene in which the meshes exist
  44083. * @param meshes list of meshes that make up the controller model to process
  44084. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44085. */
  44086. private processModel;
  44087. private createMeshInfo;
  44088. /**
  44089. * Gets the ray of the controller in the direction the controller is pointing
  44090. * @param length the length the resulting ray should be
  44091. * @returns a ray in the direction the controller is pointing
  44092. */
  44093. getForwardRay(length?: number): Ray;
  44094. /**
  44095. * Disposes of the controller
  44096. */
  44097. dispose(): void;
  44098. }
  44099. }
  44100. declare module "babylonjs/Gamepads/Controllers/index" {
  44101. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44102. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44103. export * from "babylonjs/Gamepads/Controllers/genericController";
  44104. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44105. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44106. export * from "babylonjs/Gamepads/Controllers/viveController";
  44107. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44108. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44109. }
  44110. declare module "babylonjs/Gamepads/index" {
  44111. export * from "babylonjs/Gamepads/Controllers/index";
  44112. export * from "babylonjs/Gamepads/gamepad";
  44113. export * from "babylonjs/Gamepads/gamepadManager";
  44114. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44115. export * from "babylonjs/Gamepads/xboxGamepad";
  44116. }
  44117. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44118. import { Observable } from "babylonjs/Misc/observable";
  44119. import { Nullable } from "babylonjs/types";
  44120. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44122. import { Mesh } from "babylonjs/Meshes/mesh";
  44123. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44124. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44125. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44126. /**
  44127. * Single axis scale gizmo
  44128. */
  44129. export class AxisScaleGizmo extends Gizmo {
  44130. private _coloredMaterial;
  44131. /**
  44132. * Drag behavior responsible for the gizmos dragging interactions
  44133. */
  44134. dragBehavior: PointerDragBehavior;
  44135. private _pointerObserver;
  44136. /**
  44137. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44138. */
  44139. snapDistance: number;
  44140. /**
  44141. * Event that fires each time the gizmo snaps to a new location.
  44142. * * snapDistance is the the change in distance
  44143. */
  44144. onSnapObservable: Observable<{
  44145. snapDistance: number;
  44146. }>;
  44147. /**
  44148. * If the scaling operation should be done on all axis (default: false)
  44149. */
  44150. uniformScaling: boolean;
  44151. /**
  44152. * Creates an AxisScaleGizmo
  44153. * @param gizmoLayer The utility layer the gizmo will be added to
  44154. * @param dragAxis The axis which the gizmo will be able to scale on
  44155. * @param color The color of the gizmo
  44156. */
  44157. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44158. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44159. /**
  44160. * Disposes of the gizmo
  44161. */
  44162. dispose(): void;
  44163. /**
  44164. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44165. * @param mesh The mesh to replace the default mesh of the gizmo
  44166. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44167. */
  44168. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44169. }
  44170. }
  44171. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44172. import { Observable } from "babylonjs/Misc/observable";
  44173. import { Nullable } from "babylonjs/types";
  44174. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44176. import { Mesh } from "babylonjs/Meshes/mesh";
  44177. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44178. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44179. import "babylonjs/Meshes/Builders/boxBuilder";
  44180. /**
  44181. * Bounding box gizmo
  44182. */
  44183. export class BoundingBoxGizmo extends Gizmo {
  44184. private _lineBoundingBox;
  44185. private _rotateSpheresParent;
  44186. private _scaleBoxesParent;
  44187. private _boundingDimensions;
  44188. private _renderObserver;
  44189. private _pointerObserver;
  44190. private _scaleDragSpeed;
  44191. private _tmpQuaternion;
  44192. private _tmpVector;
  44193. private _tmpRotationMatrix;
  44194. /**
  44195. * 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)
  44196. */
  44197. ignoreChildren: boolean;
  44198. /**
  44199. * 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)
  44200. */
  44201. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44202. /**
  44203. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44204. */
  44205. rotationSphereSize: number;
  44206. /**
  44207. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44208. */
  44209. scaleBoxSize: number;
  44210. /**
  44211. * 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)
  44212. */
  44213. fixedDragMeshScreenSize: boolean;
  44214. /**
  44215. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44216. */
  44217. fixedDragMeshScreenSizeDistanceFactor: number;
  44218. /**
  44219. * Fired when a rotation sphere or scale box is dragged
  44220. */
  44221. onDragStartObservable: Observable<{}>;
  44222. /**
  44223. * Fired when a scale box is dragged
  44224. */
  44225. onScaleBoxDragObservable: Observable<{}>;
  44226. /**
  44227. * Fired when a scale box drag is ended
  44228. */
  44229. onScaleBoxDragEndObservable: Observable<{}>;
  44230. /**
  44231. * Fired when a rotation sphere is dragged
  44232. */
  44233. onRotationSphereDragObservable: Observable<{}>;
  44234. /**
  44235. * Fired when a rotation sphere drag is ended
  44236. */
  44237. onRotationSphereDragEndObservable: Observable<{}>;
  44238. /**
  44239. * 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)
  44240. */
  44241. scalePivot: Nullable<Vector3>;
  44242. /**
  44243. * Mesh used as a pivot to rotate the attached mesh
  44244. */
  44245. private _anchorMesh;
  44246. private _existingMeshScale;
  44247. private _dragMesh;
  44248. private pointerDragBehavior;
  44249. private coloredMaterial;
  44250. private hoverColoredMaterial;
  44251. /**
  44252. * Sets the color of the bounding box gizmo
  44253. * @param color the color to set
  44254. */
  44255. setColor(color: Color3): void;
  44256. /**
  44257. * Creates an BoundingBoxGizmo
  44258. * @param gizmoLayer The utility layer the gizmo will be added to
  44259. * @param color The color of the gizmo
  44260. */
  44261. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44262. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44263. private _selectNode;
  44264. /**
  44265. * Updates the bounding box information for the Gizmo
  44266. */
  44267. updateBoundingBox(): void;
  44268. private _updateRotationSpheres;
  44269. private _updateScaleBoxes;
  44270. /**
  44271. * Enables rotation on the specified axis and disables rotation on the others
  44272. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44273. */
  44274. setEnabledRotationAxis(axis: string): void;
  44275. /**
  44276. * Enables/disables scaling
  44277. * @param enable if scaling should be enabled
  44278. */
  44279. setEnabledScaling(enable: boolean): void;
  44280. private _updateDummy;
  44281. /**
  44282. * Enables a pointer drag behavior on the bounding box of the gizmo
  44283. */
  44284. enableDragBehavior(): void;
  44285. /**
  44286. * Disposes of the gizmo
  44287. */
  44288. dispose(): void;
  44289. /**
  44290. * 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)
  44291. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44292. * @returns the bounding box mesh with the passed in mesh as a child
  44293. */
  44294. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44295. /**
  44296. * CustomMeshes are not supported by this gizmo
  44297. * @param mesh The mesh to replace the default mesh of the gizmo
  44298. */
  44299. setCustomMesh(mesh: Mesh): void;
  44300. }
  44301. }
  44302. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44303. import { Observable } from "babylonjs/Misc/observable";
  44304. import { Nullable } from "babylonjs/types";
  44305. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44307. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44308. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44309. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44310. import "babylonjs/Meshes/Builders/linesBuilder";
  44311. /**
  44312. * Single plane rotation gizmo
  44313. */
  44314. export class PlaneRotationGizmo extends Gizmo {
  44315. /**
  44316. * Drag behavior responsible for the gizmos dragging interactions
  44317. */
  44318. dragBehavior: PointerDragBehavior;
  44319. private _pointerObserver;
  44320. /**
  44321. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44322. */
  44323. snapDistance: number;
  44324. /**
  44325. * Event that fires each time the gizmo snaps to a new location.
  44326. * * snapDistance is the the change in distance
  44327. */
  44328. onSnapObservable: Observable<{
  44329. snapDistance: number;
  44330. }>;
  44331. /**
  44332. * Creates a PlaneRotationGizmo
  44333. * @param gizmoLayer The utility layer the gizmo will be added to
  44334. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44335. * @param color The color of the gizmo
  44336. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44337. */
  44338. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44339. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44340. /**
  44341. * Disposes of the gizmo
  44342. */
  44343. dispose(): void;
  44344. }
  44345. }
  44346. declare module "babylonjs/Gizmos/rotationGizmo" {
  44347. import { Observable } from "babylonjs/Misc/observable";
  44348. import { Nullable } from "babylonjs/types";
  44349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44350. import { Mesh } from "babylonjs/Meshes/mesh";
  44351. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44352. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44353. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44354. /**
  44355. * Gizmo that enables rotating a mesh along 3 axis
  44356. */
  44357. export class RotationGizmo extends Gizmo {
  44358. /**
  44359. * Internal gizmo used for interactions on the x axis
  44360. */
  44361. xGizmo: PlaneRotationGizmo;
  44362. /**
  44363. * Internal gizmo used for interactions on the y axis
  44364. */
  44365. yGizmo: PlaneRotationGizmo;
  44366. /**
  44367. * Internal gizmo used for interactions on the z axis
  44368. */
  44369. zGizmo: PlaneRotationGizmo;
  44370. /** Fires an event when any of it's sub gizmos are dragged */
  44371. onDragStartObservable: Observable<{}>;
  44372. /** Fires an event when any of it's sub gizmos are released from dragging */
  44373. onDragEndObservable: Observable<{}>;
  44374. attachedMesh: Nullable<AbstractMesh>;
  44375. /**
  44376. * Creates a RotationGizmo
  44377. * @param gizmoLayer The utility layer the gizmo will be added to
  44378. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44379. */
  44380. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44381. updateGizmoRotationToMatchAttachedMesh: boolean;
  44382. /**
  44383. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44384. */
  44385. snapDistance: number;
  44386. /**
  44387. * Ratio for the scale of the gizmo (Default: 1)
  44388. */
  44389. scaleRatio: number;
  44390. /**
  44391. * Disposes of the gizmo
  44392. */
  44393. dispose(): void;
  44394. /**
  44395. * CustomMeshes are not supported by this gizmo
  44396. * @param mesh The mesh to replace the default mesh of the gizmo
  44397. */
  44398. setCustomMesh(mesh: Mesh): void;
  44399. }
  44400. }
  44401. declare module "babylonjs/Gizmos/positionGizmo" {
  44402. import { Observable } from "babylonjs/Misc/observable";
  44403. import { Nullable } from "babylonjs/types";
  44404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44405. import { Mesh } from "babylonjs/Meshes/mesh";
  44406. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44407. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44408. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44409. /**
  44410. * Gizmo that enables dragging a mesh along 3 axis
  44411. */
  44412. export class PositionGizmo extends Gizmo {
  44413. /**
  44414. * Internal gizmo used for interactions on the x axis
  44415. */
  44416. xGizmo: AxisDragGizmo;
  44417. /**
  44418. * Internal gizmo used for interactions on the y axis
  44419. */
  44420. yGizmo: AxisDragGizmo;
  44421. /**
  44422. * Internal gizmo used for interactions on the z axis
  44423. */
  44424. zGizmo: AxisDragGizmo;
  44425. /** Fires an event when any of it's sub gizmos are dragged */
  44426. onDragStartObservable: Observable<{}>;
  44427. /** Fires an event when any of it's sub gizmos are released from dragging */
  44428. onDragEndObservable: Observable<{}>;
  44429. attachedMesh: Nullable<AbstractMesh>;
  44430. /**
  44431. * Creates a PositionGizmo
  44432. * @param gizmoLayer The utility layer the gizmo will be added to
  44433. */
  44434. constructor(gizmoLayer?: UtilityLayerRenderer);
  44435. updateGizmoRotationToMatchAttachedMesh: boolean;
  44436. /**
  44437. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44438. */
  44439. snapDistance: number;
  44440. /**
  44441. * Ratio for the scale of the gizmo (Default: 1)
  44442. */
  44443. scaleRatio: number;
  44444. /**
  44445. * Disposes of the gizmo
  44446. */
  44447. dispose(): void;
  44448. /**
  44449. * CustomMeshes are not supported by this gizmo
  44450. * @param mesh The mesh to replace the default mesh of the gizmo
  44451. */
  44452. setCustomMesh(mesh: Mesh): void;
  44453. }
  44454. }
  44455. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44456. import { Scene } from "babylonjs/scene";
  44457. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44458. import { Mesh } from "babylonjs/Meshes/mesh";
  44459. import { Nullable } from "babylonjs/types";
  44460. /**
  44461. * Class containing static functions to help procedurally build meshes
  44462. */
  44463. export class PolyhedronBuilder {
  44464. /**
  44465. * Creates a polyhedron mesh
  44466. * * 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
  44467. * * The parameter `size` (positive float, default 1) sets the polygon size
  44468. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44469. * * 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`
  44470. * * 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
  44471. * * 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)`)
  44472. * * 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
  44473. * * 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
  44474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44477. * @param name defines the name of the mesh
  44478. * @param options defines the options used to create the mesh
  44479. * @param scene defines the hosting scene
  44480. * @returns the polyhedron mesh
  44481. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44482. */
  44483. static CreatePolyhedron(name: string, options: {
  44484. type?: number;
  44485. size?: number;
  44486. sizeX?: number;
  44487. sizeY?: number;
  44488. sizeZ?: number;
  44489. custom?: any;
  44490. faceUV?: Vector4[];
  44491. faceColors?: Color4[];
  44492. flat?: boolean;
  44493. updatable?: boolean;
  44494. sideOrientation?: number;
  44495. frontUVs?: Vector4;
  44496. backUVs?: Vector4;
  44497. }, scene?: Nullable<Scene>): Mesh;
  44498. }
  44499. }
  44500. declare module "babylonjs/Gizmos/scaleGizmo" {
  44501. import { Observable } from "babylonjs/Misc/observable";
  44502. import { Nullable } from "babylonjs/types";
  44503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44504. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44505. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44506. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44507. /**
  44508. * Gizmo that enables scaling a mesh along 3 axis
  44509. */
  44510. export class ScaleGizmo extends Gizmo {
  44511. /**
  44512. * Internal gizmo used for interactions on the x axis
  44513. */
  44514. xGizmo: AxisScaleGizmo;
  44515. /**
  44516. * Internal gizmo used for interactions on the y axis
  44517. */
  44518. yGizmo: AxisScaleGizmo;
  44519. /**
  44520. * Internal gizmo used for interactions on the z axis
  44521. */
  44522. zGizmo: AxisScaleGizmo;
  44523. /**
  44524. * Internal gizmo used to scale all axis equally
  44525. */
  44526. uniformScaleGizmo: AxisScaleGizmo;
  44527. /** Fires an event when any of it's sub gizmos are dragged */
  44528. onDragStartObservable: Observable<{}>;
  44529. /** Fires an event when any of it's sub gizmos are released from dragging */
  44530. onDragEndObservable: Observable<{}>;
  44531. attachedMesh: Nullable<AbstractMesh>;
  44532. /**
  44533. * Creates a ScaleGizmo
  44534. * @param gizmoLayer The utility layer the gizmo will be added to
  44535. */
  44536. constructor(gizmoLayer?: UtilityLayerRenderer);
  44537. updateGizmoRotationToMatchAttachedMesh: boolean;
  44538. /**
  44539. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44540. */
  44541. snapDistance: number;
  44542. /**
  44543. * Ratio for the scale of the gizmo (Default: 1)
  44544. */
  44545. scaleRatio: number;
  44546. /**
  44547. * Disposes of the gizmo
  44548. */
  44549. dispose(): void;
  44550. }
  44551. }
  44552. declare module "babylonjs/Gizmos/gizmoManager" {
  44553. import { Observable } from "babylonjs/Misc/observable";
  44554. import { Nullable } from "babylonjs/types";
  44555. import { Scene, IDisposable } from "babylonjs/scene";
  44556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44557. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44558. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44559. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44560. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44561. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44562. /**
  44563. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44564. */
  44565. export class GizmoManager implements IDisposable {
  44566. private scene;
  44567. /**
  44568. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44569. */
  44570. gizmos: {
  44571. positionGizmo: Nullable<PositionGizmo>;
  44572. rotationGizmo: Nullable<RotationGizmo>;
  44573. scaleGizmo: Nullable<ScaleGizmo>;
  44574. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44575. };
  44576. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44577. clearGizmoOnEmptyPointerEvent: boolean;
  44578. /** Fires an event when the manager is attached to a mesh */
  44579. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44580. private _gizmosEnabled;
  44581. private _pointerObserver;
  44582. private _attachedMesh;
  44583. private _boundingBoxColor;
  44584. private _defaultUtilityLayer;
  44585. private _defaultKeepDepthUtilityLayer;
  44586. /**
  44587. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44588. */
  44589. boundingBoxDragBehavior: SixDofDragBehavior;
  44590. /**
  44591. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44592. */
  44593. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44594. /**
  44595. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44596. */
  44597. usePointerToAttachGizmos: boolean;
  44598. /**
  44599. * Instatiates a gizmo manager
  44600. * @param scene the scene to overlay the gizmos on top of
  44601. */
  44602. constructor(scene: Scene);
  44603. /**
  44604. * Attaches a set of gizmos to the specified mesh
  44605. * @param mesh The mesh the gizmo's should be attached to
  44606. */
  44607. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44608. /**
  44609. * If the position gizmo is enabled
  44610. */
  44611. positionGizmoEnabled: boolean;
  44612. /**
  44613. * If the rotation gizmo is enabled
  44614. */
  44615. rotationGizmoEnabled: boolean;
  44616. /**
  44617. * If the scale gizmo is enabled
  44618. */
  44619. scaleGizmoEnabled: boolean;
  44620. /**
  44621. * If the boundingBox gizmo is enabled
  44622. */
  44623. boundingBoxGizmoEnabled: boolean;
  44624. /**
  44625. * Disposes of the gizmo manager
  44626. */
  44627. dispose(): void;
  44628. }
  44629. }
  44630. declare module "babylonjs/Lights/directionalLight" {
  44631. import { Camera } from "babylonjs/Cameras/camera";
  44632. import { Scene } from "babylonjs/scene";
  44633. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44635. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44636. import { Effect } from "babylonjs/Materials/effect";
  44637. /**
  44638. * A directional light is defined by a direction (what a surprise!).
  44639. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44640. * 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.
  44641. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44642. */
  44643. export class DirectionalLight extends ShadowLight {
  44644. private _shadowFrustumSize;
  44645. /**
  44646. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44647. */
  44648. /**
  44649. * Specifies a fix frustum size for the shadow generation.
  44650. */
  44651. shadowFrustumSize: number;
  44652. private _shadowOrthoScale;
  44653. /**
  44654. * Gets the shadow projection scale against the optimal computed one.
  44655. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44656. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44657. */
  44658. /**
  44659. * Sets the shadow projection scale against the optimal computed one.
  44660. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44661. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44662. */
  44663. shadowOrthoScale: number;
  44664. /**
  44665. * Automatically compute the projection matrix to best fit (including all the casters)
  44666. * on each frame.
  44667. */
  44668. autoUpdateExtends: boolean;
  44669. private _orthoLeft;
  44670. private _orthoRight;
  44671. private _orthoTop;
  44672. private _orthoBottom;
  44673. /**
  44674. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44675. * The directional light is emitted from everywhere in the given direction.
  44676. * It can cast shadows.
  44677. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44678. * @param name The friendly name of the light
  44679. * @param direction The direction of the light
  44680. * @param scene The scene the light belongs to
  44681. */
  44682. constructor(name: string, direction: Vector3, scene: Scene);
  44683. /**
  44684. * Returns the string "DirectionalLight".
  44685. * @return The class name
  44686. */
  44687. getClassName(): string;
  44688. /**
  44689. * Returns the integer 1.
  44690. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44691. */
  44692. getTypeID(): number;
  44693. /**
  44694. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44695. * Returns the DirectionalLight Shadow projection matrix.
  44696. */
  44697. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44698. /**
  44699. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44700. * Returns the DirectionalLight Shadow projection matrix.
  44701. */
  44702. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44703. /**
  44704. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44705. * Returns the DirectionalLight Shadow projection matrix.
  44706. */
  44707. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44708. protected _buildUniformLayout(): void;
  44709. /**
  44710. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44711. * @param effect The effect to update
  44712. * @param lightIndex The index of the light in the effect to update
  44713. * @returns The directional light
  44714. */
  44715. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44716. /**
  44717. * Gets the minZ used for shadow according to both the scene and the light.
  44718. *
  44719. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44720. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44721. * @param activeCamera The camera we are returning the min for
  44722. * @returns the depth min z
  44723. */
  44724. getDepthMinZ(activeCamera: Camera): number;
  44725. /**
  44726. * Gets the maxZ used for shadow according to both the scene and the light.
  44727. *
  44728. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44729. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44730. * @param activeCamera The camera we are returning the max for
  44731. * @returns the depth max z
  44732. */
  44733. getDepthMaxZ(activeCamera: Camera): number;
  44734. /**
  44735. * Prepares the list of defines specific to the light type.
  44736. * @param defines the list of defines
  44737. * @param lightIndex defines the index of the light for the effect
  44738. */
  44739. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44740. }
  44741. }
  44742. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44743. import { Mesh } from "babylonjs/Meshes/mesh";
  44744. /**
  44745. * Class containing static functions to help procedurally build meshes
  44746. */
  44747. export class HemisphereBuilder {
  44748. /**
  44749. * Creates a hemisphere mesh
  44750. * @param name defines the name of the mesh
  44751. * @param options defines the options used to create the mesh
  44752. * @param scene defines the hosting scene
  44753. * @returns the hemisphere mesh
  44754. */
  44755. static CreateHemisphere(name: string, options: {
  44756. segments?: number;
  44757. diameter?: number;
  44758. sideOrientation?: number;
  44759. }, scene: any): Mesh;
  44760. }
  44761. }
  44762. declare module "babylonjs/Lights/spotLight" {
  44763. import { Nullable } from "babylonjs/types";
  44764. import { Scene } from "babylonjs/scene";
  44765. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44767. import { Effect } from "babylonjs/Materials/effect";
  44768. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44769. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44770. /**
  44771. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44772. * These values define a cone of light starting from the position, emitting toward the direction.
  44773. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44774. * and the exponent defines the speed of the decay of the light with distance (reach).
  44775. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44776. */
  44777. export class SpotLight extends ShadowLight {
  44778. private _angle;
  44779. private _innerAngle;
  44780. private _cosHalfAngle;
  44781. private _lightAngleScale;
  44782. private _lightAngleOffset;
  44783. /**
  44784. * Gets the cone angle of the spot light in Radians.
  44785. */
  44786. /**
  44787. * Sets the cone angle of the spot light in Radians.
  44788. */
  44789. angle: number;
  44790. /**
  44791. * Only used in gltf falloff mode, this defines the angle where
  44792. * the directional falloff will start before cutting at angle which could be seen
  44793. * as outer angle.
  44794. */
  44795. /**
  44796. * Only used in gltf falloff mode, this defines the angle where
  44797. * the directional falloff will start before cutting at angle which could be seen
  44798. * as outer angle.
  44799. */
  44800. innerAngle: number;
  44801. private _shadowAngleScale;
  44802. /**
  44803. * Allows scaling the angle of the light for shadow generation only.
  44804. */
  44805. /**
  44806. * Allows scaling the angle of the light for shadow generation only.
  44807. */
  44808. shadowAngleScale: number;
  44809. /**
  44810. * The light decay speed with the distance from the emission spot.
  44811. */
  44812. exponent: number;
  44813. private _projectionTextureMatrix;
  44814. /**
  44815. * Allows reading the projecton texture
  44816. */
  44817. readonly projectionTextureMatrix: Matrix;
  44818. protected _projectionTextureLightNear: number;
  44819. /**
  44820. * Gets the near clip of the Spotlight for texture projection.
  44821. */
  44822. /**
  44823. * Sets the near clip of the Spotlight for texture projection.
  44824. */
  44825. projectionTextureLightNear: number;
  44826. protected _projectionTextureLightFar: number;
  44827. /**
  44828. * Gets the far clip of the Spotlight for texture projection.
  44829. */
  44830. /**
  44831. * Sets the far clip of the Spotlight for texture projection.
  44832. */
  44833. projectionTextureLightFar: number;
  44834. protected _projectionTextureUpDirection: Vector3;
  44835. /**
  44836. * Gets the Up vector of the Spotlight for texture projection.
  44837. */
  44838. /**
  44839. * Sets the Up vector of the Spotlight for texture projection.
  44840. */
  44841. projectionTextureUpDirection: Vector3;
  44842. private _projectionTexture;
  44843. /**
  44844. * Gets the projection texture of the light.
  44845. */
  44846. /**
  44847. * Sets the projection texture of the light.
  44848. */
  44849. projectionTexture: Nullable<BaseTexture>;
  44850. private _projectionTextureViewLightDirty;
  44851. private _projectionTextureProjectionLightDirty;
  44852. private _projectionTextureDirty;
  44853. private _projectionTextureViewTargetVector;
  44854. private _projectionTextureViewLightMatrix;
  44855. private _projectionTextureProjectionLightMatrix;
  44856. private _projectionTextureScalingMatrix;
  44857. /**
  44858. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44859. * It can cast shadows.
  44860. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44861. * @param name The light friendly name
  44862. * @param position The position of the spot light in the scene
  44863. * @param direction The direction of the light in the scene
  44864. * @param angle The cone angle of the light in Radians
  44865. * @param exponent The light decay speed with the distance from the emission spot
  44866. * @param scene The scene the lights belongs to
  44867. */
  44868. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44869. /**
  44870. * Returns the string "SpotLight".
  44871. * @returns the class name
  44872. */
  44873. getClassName(): string;
  44874. /**
  44875. * Returns the integer 2.
  44876. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44877. */
  44878. getTypeID(): number;
  44879. /**
  44880. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44881. */
  44882. protected _setDirection(value: Vector3): void;
  44883. /**
  44884. * Overrides the position setter to recompute the projection texture view light Matrix.
  44885. */
  44886. protected _setPosition(value: Vector3): void;
  44887. /**
  44888. * 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.
  44889. * Returns the SpotLight.
  44890. */
  44891. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44892. protected _computeProjectionTextureViewLightMatrix(): void;
  44893. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44894. /**
  44895. * Main function for light texture projection matrix computing.
  44896. */
  44897. protected _computeProjectionTextureMatrix(): void;
  44898. protected _buildUniformLayout(): void;
  44899. private _computeAngleValues;
  44900. /**
  44901. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44902. * @param effect The effect to update
  44903. * @param lightIndex The index of the light in the effect to update
  44904. * @returns The spot light
  44905. */
  44906. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44907. /**
  44908. * Disposes the light and the associated resources.
  44909. */
  44910. dispose(): void;
  44911. /**
  44912. * Prepares the list of defines specific to the light type.
  44913. * @param defines the list of defines
  44914. * @param lightIndex defines the index of the light for the effect
  44915. */
  44916. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44917. }
  44918. }
  44919. declare module "babylonjs/Gizmos/lightGizmo" {
  44920. import { Nullable } from "babylonjs/types";
  44921. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44922. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44923. import { Light } from "babylonjs/Lights/light";
  44924. /**
  44925. * Gizmo that enables viewing a light
  44926. */
  44927. export class LightGizmo extends Gizmo {
  44928. private _lightMesh;
  44929. private _material;
  44930. /**
  44931. * Creates a LightGizmo
  44932. * @param gizmoLayer The utility layer the gizmo will be added to
  44933. */
  44934. constructor(gizmoLayer?: UtilityLayerRenderer);
  44935. private _light;
  44936. /**
  44937. * The light that the gizmo is attached to
  44938. */
  44939. light: Nullable<Light>;
  44940. /**
  44941. * @hidden
  44942. * Updates the gizmo to match the attached mesh's position/rotation
  44943. */
  44944. protected _update(): void;
  44945. private static _Scale;
  44946. /**
  44947. * Creates the lines for a light mesh
  44948. */
  44949. private static _createLightLines;
  44950. private static _CreateHemisphericLightMesh;
  44951. private static _CreatePointLightMesh;
  44952. private static _CreateSpotLightMesh;
  44953. private static _CreateDirectionalLightMesh;
  44954. }
  44955. }
  44956. declare module "babylonjs/Gizmos/index" {
  44957. export * from "babylonjs/Gizmos/axisDragGizmo";
  44958. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44959. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44960. export * from "babylonjs/Gizmos/gizmo";
  44961. export * from "babylonjs/Gizmos/gizmoManager";
  44962. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44963. export * from "babylonjs/Gizmos/positionGizmo";
  44964. export * from "babylonjs/Gizmos/rotationGizmo";
  44965. export * from "babylonjs/Gizmos/scaleGizmo";
  44966. export * from "babylonjs/Gizmos/lightGizmo";
  44967. }
  44968. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44969. /** @hidden */
  44970. export var backgroundFragmentDeclaration: {
  44971. name: string;
  44972. shader: string;
  44973. };
  44974. }
  44975. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44976. /** @hidden */
  44977. export var backgroundUboDeclaration: {
  44978. name: string;
  44979. shader: string;
  44980. };
  44981. }
  44982. declare module "babylonjs/Shaders/background.fragment" {
  44983. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44984. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44985. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44986. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44987. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44988. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44989. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44990. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44991. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44992. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44993. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44994. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44995. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44996. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44997. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44998. /** @hidden */
  44999. export var backgroundPixelShader: {
  45000. name: string;
  45001. shader: string;
  45002. };
  45003. }
  45004. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45005. /** @hidden */
  45006. export var backgroundVertexDeclaration: {
  45007. name: string;
  45008. shader: string;
  45009. };
  45010. }
  45011. declare module "babylonjs/Shaders/background.vertex" {
  45012. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45013. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45014. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45015. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45016. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45017. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45018. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45019. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45020. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45021. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45022. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45023. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45024. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45025. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45026. /** @hidden */
  45027. export var backgroundVertexShader: {
  45028. name: string;
  45029. shader: string;
  45030. };
  45031. }
  45032. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45033. import { Nullable, int, float } from "babylonjs/types";
  45034. import { Scene } from "babylonjs/scene";
  45035. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45036. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45038. import { Mesh } from "babylonjs/Meshes/mesh";
  45039. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45040. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45041. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45042. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45043. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45044. import "babylonjs/Shaders/background.fragment";
  45045. import "babylonjs/Shaders/background.vertex";
  45046. /**
  45047. * Background material used to create an efficient environement around your scene.
  45048. */
  45049. export class BackgroundMaterial extends PushMaterial {
  45050. /**
  45051. * Standard reflectance value at parallel view angle.
  45052. */
  45053. static StandardReflectance0: number;
  45054. /**
  45055. * Standard reflectance value at grazing angle.
  45056. */
  45057. static StandardReflectance90: number;
  45058. protected _primaryColor: Color3;
  45059. /**
  45060. * Key light Color (multiply against the environement texture)
  45061. */
  45062. primaryColor: Color3;
  45063. protected __perceptualColor: Nullable<Color3>;
  45064. /**
  45065. * Experimental Internal Use Only.
  45066. *
  45067. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45068. * This acts as a helper to set the primary color to a more "human friendly" value.
  45069. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45070. * output color as close as possible from the chosen value.
  45071. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45072. * part of lighting setup.)
  45073. */
  45074. _perceptualColor: Nullable<Color3>;
  45075. protected _primaryColorShadowLevel: float;
  45076. /**
  45077. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45078. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45079. */
  45080. primaryColorShadowLevel: float;
  45081. protected _primaryColorHighlightLevel: float;
  45082. /**
  45083. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45084. * The primary color is used at the level chosen to define what the white area would look.
  45085. */
  45086. primaryColorHighlightLevel: float;
  45087. protected _reflectionTexture: Nullable<BaseTexture>;
  45088. /**
  45089. * Reflection Texture used in the material.
  45090. * Should be author in a specific way for the best result (refer to the documentation).
  45091. */
  45092. reflectionTexture: Nullable<BaseTexture>;
  45093. protected _reflectionBlur: float;
  45094. /**
  45095. * Reflection Texture level of blur.
  45096. *
  45097. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45098. * texture twice.
  45099. */
  45100. reflectionBlur: float;
  45101. protected _diffuseTexture: Nullable<BaseTexture>;
  45102. /**
  45103. * Diffuse Texture used in the material.
  45104. * Should be author in a specific way for the best result (refer to the documentation).
  45105. */
  45106. diffuseTexture: Nullable<BaseTexture>;
  45107. protected _shadowLights: Nullable<IShadowLight[]>;
  45108. /**
  45109. * Specify the list of lights casting shadow on the material.
  45110. * All scene shadow lights will be included if null.
  45111. */
  45112. shadowLights: Nullable<IShadowLight[]>;
  45113. protected _shadowLevel: float;
  45114. /**
  45115. * Helps adjusting the shadow to a softer level if required.
  45116. * 0 means black shadows and 1 means no shadows.
  45117. */
  45118. shadowLevel: float;
  45119. protected _sceneCenter: Vector3;
  45120. /**
  45121. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45122. * It is usually zero but might be interesting to modify according to your setup.
  45123. */
  45124. sceneCenter: Vector3;
  45125. protected _opacityFresnel: boolean;
  45126. /**
  45127. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45128. * This helps ensuring a nice transition when the camera goes under the ground.
  45129. */
  45130. opacityFresnel: boolean;
  45131. protected _reflectionFresnel: boolean;
  45132. /**
  45133. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45134. * This helps adding a mirror texture on the ground.
  45135. */
  45136. reflectionFresnel: boolean;
  45137. protected _reflectionFalloffDistance: number;
  45138. /**
  45139. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45140. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45141. */
  45142. reflectionFalloffDistance: number;
  45143. protected _reflectionAmount: number;
  45144. /**
  45145. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45146. */
  45147. reflectionAmount: number;
  45148. protected _reflectionReflectance0: number;
  45149. /**
  45150. * This specifies the weight of the reflection at grazing angle.
  45151. */
  45152. reflectionReflectance0: number;
  45153. protected _reflectionReflectance90: number;
  45154. /**
  45155. * This specifies the weight of the reflection at a perpendicular point of view.
  45156. */
  45157. reflectionReflectance90: number;
  45158. /**
  45159. * Sets the reflection reflectance fresnel values according to the default standard
  45160. * empirically know to work well :-)
  45161. */
  45162. reflectionStandardFresnelWeight: number;
  45163. protected _useRGBColor: boolean;
  45164. /**
  45165. * Helps to directly use the maps channels instead of their level.
  45166. */
  45167. useRGBColor: boolean;
  45168. protected _enableNoise: boolean;
  45169. /**
  45170. * This helps reducing the banding effect that could occur on the background.
  45171. */
  45172. enableNoise: boolean;
  45173. /**
  45174. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45175. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45176. * Recommended to be keep at 1.0 except for special cases.
  45177. */
  45178. fovMultiplier: number;
  45179. private _fovMultiplier;
  45180. /**
  45181. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45182. */
  45183. useEquirectangularFOV: boolean;
  45184. private _maxSimultaneousLights;
  45185. /**
  45186. * Number of Simultaneous lights allowed on the material.
  45187. */
  45188. maxSimultaneousLights: int;
  45189. /**
  45190. * Default configuration related to image processing available in the Background Material.
  45191. */
  45192. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45193. /**
  45194. * Keep track of the image processing observer to allow dispose and replace.
  45195. */
  45196. private _imageProcessingObserver;
  45197. /**
  45198. * Attaches a new image processing configuration to the PBR Material.
  45199. * @param configuration (if null the scene configuration will be use)
  45200. */
  45201. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45202. /**
  45203. * Gets the image processing configuration used either in this material.
  45204. */
  45205. /**
  45206. * Sets the Default image processing configuration used either in the this material.
  45207. *
  45208. * If sets to null, the scene one is in use.
  45209. */
  45210. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45211. /**
  45212. * Gets wether the color curves effect is enabled.
  45213. */
  45214. /**
  45215. * Sets wether the color curves effect is enabled.
  45216. */
  45217. cameraColorCurvesEnabled: boolean;
  45218. /**
  45219. * Gets wether the color grading effect is enabled.
  45220. */
  45221. /**
  45222. * Gets wether the color grading effect is enabled.
  45223. */
  45224. cameraColorGradingEnabled: boolean;
  45225. /**
  45226. * Gets wether tonemapping is enabled or not.
  45227. */
  45228. /**
  45229. * Sets wether tonemapping is enabled or not
  45230. */
  45231. cameraToneMappingEnabled: boolean;
  45232. /**
  45233. * The camera exposure used on this material.
  45234. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45235. * This corresponds to a photographic exposure.
  45236. */
  45237. /**
  45238. * The camera exposure used on this material.
  45239. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45240. * This corresponds to a photographic exposure.
  45241. */
  45242. cameraExposure: float;
  45243. /**
  45244. * Gets The camera contrast used on this material.
  45245. */
  45246. /**
  45247. * Sets The camera contrast used on this material.
  45248. */
  45249. cameraContrast: float;
  45250. /**
  45251. * Gets the Color Grading 2D Lookup Texture.
  45252. */
  45253. /**
  45254. * Sets the Color Grading 2D Lookup Texture.
  45255. */
  45256. cameraColorGradingTexture: Nullable<BaseTexture>;
  45257. /**
  45258. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45259. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45260. * 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;
  45261. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45262. */
  45263. /**
  45264. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45265. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45266. * 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;
  45267. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45268. */
  45269. cameraColorCurves: Nullable<ColorCurves>;
  45270. /**
  45271. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45272. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45273. */
  45274. switchToBGR: boolean;
  45275. private _renderTargets;
  45276. private _reflectionControls;
  45277. private _white;
  45278. private _primaryShadowColor;
  45279. private _primaryHighlightColor;
  45280. /**
  45281. * Instantiates a Background Material in the given scene
  45282. * @param name The friendly name of the material
  45283. * @param scene The scene to add the material to
  45284. */
  45285. constructor(name: string, scene: Scene);
  45286. /**
  45287. * Gets a boolean indicating that current material needs to register RTT
  45288. */
  45289. readonly hasRenderTargetTextures: boolean;
  45290. /**
  45291. * The entire material has been created in order to prevent overdraw.
  45292. * @returns false
  45293. */
  45294. needAlphaTesting(): boolean;
  45295. /**
  45296. * The entire material has been created in order to prevent overdraw.
  45297. * @returns true if blending is enable
  45298. */
  45299. needAlphaBlending(): boolean;
  45300. /**
  45301. * Checks wether the material is ready to be rendered for a given mesh.
  45302. * @param mesh The mesh to render
  45303. * @param subMesh The submesh to check against
  45304. * @param useInstances Specify wether or not the material is used with instances
  45305. * @returns true if all the dependencies are ready (Textures, Effects...)
  45306. */
  45307. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45308. /**
  45309. * Compute the primary color according to the chosen perceptual color.
  45310. */
  45311. private _computePrimaryColorFromPerceptualColor;
  45312. /**
  45313. * Compute the highlights and shadow colors according to their chosen levels.
  45314. */
  45315. private _computePrimaryColors;
  45316. /**
  45317. * Build the uniform buffer used in the material.
  45318. */
  45319. buildUniformLayout(): void;
  45320. /**
  45321. * Unbind the material.
  45322. */
  45323. unbind(): void;
  45324. /**
  45325. * Bind only the world matrix to the material.
  45326. * @param world The world matrix to bind.
  45327. */
  45328. bindOnlyWorldMatrix(world: Matrix): void;
  45329. /**
  45330. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45331. * @param world The world matrix to bind.
  45332. * @param subMesh The submesh to bind for.
  45333. */
  45334. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45335. /**
  45336. * Dispose the material.
  45337. * @param forceDisposeEffect Force disposal of the associated effect.
  45338. * @param forceDisposeTextures Force disposal of the associated textures.
  45339. */
  45340. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45341. /**
  45342. * Clones the material.
  45343. * @param name The cloned name.
  45344. * @returns The cloned material.
  45345. */
  45346. clone(name: string): BackgroundMaterial;
  45347. /**
  45348. * Serializes the current material to its JSON representation.
  45349. * @returns The JSON representation.
  45350. */
  45351. serialize(): any;
  45352. /**
  45353. * Gets the class name of the material
  45354. * @returns "BackgroundMaterial"
  45355. */
  45356. getClassName(): string;
  45357. /**
  45358. * Parse a JSON input to create back a background material.
  45359. * @param source The JSON data to parse
  45360. * @param scene The scene to create the parsed material in
  45361. * @param rootUrl The root url of the assets the material depends upon
  45362. * @returns the instantiated BackgroundMaterial.
  45363. */
  45364. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45365. }
  45366. }
  45367. declare module "babylonjs/Helpers/environmentHelper" {
  45368. import { Observable } from "babylonjs/Misc/observable";
  45369. import { Nullable } from "babylonjs/types";
  45370. import { Scene } from "babylonjs/scene";
  45371. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45373. import { Mesh } from "babylonjs/Meshes/mesh";
  45374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45375. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45376. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45377. import "babylonjs/Meshes/Builders/planeBuilder";
  45378. import "babylonjs/Meshes/Builders/boxBuilder";
  45379. /**
  45380. * Represents the different options available during the creation of
  45381. * a Environment helper.
  45382. *
  45383. * This can control the default ground, skybox and image processing setup of your scene.
  45384. */
  45385. export interface IEnvironmentHelperOptions {
  45386. /**
  45387. * Specifies wether or not to create a ground.
  45388. * True by default.
  45389. */
  45390. createGround: boolean;
  45391. /**
  45392. * Specifies the ground size.
  45393. * 15 by default.
  45394. */
  45395. groundSize: number;
  45396. /**
  45397. * The texture used on the ground for the main color.
  45398. * Comes from the BabylonJS CDN by default.
  45399. *
  45400. * Remarks: Can be either a texture or a url.
  45401. */
  45402. groundTexture: string | BaseTexture;
  45403. /**
  45404. * The color mixed in the ground texture by default.
  45405. * BabylonJS clearColor by default.
  45406. */
  45407. groundColor: Color3;
  45408. /**
  45409. * Specifies the ground opacity.
  45410. * 1 by default.
  45411. */
  45412. groundOpacity: number;
  45413. /**
  45414. * Enables the ground to receive shadows.
  45415. * True by default.
  45416. */
  45417. enableGroundShadow: boolean;
  45418. /**
  45419. * Helps preventing the shadow to be fully black on the ground.
  45420. * 0.5 by default.
  45421. */
  45422. groundShadowLevel: number;
  45423. /**
  45424. * Creates a mirror texture attach to the ground.
  45425. * false by default.
  45426. */
  45427. enableGroundMirror: boolean;
  45428. /**
  45429. * Specifies the ground mirror size ratio.
  45430. * 0.3 by default as the default kernel is 64.
  45431. */
  45432. groundMirrorSizeRatio: number;
  45433. /**
  45434. * Specifies the ground mirror blur kernel size.
  45435. * 64 by default.
  45436. */
  45437. groundMirrorBlurKernel: number;
  45438. /**
  45439. * Specifies the ground mirror visibility amount.
  45440. * 1 by default
  45441. */
  45442. groundMirrorAmount: number;
  45443. /**
  45444. * Specifies the ground mirror reflectance weight.
  45445. * This uses the standard weight of the background material to setup the fresnel effect
  45446. * of the mirror.
  45447. * 1 by default.
  45448. */
  45449. groundMirrorFresnelWeight: number;
  45450. /**
  45451. * Specifies the ground mirror Falloff distance.
  45452. * This can helps reducing the size of the reflection.
  45453. * 0 by Default.
  45454. */
  45455. groundMirrorFallOffDistance: number;
  45456. /**
  45457. * Specifies the ground mirror texture type.
  45458. * Unsigned Int by Default.
  45459. */
  45460. groundMirrorTextureType: number;
  45461. /**
  45462. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45463. * the shown objects.
  45464. */
  45465. groundYBias: number;
  45466. /**
  45467. * Specifies wether or not to create a skybox.
  45468. * True by default.
  45469. */
  45470. createSkybox: boolean;
  45471. /**
  45472. * Specifies the skybox size.
  45473. * 20 by default.
  45474. */
  45475. skyboxSize: number;
  45476. /**
  45477. * The texture used on the skybox for the main color.
  45478. * Comes from the BabylonJS CDN by default.
  45479. *
  45480. * Remarks: Can be either a texture or a url.
  45481. */
  45482. skyboxTexture: string | BaseTexture;
  45483. /**
  45484. * The color mixed in the skybox texture by default.
  45485. * BabylonJS clearColor by default.
  45486. */
  45487. skyboxColor: Color3;
  45488. /**
  45489. * The background rotation around the Y axis of the scene.
  45490. * This helps aligning the key lights of your scene with the background.
  45491. * 0 by default.
  45492. */
  45493. backgroundYRotation: number;
  45494. /**
  45495. * Compute automatically the size of the elements to best fit with the scene.
  45496. */
  45497. sizeAuto: boolean;
  45498. /**
  45499. * Default position of the rootMesh if autoSize is not true.
  45500. */
  45501. rootPosition: Vector3;
  45502. /**
  45503. * Sets up the image processing in the scene.
  45504. * true by default.
  45505. */
  45506. setupImageProcessing: boolean;
  45507. /**
  45508. * The texture used as your environment texture in the scene.
  45509. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45510. *
  45511. * Remarks: Can be either a texture or a url.
  45512. */
  45513. environmentTexture: string | BaseTexture;
  45514. /**
  45515. * The value of the exposure to apply to the scene.
  45516. * 0.6 by default if setupImageProcessing is true.
  45517. */
  45518. cameraExposure: number;
  45519. /**
  45520. * The value of the contrast to apply to the scene.
  45521. * 1.6 by default if setupImageProcessing is true.
  45522. */
  45523. cameraContrast: number;
  45524. /**
  45525. * Specifies wether or not tonemapping should be enabled in the scene.
  45526. * true by default if setupImageProcessing is true.
  45527. */
  45528. toneMappingEnabled: boolean;
  45529. }
  45530. /**
  45531. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45532. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45533. * It also helps with the default setup of your imageProcessing configuration.
  45534. */
  45535. export class EnvironmentHelper {
  45536. /**
  45537. * Default ground texture URL.
  45538. */
  45539. private static _groundTextureCDNUrl;
  45540. /**
  45541. * Default skybox texture URL.
  45542. */
  45543. private static _skyboxTextureCDNUrl;
  45544. /**
  45545. * Default environment texture URL.
  45546. */
  45547. private static _environmentTextureCDNUrl;
  45548. /**
  45549. * Creates the default options for the helper.
  45550. */
  45551. private static _getDefaultOptions;
  45552. private _rootMesh;
  45553. /**
  45554. * Gets the root mesh created by the helper.
  45555. */
  45556. readonly rootMesh: Mesh;
  45557. private _skybox;
  45558. /**
  45559. * Gets the skybox created by the helper.
  45560. */
  45561. readonly skybox: Nullable<Mesh>;
  45562. private _skyboxTexture;
  45563. /**
  45564. * Gets the skybox texture created by the helper.
  45565. */
  45566. readonly skyboxTexture: Nullable<BaseTexture>;
  45567. private _skyboxMaterial;
  45568. /**
  45569. * Gets the skybox material created by the helper.
  45570. */
  45571. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45572. private _ground;
  45573. /**
  45574. * Gets the ground mesh created by the helper.
  45575. */
  45576. readonly ground: Nullable<Mesh>;
  45577. private _groundTexture;
  45578. /**
  45579. * Gets the ground texture created by the helper.
  45580. */
  45581. readonly groundTexture: Nullable<BaseTexture>;
  45582. private _groundMirror;
  45583. /**
  45584. * Gets the ground mirror created by the helper.
  45585. */
  45586. readonly groundMirror: Nullable<MirrorTexture>;
  45587. /**
  45588. * Gets the ground mirror render list to helps pushing the meshes
  45589. * you wish in the ground reflection.
  45590. */
  45591. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45592. private _groundMaterial;
  45593. /**
  45594. * Gets the ground material created by the helper.
  45595. */
  45596. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45597. /**
  45598. * Stores the creation options.
  45599. */
  45600. private readonly _scene;
  45601. private _options;
  45602. /**
  45603. * This observable will be notified with any error during the creation of the environment,
  45604. * mainly texture creation errors.
  45605. */
  45606. onErrorObservable: Observable<{
  45607. message?: string;
  45608. exception?: any;
  45609. }>;
  45610. /**
  45611. * constructor
  45612. * @param options Defines the options we want to customize the helper
  45613. * @param scene The scene to add the material to
  45614. */
  45615. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45616. /**
  45617. * Updates the background according to the new options
  45618. * @param options
  45619. */
  45620. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45621. /**
  45622. * Sets the primary color of all the available elements.
  45623. * @param color the main color to affect to the ground and the background
  45624. */
  45625. setMainColor(color: Color3): void;
  45626. /**
  45627. * Setup the image processing according to the specified options.
  45628. */
  45629. private _setupImageProcessing;
  45630. /**
  45631. * Setup the environment texture according to the specified options.
  45632. */
  45633. private _setupEnvironmentTexture;
  45634. /**
  45635. * Setup the background according to the specified options.
  45636. */
  45637. private _setupBackground;
  45638. /**
  45639. * Get the scene sizes according to the setup.
  45640. */
  45641. private _getSceneSize;
  45642. /**
  45643. * Setup the ground according to the specified options.
  45644. */
  45645. private _setupGround;
  45646. /**
  45647. * Setup the ground material according to the specified options.
  45648. */
  45649. private _setupGroundMaterial;
  45650. /**
  45651. * Setup the ground diffuse texture according to the specified options.
  45652. */
  45653. private _setupGroundDiffuseTexture;
  45654. /**
  45655. * Setup the ground mirror texture according to the specified options.
  45656. */
  45657. private _setupGroundMirrorTexture;
  45658. /**
  45659. * Setup the ground to receive the mirror texture.
  45660. */
  45661. private _setupMirrorInGroundMaterial;
  45662. /**
  45663. * Setup the skybox according to the specified options.
  45664. */
  45665. private _setupSkybox;
  45666. /**
  45667. * Setup the skybox material according to the specified options.
  45668. */
  45669. private _setupSkyboxMaterial;
  45670. /**
  45671. * Setup the skybox reflection texture according to the specified options.
  45672. */
  45673. private _setupSkyboxReflectionTexture;
  45674. private _errorHandler;
  45675. /**
  45676. * Dispose all the elements created by the Helper.
  45677. */
  45678. dispose(): void;
  45679. }
  45680. }
  45681. declare module "babylonjs/Helpers/photoDome" {
  45682. import { Observable } from "babylonjs/Misc/observable";
  45683. import { Nullable } from "babylonjs/types";
  45684. import { Scene } from "babylonjs/scene";
  45685. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45686. import { Mesh } from "babylonjs/Meshes/mesh";
  45687. import { Texture } from "babylonjs/Materials/Textures/texture";
  45688. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45689. import "babylonjs/Meshes/Builders/sphereBuilder";
  45690. /**
  45691. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45692. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45693. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45694. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45695. */
  45696. export class PhotoDome extends TransformNode {
  45697. private _useDirectMapping;
  45698. /**
  45699. * The texture being displayed on the sphere
  45700. */
  45701. protected _photoTexture: Texture;
  45702. /**
  45703. * Gets or sets the texture being displayed on the sphere
  45704. */
  45705. photoTexture: Texture;
  45706. /**
  45707. * Observable raised when an error occured while loading the 360 image
  45708. */
  45709. onLoadErrorObservable: Observable<string>;
  45710. /**
  45711. * The skybox material
  45712. */
  45713. protected _material: BackgroundMaterial;
  45714. /**
  45715. * The surface used for the skybox
  45716. */
  45717. protected _mesh: Mesh;
  45718. /**
  45719. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45720. * Also see the options.resolution property.
  45721. */
  45722. fovMultiplier: number;
  45723. /**
  45724. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45725. * @param name Element's name, child elements will append suffixes for their own names.
  45726. * @param urlsOfPhoto defines the url of the photo to display
  45727. * @param options defines an object containing optional or exposed sub element properties
  45728. * @param onError defines a callback called when an error occured while loading the texture
  45729. */
  45730. constructor(name: string, urlOfPhoto: string, options: {
  45731. resolution?: number;
  45732. size?: number;
  45733. useDirectMapping?: boolean;
  45734. faceForward?: boolean;
  45735. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45736. /**
  45737. * Releases resources associated with this node.
  45738. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45739. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45740. */
  45741. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45742. }
  45743. }
  45744. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45745. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45746. /** @hidden */
  45747. export var rgbdDecodePixelShader: {
  45748. name: string;
  45749. shader: string;
  45750. };
  45751. }
  45752. declare module "babylonjs/Misc/brdfTextureTools" {
  45753. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45754. import { Scene } from "babylonjs/scene";
  45755. import "babylonjs/Shaders/rgbdDecode.fragment";
  45756. /**
  45757. * Class used to host texture specific utilities
  45758. */
  45759. export class BRDFTextureTools {
  45760. /**
  45761. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45762. * @param texture the texture to expand.
  45763. */
  45764. private static _ExpandDefaultBRDFTexture;
  45765. /**
  45766. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45767. * @param scene defines the hosting scene
  45768. * @returns the environment BRDF texture
  45769. */
  45770. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45771. private static _environmentBRDFBase64Texture;
  45772. }
  45773. }
  45774. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45775. import { Nullable } from "babylonjs/types";
  45776. import { IAnimatable } from "babylonjs/Misc/tools";
  45777. import { Color3 } from "babylonjs/Maths/math";
  45778. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45779. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45780. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45781. import { Engine } from "babylonjs/Engines/engine";
  45782. import { Scene } from "babylonjs/scene";
  45783. /**
  45784. * @hidden
  45785. */
  45786. export interface IMaterialClearCoatDefines {
  45787. CLEARCOAT: boolean;
  45788. CLEARCOAT_DEFAULTIOR: boolean;
  45789. CLEARCOAT_TEXTURE: boolean;
  45790. CLEARCOAT_TEXTUREDIRECTUV: number;
  45791. CLEARCOAT_BUMP: boolean;
  45792. CLEARCOAT_BUMPDIRECTUV: number;
  45793. CLEARCOAT_TINT: boolean;
  45794. CLEARCOAT_TINT_TEXTURE: boolean;
  45795. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45796. /** @hidden */
  45797. _areTexturesDirty: boolean;
  45798. }
  45799. /**
  45800. * Define the code related to the clear coat parameters of the pbr material.
  45801. */
  45802. export class PBRClearCoatConfiguration {
  45803. /**
  45804. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45805. * The default fits with a polyurethane material.
  45806. */
  45807. private static readonly _DefaultIndiceOfRefraction;
  45808. private _isEnabled;
  45809. /**
  45810. * Defines if the clear coat is enabled in the material.
  45811. */
  45812. isEnabled: boolean;
  45813. /**
  45814. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45815. */
  45816. intensity: number;
  45817. /**
  45818. * Defines the clear coat layer roughness.
  45819. */
  45820. roughness: number;
  45821. private _indiceOfRefraction;
  45822. /**
  45823. * Defines the indice of refraction of the clear coat.
  45824. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45825. * The default fits with a polyurethane material.
  45826. * Changing the default value is more performance intensive.
  45827. */
  45828. indiceOfRefraction: number;
  45829. private _texture;
  45830. /**
  45831. * Stores the clear coat values in a texture.
  45832. */
  45833. texture: Nullable<BaseTexture>;
  45834. private _bumpTexture;
  45835. /**
  45836. * Define the clear coat specific bump texture.
  45837. */
  45838. bumpTexture: Nullable<BaseTexture>;
  45839. private _isTintEnabled;
  45840. /**
  45841. * Defines if the clear coat tint is enabled in the material.
  45842. */
  45843. isTintEnabled: boolean;
  45844. /**
  45845. * Defines the clear coat tint of the material.
  45846. * This is only use if tint is enabled
  45847. */
  45848. tintColor: Color3;
  45849. /**
  45850. * Defines the distance at which the tint color should be found in the
  45851. * clear coat media.
  45852. * This is only use if tint is enabled
  45853. */
  45854. tintColorAtDistance: number;
  45855. /**
  45856. * Defines the clear coat layer thickness.
  45857. * This is only use if tint is enabled
  45858. */
  45859. tintThickness: number;
  45860. private _tintTexture;
  45861. /**
  45862. * Stores the clear tint values in a texture.
  45863. * rgb is tint
  45864. * a is a thickness factor
  45865. */
  45866. tintTexture: Nullable<BaseTexture>;
  45867. /** @hidden */
  45868. private _internalMarkAllSubMeshesAsTexturesDirty;
  45869. /** @hidden */
  45870. _markAllSubMeshesAsTexturesDirty(): void;
  45871. /**
  45872. * Instantiate a new istance of clear coat configuration.
  45873. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45874. */
  45875. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45876. /**
  45877. * Gets wehter the submesh is ready to be used or not.
  45878. * @param defines the list of "defines" to update.
  45879. * @param scene defines the scene the material belongs to.
  45880. * @param engine defines the engine the material belongs to.
  45881. * @param disableBumpMap defines wether the material disables bump or not.
  45882. * @returns - boolean indicating that the submesh is ready or not.
  45883. */
  45884. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45885. /**
  45886. * Checks to see if a texture is used in the material.
  45887. * @param defines the list of "defines" to update.
  45888. * @param scene defines the scene to the material belongs to.
  45889. */
  45890. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45891. /**
  45892. * Binds the material data.
  45893. * @param uniformBuffer defines the Uniform buffer to fill in.
  45894. * @param scene defines the scene the material belongs to.
  45895. * @param engine defines the engine the material belongs to.
  45896. * @param disableBumpMap defines wether the material disables bump or not.
  45897. * @param isFrozen defines wether the material is frozen or not.
  45898. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45899. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45900. */
  45901. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45902. /**
  45903. * Checks to see if a texture is used in the material.
  45904. * @param texture - Base texture to use.
  45905. * @returns - Boolean specifying if a texture is used in the material.
  45906. */
  45907. hasTexture(texture: BaseTexture): boolean;
  45908. /**
  45909. * Returns an array of the actively used textures.
  45910. * @param activeTextures Array of BaseTextures
  45911. */
  45912. getActiveTextures(activeTextures: BaseTexture[]): void;
  45913. /**
  45914. * Returns the animatable textures.
  45915. * @param animatables Array of animatable textures.
  45916. */
  45917. getAnimatables(animatables: IAnimatable[]): void;
  45918. /**
  45919. * Disposes the resources of the material.
  45920. * @param forceDisposeTextures - Forces the disposal of all textures.
  45921. */
  45922. dispose(forceDisposeTextures?: boolean): void;
  45923. /**
  45924. * Get the current class name of the texture useful for serialization or dynamic coding.
  45925. * @returns "PBRClearCoatConfiguration"
  45926. */
  45927. getClassName(): string;
  45928. /**
  45929. * Add fallbacks to the effect fallbacks list.
  45930. * @param defines defines the Base texture to use.
  45931. * @param fallbacks defines the current fallback list.
  45932. * @param currentRank defines the current fallback rank.
  45933. * @returns the new fallback rank.
  45934. */
  45935. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45936. /**
  45937. * Add the required uniforms to the current list.
  45938. * @param uniforms defines the current uniform list.
  45939. */
  45940. static AddUniforms(uniforms: string[]): void;
  45941. /**
  45942. * Add the required samplers to the current list.
  45943. * @param samplers defines the current sampler list.
  45944. */
  45945. static AddSamplers(samplers: string[]): void;
  45946. /**
  45947. * Add the required uniforms to the current buffer.
  45948. * @param uniformBuffer defines the current uniform buffer.
  45949. */
  45950. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45951. /**
  45952. * Makes a duplicate of the current configuration into another one.
  45953. * @param clearCoatConfiguration define the config where to copy the info
  45954. */
  45955. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45956. /**
  45957. * Serializes this clear coat configuration.
  45958. * @returns - An object with the serialized config.
  45959. */
  45960. serialize(): any;
  45961. /**
  45962. * Parses a Clear Coat Configuration from a serialized object.
  45963. * @param source - Serialized object.
  45964. */
  45965. parse(source: any): void;
  45966. }
  45967. }
  45968. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45969. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45970. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45972. import { Vector2 } from "babylonjs/Maths/math";
  45973. import { Scene } from "babylonjs/scene";
  45974. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45975. import { IAnimatable } from "babylonjs/Misc/tools";
  45976. import { Nullable } from "babylonjs/types";
  45977. /**
  45978. * @hidden
  45979. */
  45980. export interface IMaterialAnisotropicDefines {
  45981. ANISOTROPIC: boolean;
  45982. ANISOTROPIC_TEXTURE: boolean;
  45983. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45984. MAINUV1: boolean;
  45985. _areTexturesDirty: boolean;
  45986. _needUVs: boolean;
  45987. }
  45988. /**
  45989. * Define the code related to the anisotropic parameters of the pbr material.
  45990. */
  45991. export class PBRAnisotropicConfiguration {
  45992. private _isEnabled;
  45993. /**
  45994. * Defines if the anisotropy is enabled in the material.
  45995. */
  45996. isEnabled: boolean;
  45997. /**
  45998. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45999. */
  46000. intensity: number;
  46001. /**
  46002. * Defines if the effect is along the tangents, bitangents or in between.
  46003. * By default, the effect is "strectching" the highlights along the tangents.
  46004. */
  46005. direction: Vector2;
  46006. private _texture;
  46007. /**
  46008. * Stores the anisotropy values in a texture.
  46009. * rg is direction (like normal from -1 to 1)
  46010. * b is a intensity
  46011. */
  46012. texture: Nullable<BaseTexture>;
  46013. /** @hidden */
  46014. private _internalMarkAllSubMeshesAsTexturesDirty;
  46015. /** @hidden */
  46016. _markAllSubMeshesAsTexturesDirty(): void;
  46017. /**
  46018. * Instantiate a new istance of anisotropy configuration.
  46019. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46020. */
  46021. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46022. /**
  46023. * Specifies that the submesh is ready to be used.
  46024. * @param defines the list of "defines" to update.
  46025. * @param scene defines the scene the material belongs to.
  46026. * @returns - boolean indicating that the submesh is ready or not.
  46027. */
  46028. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46029. /**
  46030. * Checks to see if a texture is used in the material.
  46031. * @param defines the list of "defines" to update.
  46032. * @param mesh the mesh we are preparing the defines for.
  46033. * @param scene defines the scene the material belongs to.
  46034. */
  46035. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46036. /**
  46037. * Binds the material data.
  46038. * @param uniformBuffer defines the Uniform buffer to fill in.
  46039. * @param scene defines the scene the material belongs to.
  46040. * @param isFrozen defines wether the material is frozen or not.
  46041. */
  46042. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46043. /**
  46044. * Checks to see if a texture is used in the material.
  46045. * @param texture - Base texture to use.
  46046. * @returns - Boolean specifying if a texture is used in the material.
  46047. */
  46048. hasTexture(texture: BaseTexture): boolean;
  46049. /**
  46050. * Returns an array of the actively used textures.
  46051. * @param activeTextures Array of BaseTextures
  46052. */
  46053. getActiveTextures(activeTextures: BaseTexture[]): void;
  46054. /**
  46055. * Returns the animatable textures.
  46056. * @param animatables Array of animatable textures.
  46057. */
  46058. getAnimatables(animatables: IAnimatable[]): void;
  46059. /**
  46060. * Disposes the resources of the material.
  46061. * @param forceDisposeTextures - Forces the disposal of all textures.
  46062. */
  46063. dispose(forceDisposeTextures?: boolean): void;
  46064. /**
  46065. * Get the current class name of the texture useful for serialization or dynamic coding.
  46066. * @returns "PBRAnisotropicConfiguration"
  46067. */
  46068. getClassName(): string;
  46069. /**
  46070. * Add fallbacks to the effect fallbacks list.
  46071. * @param defines defines the Base texture to use.
  46072. * @param fallbacks defines the current fallback list.
  46073. * @param currentRank defines the current fallback rank.
  46074. * @returns the new fallback rank.
  46075. */
  46076. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46077. /**
  46078. * Add the required uniforms to the current list.
  46079. * @param uniforms defines the current uniform list.
  46080. */
  46081. static AddUniforms(uniforms: string[]): void;
  46082. /**
  46083. * Add the required uniforms to the current buffer.
  46084. * @param uniformBuffer defines the current uniform buffer.
  46085. */
  46086. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46087. /**
  46088. * Add the required samplers to the current list.
  46089. * @param samplers defines the current sampler list.
  46090. */
  46091. static AddSamplers(samplers: string[]): void;
  46092. /**
  46093. * Makes a duplicate of the current configuration into another one.
  46094. * @param anisotropicConfiguration define the config where to copy the info
  46095. */
  46096. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46097. /**
  46098. * Serializes this anisotropy configuration.
  46099. * @returns - An object with the serialized config.
  46100. */
  46101. serialize(): any;
  46102. /**
  46103. * Parses a anisotropy Configuration from a serialized object.
  46104. * @param source - Serialized object.
  46105. */
  46106. parse(source: any): void;
  46107. }
  46108. }
  46109. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46110. /**
  46111. * @hidden
  46112. */
  46113. export interface IMaterialBRDFDefines {
  46114. BRDF_V_HEIGHT_CORRELATED: boolean;
  46115. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46116. SPHERICAL_HARMONICS: boolean;
  46117. /** @hidden */
  46118. _areMiscDirty: boolean;
  46119. }
  46120. /**
  46121. * Define the code related to the BRDF parameters of the pbr material.
  46122. */
  46123. export class PBRBRDFConfiguration {
  46124. /**
  46125. * Default value used for the energy conservation.
  46126. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46127. */
  46128. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46129. /**
  46130. * Default value used for the Smith Visibility Height Correlated mode.
  46131. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46132. */
  46133. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46134. /**
  46135. * Default value used for the IBL diffuse part.
  46136. * This can help switching back to the polynomials mode globally which is a tiny bit
  46137. * less GPU intensive at the drawback of a lower quality.
  46138. */
  46139. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46140. private _useEnergyConservation;
  46141. /**
  46142. * Defines if the material uses energy conservation.
  46143. */
  46144. useEnergyConservation: boolean;
  46145. private _useSmithVisibilityHeightCorrelated;
  46146. /**
  46147. * LEGACY Mode set to false
  46148. * Defines if the material uses height smith correlated visibility term.
  46149. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46150. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46151. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46152. * Not relying on height correlated will also disable energy conservation.
  46153. */
  46154. useSmithVisibilityHeightCorrelated: boolean;
  46155. private _useSphericalHarmonics;
  46156. /**
  46157. * LEGACY Mode set to false
  46158. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46159. * diffuse part of the IBL.
  46160. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46161. * to the ground truth.
  46162. */
  46163. useSphericalHarmonics: boolean;
  46164. /** @hidden */
  46165. private _internalMarkAllSubMeshesAsMiscDirty;
  46166. /** @hidden */
  46167. _markAllSubMeshesAsMiscDirty(): void;
  46168. /**
  46169. * Instantiate a new istance of clear coat configuration.
  46170. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46171. */
  46172. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46173. /**
  46174. * Checks to see if a texture is used in the material.
  46175. * @param defines the list of "defines" to update.
  46176. */
  46177. prepareDefines(defines: IMaterialBRDFDefines): void;
  46178. /**
  46179. * Get the current class name of the texture useful for serialization or dynamic coding.
  46180. * @returns "PBRClearCoatConfiguration"
  46181. */
  46182. getClassName(): string;
  46183. /**
  46184. * Makes a duplicate of the current configuration into another one.
  46185. * @param brdfConfiguration define the config where to copy the info
  46186. */
  46187. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46188. /**
  46189. * Serializes this BRDF configuration.
  46190. * @returns - An object with the serialized config.
  46191. */
  46192. serialize(): any;
  46193. /**
  46194. * Parses a BRDF Configuration from a serialized object.
  46195. * @param source - Serialized object.
  46196. */
  46197. parse(source: any): void;
  46198. }
  46199. }
  46200. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46201. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46202. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46203. import { Color3 } from "babylonjs/Maths/math";
  46204. import { Scene } from "babylonjs/scene";
  46205. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46206. import { IAnimatable } from "babylonjs/Misc/tools";
  46207. import { Nullable } from "babylonjs/types";
  46208. /**
  46209. * @hidden
  46210. */
  46211. export interface IMaterialSheenDefines {
  46212. SHEEN: boolean;
  46213. SHEEN_TEXTURE: boolean;
  46214. SHEEN_TEXTUREDIRECTUV: number;
  46215. SHEEN_LINKWITHALBEDO: boolean;
  46216. /** @hidden */
  46217. _areTexturesDirty: boolean;
  46218. }
  46219. /**
  46220. * Define the code related to the Sheen parameters of the pbr material.
  46221. */
  46222. export class PBRSheenConfiguration {
  46223. private _isEnabled;
  46224. /**
  46225. * Defines if the material uses sheen.
  46226. */
  46227. isEnabled: boolean;
  46228. private _linkSheenWithAlbedo;
  46229. /**
  46230. * Defines if the sheen is linked to the sheen color.
  46231. */
  46232. linkSheenWithAlbedo: boolean;
  46233. /**
  46234. * Defines the sheen intensity.
  46235. */
  46236. intensity: number;
  46237. /**
  46238. * Defines the sheen color.
  46239. */
  46240. color: Color3;
  46241. private _texture;
  46242. /**
  46243. * Stores the sheen tint values in a texture.
  46244. * rgb is tint
  46245. * a is a intensity
  46246. */
  46247. texture: Nullable<BaseTexture>;
  46248. /** @hidden */
  46249. private _internalMarkAllSubMeshesAsTexturesDirty;
  46250. /** @hidden */
  46251. _markAllSubMeshesAsTexturesDirty(): void;
  46252. /**
  46253. * Instantiate a new istance of clear coat configuration.
  46254. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46255. */
  46256. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46257. /**
  46258. * Specifies that the submesh is ready to be used.
  46259. * @param defines the list of "defines" to update.
  46260. * @param scene defines the scene the material belongs to.
  46261. * @returns - boolean indicating that the submesh is ready or not.
  46262. */
  46263. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46264. /**
  46265. * Checks to see if a texture is used in the material.
  46266. * @param defines the list of "defines" to update.
  46267. * @param scene defines the scene the material belongs to.
  46268. */
  46269. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46270. /**
  46271. * Binds the material data.
  46272. * @param uniformBuffer defines the Uniform buffer to fill in.
  46273. * @param scene defines the scene the material belongs to.
  46274. * @param isFrozen defines wether the material is frozen or not.
  46275. */
  46276. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46277. /**
  46278. * Checks to see if a texture is used in the material.
  46279. * @param texture - Base texture to use.
  46280. * @returns - Boolean specifying if a texture is used in the material.
  46281. */
  46282. hasTexture(texture: BaseTexture): boolean;
  46283. /**
  46284. * Returns an array of the actively used textures.
  46285. * @param activeTextures Array of BaseTextures
  46286. */
  46287. getActiveTextures(activeTextures: BaseTexture[]): void;
  46288. /**
  46289. * Returns the animatable textures.
  46290. * @param animatables Array of animatable textures.
  46291. */
  46292. getAnimatables(animatables: IAnimatable[]): void;
  46293. /**
  46294. * Disposes the resources of the material.
  46295. * @param forceDisposeTextures - Forces the disposal of all textures.
  46296. */
  46297. dispose(forceDisposeTextures?: boolean): void;
  46298. /**
  46299. * Get the current class name of the texture useful for serialization or dynamic coding.
  46300. * @returns "PBRSheenConfiguration"
  46301. */
  46302. getClassName(): string;
  46303. /**
  46304. * Add fallbacks to the effect fallbacks list.
  46305. * @param defines defines the Base texture to use.
  46306. * @param fallbacks defines the current fallback list.
  46307. * @param currentRank defines the current fallback rank.
  46308. * @returns the new fallback rank.
  46309. */
  46310. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46311. /**
  46312. * Add the required uniforms to the current list.
  46313. * @param uniforms defines the current uniform list.
  46314. */
  46315. static AddUniforms(uniforms: string[]): void;
  46316. /**
  46317. * Add the required uniforms to the current buffer.
  46318. * @param uniformBuffer defines the current uniform buffer.
  46319. */
  46320. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46321. /**
  46322. * Add the required samplers to the current list.
  46323. * @param samplers defines the current sampler list.
  46324. */
  46325. static AddSamplers(samplers: string[]): void;
  46326. /**
  46327. * Makes a duplicate of the current configuration into another one.
  46328. * @param sheenConfiguration define the config where to copy the info
  46329. */
  46330. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46331. /**
  46332. * Serializes this BRDF configuration.
  46333. * @returns - An object with the serialized config.
  46334. */
  46335. serialize(): any;
  46336. /**
  46337. * Parses a Sheen Configuration from a serialized object.
  46338. * @param source - Serialized object.
  46339. */
  46340. parse(source: any): void;
  46341. }
  46342. }
  46343. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46344. import { Nullable } from "babylonjs/types";
  46345. import { IAnimatable } from "babylonjs/Misc/tools";
  46346. import { Color3 } from "babylonjs/Maths/math";
  46347. import { SmartArray } from "babylonjs/Misc/smartArray";
  46348. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46350. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46351. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46352. import { Engine } from "babylonjs/Engines/engine";
  46353. import { Scene } from "babylonjs/scene";
  46354. /**
  46355. * @hidden
  46356. */
  46357. export interface IMaterialSubSurfaceDefines {
  46358. SUBSURFACE: boolean;
  46359. SS_REFRACTION: boolean;
  46360. SS_TRANSLUCENCY: boolean;
  46361. SS_SCATERRING: boolean;
  46362. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46363. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46364. SS_REFRACTIONMAP_3D: boolean;
  46365. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46366. SS_LODINREFRACTIONALPHA: boolean;
  46367. SS_GAMMAREFRACTION: boolean;
  46368. SS_RGBDREFRACTION: boolean;
  46369. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46370. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46371. /** @hidden */
  46372. _areTexturesDirty: boolean;
  46373. }
  46374. /**
  46375. * Define the code related to the sub surface parameters of the pbr material.
  46376. */
  46377. export class PBRSubSurfaceConfiguration {
  46378. private _isRefractionEnabled;
  46379. /**
  46380. * Defines if the refraction is enabled in the material.
  46381. */
  46382. isRefractionEnabled: boolean;
  46383. private _isTranslucencyEnabled;
  46384. /**
  46385. * Defines if the translucency is enabled in the material.
  46386. */
  46387. isTranslucencyEnabled: boolean;
  46388. private _isScatteringEnabled;
  46389. /**
  46390. * Defines the refraction intensity of the material.
  46391. * The refraction when enabled replaces the Diffuse part of the material.
  46392. * The intensity helps transitionning between diffuse and refraction.
  46393. */
  46394. refractionIntensity: number;
  46395. /**
  46396. * Defines the translucency intensity of the material.
  46397. * When translucency has been enabled, this defines how much of the "translucency"
  46398. * is addded to the diffuse part of the material.
  46399. */
  46400. translucencyIntensity: number;
  46401. /**
  46402. * Defines the scattering intensity of the material.
  46403. * When scattering has been enabled, this defines how much of the "scattered light"
  46404. * is addded to the diffuse part of the material.
  46405. */
  46406. scatteringIntensity: number;
  46407. private _thicknessTexture;
  46408. /**
  46409. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46410. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46411. * 0 would mean minimumThickness
  46412. * 1 would mean maximumThickness
  46413. * The other channels might be use as a mask to vary the different effects intensity.
  46414. */
  46415. thicknessTexture: Nullable<BaseTexture>;
  46416. private _refractionTexture;
  46417. /**
  46418. * Defines the texture to use for refraction.
  46419. */
  46420. refractionTexture: Nullable<BaseTexture>;
  46421. private _indexOfRefraction;
  46422. /**
  46423. * Defines the indice of refraction used in the material.
  46424. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46425. */
  46426. indexOfRefraction: number;
  46427. private _invertRefractionY;
  46428. /**
  46429. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46430. */
  46431. invertRefractionY: boolean;
  46432. private _linkRefractionWithTransparency;
  46433. /**
  46434. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46435. * Materials half opaque for instance using refraction could benefit from this control.
  46436. */
  46437. linkRefractionWithTransparency: boolean;
  46438. /**
  46439. * Defines the minimum thickness stored in the thickness map.
  46440. * If no thickness map is defined, this value will be used to simulate thickness.
  46441. */
  46442. minimumThickness: number;
  46443. /**
  46444. * Defines the maximum thickness stored in the thickness map.
  46445. */
  46446. maximumThickness: number;
  46447. /**
  46448. * Defines the volume tint of the material.
  46449. * This is used for both translucency and scattering.
  46450. */
  46451. tintColor: Color3;
  46452. /**
  46453. * Defines the distance at which the tint color should be found in the media.
  46454. * This is used for refraction only.
  46455. */
  46456. tintColorAtDistance: number;
  46457. /**
  46458. * Defines how far each channel transmit through the media.
  46459. * It is defined as a color to simplify it selection.
  46460. */
  46461. diffusionDistance: Color3;
  46462. private _useMaskFromThicknessTexture;
  46463. /**
  46464. * Stores the intensity of the different subsurface effects in the thickness texture.
  46465. * * the green channel is the translucency intensity.
  46466. * * the blue channel is the scattering intensity.
  46467. * * the alpha channel is the refraction intensity.
  46468. */
  46469. useMaskFromThicknessTexture: boolean;
  46470. /** @hidden */
  46471. private _internalMarkAllSubMeshesAsTexturesDirty;
  46472. /** @hidden */
  46473. _markAllSubMeshesAsTexturesDirty(): void;
  46474. /**
  46475. * Instantiate a new istance of sub surface configuration.
  46476. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46477. */
  46478. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46479. /**
  46480. * Gets wehter the submesh is ready to be used or not.
  46481. * @param defines the list of "defines" to update.
  46482. * @param scene defines the scene the material belongs to.
  46483. * @returns - boolean indicating that the submesh is ready or not.
  46484. */
  46485. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46486. /**
  46487. * Checks to see if a texture is used in the material.
  46488. * @param defines the list of "defines" to update.
  46489. * @param scene defines the scene to the material belongs to.
  46490. */
  46491. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46492. /**
  46493. * Binds the material data.
  46494. * @param uniformBuffer defines the Uniform buffer to fill in.
  46495. * @param scene defines the scene the material belongs to.
  46496. * @param engine defines the engine the material belongs to.
  46497. * @param isFrozen defines wether the material is frozen or not.
  46498. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46499. */
  46500. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46501. /**
  46502. * Unbinds the material from the mesh.
  46503. * @param activeEffect defines the effect that should be unbound from.
  46504. * @returns true if unbound, otherwise false
  46505. */
  46506. unbind(activeEffect: Effect): boolean;
  46507. /**
  46508. * Returns the texture used for refraction or null if none is used.
  46509. * @param scene defines the scene the material belongs to.
  46510. * @returns - Refraction texture if present. If no refraction texture and refraction
  46511. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46512. */
  46513. private _getRefractionTexture;
  46514. /**
  46515. * Returns true if alpha blending should be disabled.
  46516. */
  46517. readonly disableAlphaBlending: boolean;
  46518. /**
  46519. * Fills the list of render target textures.
  46520. * @param renderTargets the list of render targets to update
  46521. */
  46522. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46523. /**
  46524. * Checks to see if a texture is used in the material.
  46525. * @param texture - Base texture to use.
  46526. * @returns - Boolean specifying if a texture is used in the material.
  46527. */
  46528. hasTexture(texture: BaseTexture): boolean;
  46529. /**
  46530. * Gets a boolean indicating that current material needs to register RTT
  46531. * @returns true if this uses a render target otherwise false.
  46532. */
  46533. hasRenderTargetTextures(): boolean;
  46534. /**
  46535. * Returns an array of the actively used textures.
  46536. * @param activeTextures Array of BaseTextures
  46537. */
  46538. getActiveTextures(activeTextures: BaseTexture[]): void;
  46539. /**
  46540. * Returns the animatable textures.
  46541. * @param animatables Array of animatable textures.
  46542. */
  46543. getAnimatables(animatables: IAnimatable[]): void;
  46544. /**
  46545. * Disposes the resources of the material.
  46546. * @param forceDisposeTextures - Forces the disposal of all textures.
  46547. */
  46548. dispose(forceDisposeTextures?: boolean): void;
  46549. /**
  46550. * Get the current class name of the texture useful for serialization or dynamic coding.
  46551. * @returns "PBRSubSurfaceConfiguration"
  46552. */
  46553. getClassName(): string;
  46554. /**
  46555. * Add fallbacks to the effect fallbacks list.
  46556. * @param defines defines the Base texture to use.
  46557. * @param fallbacks defines the current fallback list.
  46558. * @param currentRank defines the current fallback rank.
  46559. * @returns the new fallback rank.
  46560. */
  46561. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46562. /**
  46563. * Add the required uniforms to the current list.
  46564. * @param uniforms defines the current uniform list.
  46565. */
  46566. static AddUniforms(uniforms: string[]): void;
  46567. /**
  46568. * Add the required samplers to the current list.
  46569. * @param samplers defines the current sampler list.
  46570. */
  46571. static AddSamplers(samplers: string[]): void;
  46572. /**
  46573. * Add the required uniforms to the current buffer.
  46574. * @param uniformBuffer defines the current uniform buffer.
  46575. */
  46576. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46577. /**
  46578. * Makes a duplicate of the current configuration into another one.
  46579. * @param configuration define the config where to copy the info
  46580. */
  46581. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46582. /**
  46583. * Serializes this Sub Surface configuration.
  46584. * @returns - An object with the serialized config.
  46585. */
  46586. serialize(): any;
  46587. /**
  46588. * Parses a Sub Surface Configuration from a serialized object.
  46589. * @param source - Serialized object.
  46590. */
  46591. parse(source: any): void;
  46592. }
  46593. }
  46594. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46595. /** @hidden */
  46596. export var pbrFragmentDeclaration: {
  46597. name: string;
  46598. shader: string;
  46599. };
  46600. }
  46601. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46602. /** @hidden */
  46603. export var pbrUboDeclaration: {
  46604. name: string;
  46605. shader: string;
  46606. };
  46607. }
  46608. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46609. /** @hidden */
  46610. export var pbrFragmentExtraDeclaration: {
  46611. name: string;
  46612. shader: string;
  46613. };
  46614. }
  46615. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46616. /** @hidden */
  46617. export var pbrFragmentSamplersDeclaration: {
  46618. name: string;
  46619. shader: string;
  46620. };
  46621. }
  46622. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46623. /** @hidden */
  46624. export var pbrHelperFunctions: {
  46625. name: string;
  46626. shader: string;
  46627. };
  46628. }
  46629. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46630. /** @hidden */
  46631. export var harmonicsFunctions: {
  46632. name: string;
  46633. shader: string;
  46634. };
  46635. }
  46636. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46637. /** @hidden */
  46638. export var pbrDirectLightingSetupFunctions: {
  46639. name: string;
  46640. shader: string;
  46641. };
  46642. }
  46643. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46644. /** @hidden */
  46645. export var pbrDirectLightingFalloffFunctions: {
  46646. name: string;
  46647. shader: string;
  46648. };
  46649. }
  46650. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46651. /** @hidden */
  46652. export var pbrBRDFFunctions: {
  46653. name: string;
  46654. shader: string;
  46655. };
  46656. }
  46657. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46658. /** @hidden */
  46659. export var pbrDirectLightingFunctions: {
  46660. name: string;
  46661. shader: string;
  46662. };
  46663. }
  46664. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46665. /** @hidden */
  46666. export var pbrIBLFunctions: {
  46667. name: string;
  46668. shader: string;
  46669. };
  46670. }
  46671. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46672. /** @hidden */
  46673. export var pbrDebug: {
  46674. name: string;
  46675. shader: string;
  46676. };
  46677. }
  46678. declare module "babylonjs/Shaders/pbr.fragment" {
  46679. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46680. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46681. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46682. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46683. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46684. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46685. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46686. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46687. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46688. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46689. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46690. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46691. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46692. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46693. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46694. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46695. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46696. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46697. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46698. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46699. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46700. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46701. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46702. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46703. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46704. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46705. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46706. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46707. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46708. /** @hidden */
  46709. export var pbrPixelShader: {
  46710. name: string;
  46711. shader: string;
  46712. };
  46713. }
  46714. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46715. /** @hidden */
  46716. export var pbrVertexDeclaration: {
  46717. name: string;
  46718. shader: string;
  46719. };
  46720. }
  46721. declare module "babylonjs/Shaders/pbr.vertex" {
  46722. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46723. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46724. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46725. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46726. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46727. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46728. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46729. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46730. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46731. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46732. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46733. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46734. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46735. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46736. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46737. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46738. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46739. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46740. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46741. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46742. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46743. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46744. /** @hidden */
  46745. export var pbrVertexShader: {
  46746. name: string;
  46747. shader: string;
  46748. };
  46749. }
  46750. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46751. import { IAnimatable } from "babylonjs/Misc/tools";
  46752. import { Nullable } from "babylonjs/types";
  46753. import { Scene } from "babylonjs/scene";
  46754. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46755. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46757. import { Mesh } from "babylonjs/Meshes/mesh";
  46758. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46759. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46760. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46761. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46762. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46763. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46764. import { Material } from "babylonjs/Materials/material";
  46765. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46766. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46767. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46768. import "babylonjs/Shaders/pbr.fragment";
  46769. import "babylonjs/Shaders/pbr.vertex";
  46770. /**
  46771. * Manages the defines for the PBR Material.
  46772. * @hidden
  46773. */
  46774. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46775. PBR: boolean;
  46776. MAINUV1: boolean;
  46777. MAINUV2: boolean;
  46778. UV1: boolean;
  46779. UV2: boolean;
  46780. ALBEDO: boolean;
  46781. ALBEDODIRECTUV: number;
  46782. VERTEXCOLOR: boolean;
  46783. AMBIENT: boolean;
  46784. AMBIENTDIRECTUV: number;
  46785. AMBIENTINGRAYSCALE: boolean;
  46786. OPACITY: boolean;
  46787. VERTEXALPHA: boolean;
  46788. OPACITYDIRECTUV: number;
  46789. OPACITYRGB: boolean;
  46790. ALPHATEST: boolean;
  46791. DEPTHPREPASS: boolean;
  46792. ALPHABLEND: boolean;
  46793. ALPHAFROMALBEDO: boolean;
  46794. ALPHATESTVALUE: string;
  46795. SPECULAROVERALPHA: boolean;
  46796. RADIANCEOVERALPHA: boolean;
  46797. ALPHAFRESNEL: boolean;
  46798. LINEARALPHAFRESNEL: boolean;
  46799. PREMULTIPLYALPHA: boolean;
  46800. EMISSIVE: boolean;
  46801. EMISSIVEDIRECTUV: number;
  46802. REFLECTIVITY: boolean;
  46803. REFLECTIVITYDIRECTUV: number;
  46804. SPECULARTERM: boolean;
  46805. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46806. MICROSURFACEAUTOMATIC: boolean;
  46807. LODBASEDMICROSFURACE: boolean;
  46808. MICROSURFACEMAP: boolean;
  46809. MICROSURFACEMAPDIRECTUV: number;
  46810. METALLICWORKFLOW: boolean;
  46811. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46812. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46813. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46814. AOSTOREINMETALMAPRED: boolean;
  46815. ENVIRONMENTBRDF: boolean;
  46816. ENVIRONMENTBRDF_RGBD: boolean;
  46817. NORMAL: boolean;
  46818. TANGENT: boolean;
  46819. BUMP: boolean;
  46820. BUMPDIRECTUV: number;
  46821. OBJECTSPACE_NORMALMAP: boolean;
  46822. PARALLAX: boolean;
  46823. PARALLAXOCCLUSION: boolean;
  46824. NORMALXYSCALE: boolean;
  46825. LIGHTMAP: boolean;
  46826. LIGHTMAPDIRECTUV: number;
  46827. USELIGHTMAPASSHADOWMAP: boolean;
  46828. GAMMALIGHTMAP: boolean;
  46829. REFLECTION: boolean;
  46830. REFLECTIONMAP_3D: boolean;
  46831. REFLECTIONMAP_SPHERICAL: boolean;
  46832. REFLECTIONMAP_PLANAR: boolean;
  46833. REFLECTIONMAP_CUBIC: boolean;
  46834. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46835. REFLECTIONMAP_PROJECTION: boolean;
  46836. REFLECTIONMAP_SKYBOX: boolean;
  46837. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46838. REFLECTIONMAP_EXPLICIT: boolean;
  46839. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46840. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46841. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46842. INVERTCUBICMAP: boolean;
  46843. USESPHERICALFROMREFLECTIONMAP: boolean;
  46844. SPHERICAL_HARMONICS: boolean;
  46845. USESPHERICALINVERTEX: boolean;
  46846. REFLECTIONMAP_OPPOSITEZ: boolean;
  46847. LODINREFLECTIONALPHA: boolean;
  46848. GAMMAREFLECTION: boolean;
  46849. RGBDREFLECTION: boolean;
  46850. RADIANCEOCCLUSION: boolean;
  46851. HORIZONOCCLUSION: boolean;
  46852. INSTANCES: boolean;
  46853. NUM_BONE_INFLUENCERS: number;
  46854. BonesPerMesh: number;
  46855. BONETEXTURE: boolean;
  46856. NONUNIFORMSCALING: boolean;
  46857. MORPHTARGETS: boolean;
  46858. MORPHTARGETS_NORMAL: boolean;
  46859. MORPHTARGETS_TANGENT: boolean;
  46860. NUM_MORPH_INFLUENCERS: number;
  46861. IMAGEPROCESSING: boolean;
  46862. VIGNETTE: boolean;
  46863. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46864. VIGNETTEBLENDMODEOPAQUE: boolean;
  46865. TONEMAPPING: boolean;
  46866. TONEMAPPING_ACES: boolean;
  46867. CONTRAST: boolean;
  46868. COLORCURVES: boolean;
  46869. COLORGRADING: boolean;
  46870. COLORGRADING3D: boolean;
  46871. SAMPLER3DGREENDEPTH: boolean;
  46872. SAMPLER3DBGRMAP: boolean;
  46873. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46874. EXPOSURE: boolean;
  46875. MULTIVIEW: boolean;
  46876. USEPHYSICALLIGHTFALLOFF: boolean;
  46877. USEGLTFLIGHTFALLOFF: boolean;
  46878. TWOSIDEDLIGHTING: boolean;
  46879. SHADOWFLOAT: boolean;
  46880. CLIPPLANE: boolean;
  46881. CLIPPLANE2: boolean;
  46882. CLIPPLANE3: boolean;
  46883. CLIPPLANE4: boolean;
  46884. POINTSIZE: boolean;
  46885. FOG: boolean;
  46886. LOGARITHMICDEPTH: boolean;
  46887. FORCENORMALFORWARD: boolean;
  46888. SPECULARAA: boolean;
  46889. CLEARCOAT: boolean;
  46890. CLEARCOAT_DEFAULTIOR: boolean;
  46891. CLEARCOAT_TEXTURE: boolean;
  46892. CLEARCOAT_TEXTUREDIRECTUV: number;
  46893. CLEARCOAT_BUMP: boolean;
  46894. CLEARCOAT_BUMPDIRECTUV: number;
  46895. CLEARCOAT_TINT: boolean;
  46896. CLEARCOAT_TINT_TEXTURE: boolean;
  46897. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46898. ANISOTROPIC: boolean;
  46899. ANISOTROPIC_TEXTURE: boolean;
  46900. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46901. BRDF_V_HEIGHT_CORRELATED: boolean;
  46902. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46903. SHEEN: boolean;
  46904. SHEEN_TEXTURE: boolean;
  46905. SHEEN_TEXTUREDIRECTUV: number;
  46906. SHEEN_LINKWITHALBEDO: boolean;
  46907. SUBSURFACE: boolean;
  46908. SS_REFRACTION: boolean;
  46909. SS_TRANSLUCENCY: boolean;
  46910. SS_SCATERRING: boolean;
  46911. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46912. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46913. SS_REFRACTIONMAP_3D: boolean;
  46914. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46915. SS_LODINREFRACTIONALPHA: boolean;
  46916. SS_GAMMAREFRACTION: boolean;
  46917. SS_RGBDREFRACTION: boolean;
  46918. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46919. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46920. UNLIT: boolean;
  46921. DEBUGMODE: number;
  46922. /**
  46923. * Initializes the PBR Material defines.
  46924. */
  46925. constructor();
  46926. /**
  46927. * Resets the PBR Material defines.
  46928. */
  46929. reset(): void;
  46930. }
  46931. /**
  46932. * The Physically based material base class of BJS.
  46933. *
  46934. * This offers the main features of a standard PBR material.
  46935. * For more information, please refer to the documentation :
  46936. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46937. */
  46938. export abstract class PBRBaseMaterial extends PushMaterial {
  46939. /**
  46940. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46941. */
  46942. static readonly PBRMATERIAL_OPAQUE: number;
  46943. /**
  46944. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46945. */
  46946. static readonly PBRMATERIAL_ALPHATEST: number;
  46947. /**
  46948. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46949. */
  46950. static readonly PBRMATERIAL_ALPHABLEND: number;
  46951. /**
  46952. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46953. * They are also discarded below the alpha cutoff threshold to improve performances.
  46954. */
  46955. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46956. /**
  46957. * Defines the default value of how much AO map is occluding the analytical lights
  46958. * (point spot...).
  46959. */
  46960. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46961. /**
  46962. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46963. */
  46964. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46965. /**
  46966. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46967. * to enhance interoperability with other engines.
  46968. */
  46969. static readonly LIGHTFALLOFF_GLTF: number;
  46970. /**
  46971. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46972. * to enhance interoperability with other materials.
  46973. */
  46974. static readonly LIGHTFALLOFF_STANDARD: number;
  46975. /**
  46976. * Intensity of the direct lights e.g. the four lights available in your scene.
  46977. * This impacts both the direct diffuse and specular highlights.
  46978. */
  46979. protected _directIntensity: number;
  46980. /**
  46981. * Intensity of the emissive part of the material.
  46982. * This helps controlling the emissive effect without modifying the emissive color.
  46983. */
  46984. protected _emissiveIntensity: number;
  46985. /**
  46986. * Intensity of the environment e.g. how much the environment will light the object
  46987. * either through harmonics for rough material or through the refelction for shiny ones.
  46988. */
  46989. protected _environmentIntensity: number;
  46990. /**
  46991. * This is a special control allowing the reduction of the specular highlights coming from the
  46992. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46993. */
  46994. protected _specularIntensity: number;
  46995. /**
  46996. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46997. */
  46998. private _lightingInfos;
  46999. /**
  47000. * Debug Control allowing disabling the bump map on this material.
  47001. */
  47002. protected _disableBumpMap: boolean;
  47003. /**
  47004. * AKA Diffuse Texture in standard nomenclature.
  47005. */
  47006. protected _albedoTexture: Nullable<BaseTexture>;
  47007. /**
  47008. * AKA Occlusion Texture in other nomenclature.
  47009. */
  47010. protected _ambientTexture: Nullable<BaseTexture>;
  47011. /**
  47012. * AKA Occlusion Texture Intensity in other nomenclature.
  47013. */
  47014. protected _ambientTextureStrength: number;
  47015. /**
  47016. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47017. * 1 means it completely occludes it
  47018. * 0 mean it has no impact
  47019. */
  47020. protected _ambientTextureImpactOnAnalyticalLights: number;
  47021. /**
  47022. * Stores the alpha values in a texture.
  47023. */
  47024. protected _opacityTexture: Nullable<BaseTexture>;
  47025. /**
  47026. * Stores the reflection values in a texture.
  47027. */
  47028. protected _reflectionTexture: Nullable<BaseTexture>;
  47029. /**
  47030. * Stores the emissive values in a texture.
  47031. */
  47032. protected _emissiveTexture: Nullable<BaseTexture>;
  47033. /**
  47034. * AKA Specular texture in other nomenclature.
  47035. */
  47036. protected _reflectivityTexture: Nullable<BaseTexture>;
  47037. /**
  47038. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47039. */
  47040. protected _metallicTexture: Nullable<BaseTexture>;
  47041. /**
  47042. * Specifies the metallic scalar of the metallic/roughness workflow.
  47043. * Can also be used to scale the metalness values of the metallic texture.
  47044. */
  47045. protected _metallic: Nullable<number>;
  47046. /**
  47047. * Specifies the roughness scalar of the metallic/roughness workflow.
  47048. * Can also be used to scale the roughness values of the metallic texture.
  47049. */
  47050. protected _roughness: Nullable<number>;
  47051. /**
  47052. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47053. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47054. */
  47055. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47056. /**
  47057. * Stores surface normal data used to displace a mesh in a texture.
  47058. */
  47059. protected _bumpTexture: Nullable<BaseTexture>;
  47060. /**
  47061. * Stores the pre-calculated light information of a mesh in a texture.
  47062. */
  47063. protected _lightmapTexture: Nullable<BaseTexture>;
  47064. /**
  47065. * The color of a material in ambient lighting.
  47066. */
  47067. protected _ambientColor: Color3;
  47068. /**
  47069. * AKA Diffuse Color in other nomenclature.
  47070. */
  47071. protected _albedoColor: Color3;
  47072. /**
  47073. * AKA Specular Color in other nomenclature.
  47074. */
  47075. protected _reflectivityColor: Color3;
  47076. /**
  47077. * The color applied when light is reflected from a material.
  47078. */
  47079. protected _reflectionColor: Color3;
  47080. /**
  47081. * The color applied when light is emitted from a material.
  47082. */
  47083. protected _emissiveColor: Color3;
  47084. /**
  47085. * AKA Glossiness in other nomenclature.
  47086. */
  47087. protected _microSurface: number;
  47088. /**
  47089. * Specifies that the material will use the light map as a show map.
  47090. */
  47091. protected _useLightmapAsShadowmap: boolean;
  47092. /**
  47093. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47094. * makes the reflect vector face the model (under horizon).
  47095. */
  47096. protected _useHorizonOcclusion: boolean;
  47097. /**
  47098. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47099. * too much the area relying on ambient texture to define their ambient occlusion.
  47100. */
  47101. protected _useRadianceOcclusion: boolean;
  47102. /**
  47103. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47104. */
  47105. protected _useAlphaFromAlbedoTexture: boolean;
  47106. /**
  47107. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47108. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47109. */
  47110. protected _useSpecularOverAlpha: boolean;
  47111. /**
  47112. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47113. */
  47114. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47115. /**
  47116. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47117. */
  47118. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47119. /**
  47120. * Specifies if the metallic texture contains the roughness information in its green channel.
  47121. */
  47122. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47123. /**
  47124. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47125. */
  47126. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47127. /**
  47128. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47129. */
  47130. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47131. /**
  47132. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47133. */
  47134. protected _useAmbientInGrayScale: boolean;
  47135. /**
  47136. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47137. * The material will try to infer what glossiness each pixel should be.
  47138. */
  47139. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47140. /**
  47141. * Defines the falloff type used in this material.
  47142. * It by default is Physical.
  47143. */
  47144. protected _lightFalloff: number;
  47145. /**
  47146. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47147. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47148. */
  47149. protected _useRadianceOverAlpha: boolean;
  47150. /**
  47151. * Allows using an object space normal map (instead of tangent space).
  47152. */
  47153. protected _useObjectSpaceNormalMap: boolean;
  47154. /**
  47155. * Allows using the bump map in parallax mode.
  47156. */
  47157. protected _useParallax: boolean;
  47158. /**
  47159. * Allows using the bump map in parallax occlusion mode.
  47160. */
  47161. protected _useParallaxOcclusion: boolean;
  47162. /**
  47163. * Controls the scale bias of the parallax mode.
  47164. */
  47165. protected _parallaxScaleBias: number;
  47166. /**
  47167. * If sets to true, disables all the lights affecting the material.
  47168. */
  47169. protected _disableLighting: boolean;
  47170. /**
  47171. * Number of Simultaneous lights allowed on the material.
  47172. */
  47173. protected _maxSimultaneousLights: number;
  47174. /**
  47175. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47176. */
  47177. protected _invertNormalMapX: boolean;
  47178. /**
  47179. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47180. */
  47181. protected _invertNormalMapY: boolean;
  47182. /**
  47183. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47184. */
  47185. protected _twoSidedLighting: boolean;
  47186. /**
  47187. * Defines the alpha limits in alpha test mode.
  47188. */
  47189. protected _alphaCutOff: number;
  47190. /**
  47191. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47192. */
  47193. protected _forceAlphaTest: boolean;
  47194. /**
  47195. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47196. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47197. */
  47198. protected _useAlphaFresnel: boolean;
  47199. /**
  47200. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47201. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47202. */
  47203. protected _useLinearAlphaFresnel: boolean;
  47204. /**
  47205. * The transparency mode of the material.
  47206. */
  47207. protected _transparencyMode: Nullable<number>;
  47208. /**
  47209. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47210. * from cos thetav and roughness:
  47211. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47212. */
  47213. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47214. /**
  47215. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47216. */
  47217. protected _forceIrradianceInFragment: boolean;
  47218. /**
  47219. * Force normal to face away from face.
  47220. */
  47221. protected _forceNormalForward: boolean;
  47222. /**
  47223. * Enables specular anti aliasing in the PBR shader.
  47224. * It will both interacts on the Geometry for analytical and IBL lighting.
  47225. * It also prefilter the roughness map based on the bump values.
  47226. */
  47227. protected _enableSpecularAntiAliasing: boolean;
  47228. /**
  47229. * Default configuration related to image processing available in the PBR Material.
  47230. */
  47231. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47232. /**
  47233. * Keep track of the image processing observer to allow dispose and replace.
  47234. */
  47235. private _imageProcessingObserver;
  47236. /**
  47237. * Attaches a new image processing configuration to the PBR Material.
  47238. * @param configuration
  47239. */
  47240. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47241. /**
  47242. * Stores the available render targets.
  47243. */
  47244. private _renderTargets;
  47245. /**
  47246. * Sets the global ambient color for the material used in lighting calculations.
  47247. */
  47248. private _globalAmbientColor;
  47249. /**
  47250. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47251. */
  47252. private _useLogarithmicDepth;
  47253. /**
  47254. * If set to true, no lighting calculations will be applied.
  47255. */
  47256. private _unlit;
  47257. private _debugMode;
  47258. /**
  47259. * @hidden
  47260. * This is reserved for the inspector.
  47261. * Defines the material debug mode.
  47262. * It helps seeing only some components of the material while troubleshooting.
  47263. */
  47264. debugMode: number;
  47265. /**
  47266. * @hidden
  47267. * This is reserved for the inspector.
  47268. * Specify from where on screen the debug mode should start.
  47269. * The value goes from -1 (full screen) to 1 (not visible)
  47270. * It helps with side by side comparison against the final render
  47271. * This defaults to -1
  47272. */
  47273. private debugLimit;
  47274. /**
  47275. * @hidden
  47276. * This is reserved for the inspector.
  47277. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47278. * You can use the factor to better multiply the final value.
  47279. */
  47280. private debugFactor;
  47281. /**
  47282. * Defines the clear coat layer parameters for the material.
  47283. */
  47284. readonly clearCoat: PBRClearCoatConfiguration;
  47285. /**
  47286. * Defines the anisotropic parameters for the material.
  47287. */
  47288. readonly anisotropy: PBRAnisotropicConfiguration;
  47289. /**
  47290. * Defines the BRDF parameters for the material.
  47291. */
  47292. readonly brdf: PBRBRDFConfiguration;
  47293. /**
  47294. * Defines the Sheen parameters for the material.
  47295. */
  47296. readonly sheen: PBRSheenConfiguration;
  47297. /**
  47298. * Defines the SubSurface parameters for the material.
  47299. */
  47300. readonly subSurface: PBRSubSurfaceConfiguration;
  47301. /**
  47302. * Custom callback helping to override the default shader used in the material.
  47303. */
  47304. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47305. /**
  47306. * Instantiates a new PBRMaterial instance.
  47307. *
  47308. * @param name The material name
  47309. * @param scene The scene the material will be use in.
  47310. */
  47311. constructor(name: string, scene: Scene);
  47312. /**
  47313. * Gets a boolean indicating that current material needs to register RTT
  47314. */
  47315. readonly hasRenderTargetTextures: boolean;
  47316. /**
  47317. * Gets the name of the material class.
  47318. */
  47319. getClassName(): string;
  47320. /**
  47321. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47322. */
  47323. /**
  47324. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47325. */
  47326. useLogarithmicDepth: boolean;
  47327. /**
  47328. * Gets the current transparency mode.
  47329. */
  47330. /**
  47331. * Sets the transparency mode of the material.
  47332. *
  47333. * | Value | Type | Description |
  47334. * | ----- | ----------------------------------- | ----------- |
  47335. * | 0 | OPAQUE | |
  47336. * | 1 | ALPHATEST | |
  47337. * | 2 | ALPHABLEND | |
  47338. * | 3 | ALPHATESTANDBLEND | |
  47339. *
  47340. */
  47341. transparencyMode: Nullable<number>;
  47342. /**
  47343. * Returns true if alpha blending should be disabled.
  47344. */
  47345. private readonly _disableAlphaBlending;
  47346. /**
  47347. * Specifies whether or not this material should be rendered in alpha blend mode.
  47348. */
  47349. needAlphaBlending(): boolean;
  47350. /**
  47351. * Specifies if the mesh will require alpha blending.
  47352. * @param mesh - BJS mesh.
  47353. */
  47354. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47355. /**
  47356. * Specifies whether or not this material should be rendered in alpha test mode.
  47357. */
  47358. needAlphaTesting(): boolean;
  47359. /**
  47360. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47361. */
  47362. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47363. /**
  47364. * Gets the texture used for the alpha test.
  47365. */
  47366. getAlphaTestTexture(): Nullable<BaseTexture>;
  47367. /**
  47368. * Specifies that the submesh is ready to be used.
  47369. * @param mesh - BJS mesh.
  47370. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47371. * @param useInstances - Specifies that instances should be used.
  47372. * @returns - boolean indicating that the submesh is ready or not.
  47373. */
  47374. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47375. /**
  47376. * Specifies if the material uses metallic roughness workflow.
  47377. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47378. */
  47379. isMetallicWorkflow(): boolean;
  47380. private _prepareEffect;
  47381. private _prepareDefines;
  47382. /**
  47383. * Force shader compilation
  47384. */
  47385. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47386. clipPlane: boolean;
  47387. }>): void;
  47388. /**
  47389. * Initializes the uniform buffer layout for the shader.
  47390. */
  47391. buildUniformLayout(): void;
  47392. /**
  47393. * Unbinds the material from the mesh
  47394. */
  47395. unbind(): void;
  47396. /**
  47397. * Binds the submesh data.
  47398. * @param world - The world matrix.
  47399. * @param mesh - The BJS mesh.
  47400. * @param subMesh - A submesh of the BJS mesh.
  47401. */
  47402. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47403. /**
  47404. * Returns the animatable textures.
  47405. * @returns - Array of animatable textures.
  47406. */
  47407. getAnimatables(): IAnimatable[];
  47408. /**
  47409. * Returns the texture used for reflections.
  47410. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47411. */
  47412. private _getReflectionTexture;
  47413. /**
  47414. * Returns an array of the actively used textures.
  47415. * @returns - Array of BaseTextures
  47416. */
  47417. getActiveTextures(): BaseTexture[];
  47418. /**
  47419. * Checks to see if a texture is used in the material.
  47420. * @param texture - Base texture to use.
  47421. * @returns - Boolean specifying if a texture is used in the material.
  47422. */
  47423. hasTexture(texture: BaseTexture): boolean;
  47424. /**
  47425. * Disposes the resources of the material.
  47426. * @param forceDisposeEffect - Forces the disposal of effects.
  47427. * @param forceDisposeTextures - Forces the disposal of all textures.
  47428. */
  47429. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47430. }
  47431. }
  47432. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47433. import { Nullable } from "babylonjs/types";
  47434. import { Scene } from "babylonjs/scene";
  47435. import { Color3 } from "babylonjs/Maths/math";
  47436. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47437. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47438. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47439. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47440. /**
  47441. * The Physically based material of BJS.
  47442. *
  47443. * This offers the main features of a standard PBR material.
  47444. * For more information, please refer to the documentation :
  47445. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47446. */
  47447. export class PBRMaterial extends PBRBaseMaterial {
  47448. /**
  47449. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47450. */
  47451. static readonly PBRMATERIAL_OPAQUE: number;
  47452. /**
  47453. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47454. */
  47455. static readonly PBRMATERIAL_ALPHATEST: number;
  47456. /**
  47457. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47458. */
  47459. static readonly PBRMATERIAL_ALPHABLEND: number;
  47460. /**
  47461. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47462. * They are also discarded below the alpha cutoff threshold to improve performances.
  47463. */
  47464. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47465. /**
  47466. * Defines the default value of how much AO map is occluding the analytical lights
  47467. * (point spot...).
  47468. */
  47469. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47470. /**
  47471. * Intensity of the direct lights e.g. the four lights available in your scene.
  47472. * This impacts both the direct diffuse and specular highlights.
  47473. */
  47474. directIntensity: number;
  47475. /**
  47476. * Intensity of the emissive part of the material.
  47477. * This helps controlling the emissive effect without modifying the emissive color.
  47478. */
  47479. emissiveIntensity: number;
  47480. /**
  47481. * Intensity of the environment e.g. how much the environment will light the object
  47482. * either through harmonics for rough material or through the refelction for shiny ones.
  47483. */
  47484. environmentIntensity: number;
  47485. /**
  47486. * This is a special control allowing the reduction of the specular highlights coming from the
  47487. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47488. */
  47489. specularIntensity: number;
  47490. /**
  47491. * Debug Control allowing disabling the bump map on this material.
  47492. */
  47493. disableBumpMap: boolean;
  47494. /**
  47495. * AKA Diffuse Texture in standard nomenclature.
  47496. */
  47497. albedoTexture: BaseTexture;
  47498. /**
  47499. * AKA Occlusion Texture in other nomenclature.
  47500. */
  47501. ambientTexture: BaseTexture;
  47502. /**
  47503. * AKA Occlusion Texture Intensity in other nomenclature.
  47504. */
  47505. ambientTextureStrength: number;
  47506. /**
  47507. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47508. * 1 means it completely occludes it
  47509. * 0 mean it has no impact
  47510. */
  47511. ambientTextureImpactOnAnalyticalLights: number;
  47512. /**
  47513. * Stores the alpha values in a texture.
  47514. */
  47515. opacityTexture: BaseTexture;
  47516. /**
  47517. * Stores the reflection values in a texture.
  47518. */
  47519. reflectionTexture: Nullable<BaseTexture>;
  47520. /**
  47521. * Stores the emissive values in a texture.
  47522. */
  47523. emissiveTexture: BaseTexture;
  47524. /**
  47525. * AKA Specular texture in other nomenclature.
  47526. */
  47527. reflectivityTexture: BaseTexture;
  47528. /**
  47529. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47530. */
  47531. metallicTexture: BaseTexture;
  47532. /**
  47533. * Specifies the metallic scalar of the metallic/roughness workflow.
  47534. * Can also be used to scale the metalness values of the metallic texture.
  47535. */
  47536. metallic: Nullable<number>;
  47537. /**
  47538. * Specifies the roughness scalar of the metallic/roughness workflow.
  47539. * Can also be used to scale the roughness values of the metallic texture.
  47540. */
  47541. roughness: Nullable<number>;
  47542. /**
  47543. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47544. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47545. */
  47546. microSurfaceTexture: BaseTexture;
  47547. /**
  47548. * Stores surface normal data used to displace a mesh in a texture.
  47549. */
  47550. bumpTexture: BaseTexture;
  47551. /**
  47552. * Stores the pre-calculated light information of a mesh in a texture.
  47553. */
  47554. lightmapTexture: BaseTexture;
  47555. /**
  47556. * Stores the refracted light information in a texture.
  47557. */
  47558. refractionTexture: Nullable<BaseTexture>;
  47559. /**
  47560. * The color of a material in ambient lighting.
  47561. */
  47562. ambientColor: Color3;
  47563. /**
  47564. * AKA Diffuse Color in other nomenclature.
  47565. */
  47566. albedoColor: Color3;
  47567. /**
  47568. * AKA Specular Color in other nomenclature.
  47569. */
  47570. reflectivityColor: Color3;
  47571. /**
  47572. * The color reflected from the material.
  47573. */
  47574. reflectionColor: Color3;
  47575. /**
  47576. * The color emitted from the material.
  47577. */
  47578. emissiveColor: Color3;
  47579. /**
  47580. * AKA Glossiness in other nomenclature.
  47581. */
  47582. microSurface: number;
  47583. /**
  47584. * source material index of refraction (IOR)' / 'destination material IOR.
  47585. */
  47586. indexOfRefraction: number;
  47587. /**
  47588. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47589. */
  47590. invertRefractionY: boolean;
  47591. /**
  47592. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47593. * Materials half opaque for instance using refraction could benefit from this control.
  47594. */
  47595. linkRefractionWithTransparency: boolean;
  47596. /**
  47597. * If true, the light map contains occlusion information instead of lighting info.
  47598. */
  47599. useLightmapAsShadowmap: boolean;
  47600. /**
  47601. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47602. */
  47603. useAlphaFromAlbedoTexture: boolean;
  47604. /**
  47605. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47606. */
  47607. forceAlphaTest: boolean;
  47608. /**
  47609. * Defines the alpha limits in alpha test mode.
  47610. */
  47611. alphaCutOff: number;
  47612. /**
  47613. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47614. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47615. */
  47616. useSpecularOverAlpha: boolean;
  47617. /**
  47618. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47619. */
  47620. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47621. /**
  47622. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47623. */
  47624. useRoughnessFromMetallicTextureAlpha: boolean;
  47625. /**
  47626. * Specifies if the metallic texture contains the roughness information in its green channel.
  47627. */
  47628. useRoughnessFromMetallicTextureGreen: boolean;
  47629. /**
  47630. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47631. */
  47632. useMetallnessFromMetallicTextureBlue: boolean;
  47633. /**
  47634. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47635. */
  47636. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47637. /**
  47638. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47639. */
  47640. useAmbientInGrayScale: boolean;
  47641. /**
  47642. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47643. * The material will try to infer what glossiness each pixel should be.
  47644. */
  47645. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47646. /**
  47647. * BJS is using an harcoded light falloff based on a manually sets up range.
  47648. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47649. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47650. */
  47651. /**
  47652. * BJS is using an harcoded light falloff based on a manually sets up range.
  47653. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47654. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47655. */
  47656. usePhysicalLightFalloff: boolean;
  47657. /**
  47658. * In order to support the falloff compatibility with gltf, a special mode has been added
  47659. * to reproduce the gltf light falloff.
  47660. */
  47661. /**
  47662. * In order to support the falloff compatibility with gltf, a special mode has been added
  47663. * to reproduce the gltf light falloff.
  47664. */
  47665. useGLTFLightFalloff: boolean;
  47666. /**
  47667. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47668. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47669. */
  47670. useRadianceOverAlpha: boolean;
  47671. /**
  47672. * Allows using an object space normal map (instead of tangent space).
  47673. */
  47674. useObjectSpaceNormalMap: boolean;
  47675. /**
  47676. * Allows using the bump map in parallax mode.
  47677. */
  47678. useParallax: boolean;
  47679. /**
  47680. * Allows using the bump map in parallax occlusion mode.
  47681. */
  47682. useParallaxOcclusion: boolean;
  47683. /**
  47684. * Controls the scale bias of the parallax mode.
  47685. */
  47686. parallaxScaleBias: number;
  47687. /**
  47688. * If sets to true, disables all the lights affecting the material.
  47689. */
  47690. disableLighting: boolean;
  47691. /**
  47692. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47693. */
  47694. forceIrradianceInFragment: boolean;
  47695. /**
  47696. * Number of Simultaneous lights allowed on the material.
  47697. */
  47698. maxSimultaneousLights: number;
  47699. /**
  47700. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47701. */
  47702. invertNormalMapX: boolean;
  47703. /**
  47704. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47705. */
  47706. invertNormalMapY: boolean;
  47707. /**
  47708. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47709. */
  47710. twoSidedLighting: boolean;
  47711. /**
  47712. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47713. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47714. */
  47715. useAlphaFresnel: boolean;
  47716. /**
  47717. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47718. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47719. */
  47720. useLinearAlphaFresnel: boolean;
  47721. /**
  47722. * Let user defines the brdf lookup texture used for IBL.
  47723. * A default 8bit version is embedded but you could point at :
  47724. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47725. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47726. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47727. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47728. */
  47729. environmentBRDFTexture: Nullable<BaseTexture>;
  47730. /**
  47731. * Force normal to face away from face.
  47732. */
  47733. forceNormalForward: boolean;
  47734. /**
  47735. * Enables specular anti aliasing in the PBR shader.
  47736. * It will both interacts on the Geometry for analytical and IBL lighting.
  47737. * It also prefilter the roughness map based on the bump values.
  47738. */
  47739. enableSpecularAntiAliasing: boolean;
  47740. /**
  47741. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47742. * makes the reflect vector face the model (under horizon).
  47743. */
  47744. useHorizonOcclusion: boolean;
  47745. /**
  47746. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47747. * too much the area relying on ambient texture to define their ambient occlusion.
  47748. */
  47749. useRadianceOcclusion: boolean;
  47750. /**
  47751. * If set to true, no lighting calculations will be applied.
  47752. */
  47753. unlit: boolean;
  47754. /**
  47755. * Gets the image processing configuration used either in this material.
  47756. */
  47757. /**
  47758. * Sets the Default image processing configuration used either in the this material.
  47759. *
  47760. * If sets to null, the scene one is in use.
  47761. */
  47762. imageProcessingConfiguration: ImageProcessingConfiguration;
  47763. /**
  47764. * Gets wether the color curves effect is enabled.
  47765. */
  47766. /**
  47767. * Sets wether the color curves effect is enabled.
  47768. */
  47769. cameraColorCurvesEnabled: boolean;
  47770. /**
  47771. * Gets wether the color grading effect is enabled.
  47772. */
  47773. /**
  47774. * Gets wether the color grading effect is enabled.
  47775. */
  47776. cameraColorGradingEnabled: boolean;
  47777. /**
  47778. * Gets wether tonemapping is enabled or not.
  47779. */
  47780. /**
  47781. * Sets wether tonemapping is enabled or not
  47782. */
  47783. cameraToneMappingEnabled: boolean;
  47784. /**
  47785. * The camera exposure used on this material.
  47786. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47787. * This corresponds to a photographic exposure.
  47788. */
  47789. /**
  47790. * The camera exposure used on this material.
  47791. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47792. * This corresponds to a photographic exposure.
  47793. */
  47794. cameraExposure: number;
  47795. /**
  47796. * Gets The camera contrast used on this material.
  47797. */
  47798. /**
  47799. * Sets The camera contrast used on this material.
  47800. */
  47801. cameraContrast: number;
  47802. /**
  47803. * Gets the Color Grading 2D Lookup Texture.
  47804. */
  47805. /**
  47806. * Sets the Color Grading 2D Lookup Texture.
  47807. */
  47808. cameraColorGradingTexture: Nullable<BaseTexture>;
  47809. /**
  47810. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47811. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47812. * 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;
  47813. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47814. */
  47815. /**
  47816. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47817. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47818. * 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;
  47819. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47820. */
  47821. cameraColorCurves: Nullable<ColorCurves>;
  47822. /**
  47823. * Instantiates a new PBRMaterial instance.
  47824. *
  47825. * @param name The material name
  47826. * @param scene The scene the material will be use in.
  47827. */
  47828. constructor(name: string, scene: Scene);
  47829. /**
  47830. * Returns the name of this material class.
  47831. */
  47832. getClassName(): string;
  47833. /**
  47834. * Makes a duplicate of the current material.
  47835. * @param name - name to use for the new material.
  47836. */
  47837. clone(name: string): PBRMaterial;
  47838. /**
  47839. * Serializes this PBR Material.
  47840. * @returns - An object with the serialized material.
  47841. */
  47842. serialize(): any;
  47843. /**
  47844. * Parses a PBR Material from a serialized object.
  47845. * @param source - Serialized object.
  47846. * @param scene - BJS scene instance.
  47847. * @param rootUrl - url for the scene object
  47848. * @returns - PBRMaterial
  47849. */
  47850. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47851. }
  47852. }
  47853. declare module "babylonjs/Misc/dds" {
  47854. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47855. import { Engine } from "babylonjs/Engines/engine";
  47856. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47857. import { Nullable } from "babylonjs/types";
  47858. import { Scene } from "babylonjs/scene";
  47859. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47860. /**
  47861. * Direct draw surface info
  47862. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47863. */
  47864. export interface DDSInfo {
  47865. /**
  47866. * Width of the texture
  47867. */
  47868. width: number;
  47869. /**
  47870. * Width of the texture
  47871. */
  47872. height: number;
  47873. /**
  47874. * Number of Mipmaps for the texture
  47875. * @see https://en.wikipedia.org/wiki/Mipmap
  47876. */
  47877. mipmapCount: number;
  47878. /**
  47879. * If the textures format is a known fourCC format
  47880. * @see https://www.fourcc.org/
  47881. */
  47882. isFourCC: boolean;
  47883. /**
  47884. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47885. */
  47886. isRGB: boolean;
  47887. /**
  47888. * If the texture is a lumincance format
  47889. */
  47890. isLuminance: boolean;
  47891. /**
  47892. * If this is a cube texture
  47893. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47894. */
  47895. isCube: boolean;
  47896. /**
  47897. * If the texture is a compressed format eg. FOURCC_DXT1
  47898. */
  47899. isCompressed: boolean;
  47900. /**
  47901. * The dxgiFormat of the texture
  47902. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47903. */
  47904. dxgiFormat: number;
  47905. /**
  47906. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47907. */
  47908. textureType: number;
  47909. /**
  47910. * Sphericle polynomial created for the dds texture
  47911. */
  47912. sphericalPolynomial?: SphericalPolynomial;
  47913. }
  47914. /**
  47915. * Class used to provide DDS decompression tools
  47916. */
  47917. export class DDSTools {
  47918. /**
  47919. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47920. */
  47921. static StoreLODInAlphaChannel: boolean;
  47922. /**
  47923. * Gets DDS information from an array buffer
  47924. * @param arrayBuffer defines the array buffer to read data from
  47925. * @returns the DDS information
  47926. */
  47927. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47928. private static _FloatView;
  47929. private static _Int32View;
  47930. private static _ToHalfFloat;
  47931. private static _FromHalfFloat;
  47932. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47933. private static _GetHalfFloatRGBAArrayBuffer;
  47934. private static _GetFloatRGBAArrayBuffer;
  47935. private static _GetFloatAsUIntRGBAArrayBuffer;
  47936. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47937. private static _GetRGBAArrayBuffer;
  47938. private static _ExtractLongWordOrder;
  47939. private static _GetRGBArrayBuffer;
  47940. private static _GetLuminanceArrayBuffer;
  47941. /**
  47942. * Uploads DDS Levels to a Babylon Texture
  47943. * @hidden
  47944. */
  47945. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47946. }
  47947. module "babylonjs/Engines/engine" {
  47948. interface Engine {
  47949. /**
  47950. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47951. * @param rootUrl defines the url where the file to load is located
  47952. * @param scene defines the current scene
  47953. * @param lodScale defines scale to apply to the mip map selection
  47954. * @param lodOffset defines offset to apply to the mip map selection
  47955. * @param onLoad defines an optional callback raised when the texture is loaded
  47956. * @param onError defines an optional callback raised if there is an issue to load the texture
  47957. * @param format defines the format of the data
  47958. * @param forcedExtension defines the extension to use to pick the right loader
  47959. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47960. * @returns the cube texture as an InternalTexture
  47961. */
  47962. 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;
  47963. }
  47964. }
  47965. }
  47966. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47967. import { Nullable } from "babylonjs/types";
  47968. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47969. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47970. /**
  47971. * Implementation of the DDS Texture Loader.
  47972. * @hidden
  47973. */
  47974. export class _DDSTextureLoader implements IInternalTextureLoader {
  47975. /**
  47976. * Defines wether the loader supports cascade loading the different faces.
  47977. */
  47978. readonly supportCascades: boolean;
  47979. /**
  47980. * This returns if the loader support the current file information.
  47981. * @param extension defines the file extension of the file being loaded
  47982. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47983. * @param fallback defines the fallback internal texture if any
  47984. * @param isBase64 defines whether the texture is encoded as a base64
  47985. * @param isBuffer defines whether the texture data are stored as a buffer
  47986. * @returns true if the loader can load the specified file
  47987. */
  47988. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47989. /**
  47990. * Transform the url before loading if required.
  47991. * @param rootUrl the url of the texture
  47992. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47993. * @returns the transformed texture
  47994. */
  47995. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47996. /**
  47997. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47998. * @param rootUrl the url of the texture
  47999. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48000. * @returns the fallback texture
  48001. */
  48002. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48003. /**
  48004. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48005. * @param data contains the texture data
  48006. * @param texture defines the BabylonJS internal texture
  48007. * @param createPolynomials will be true if polynomials have been requested
  48008. * @param onLoad defines the callback to trigger once the texture is ready
  48009. * @param onError defines the callback to trigger in case of error
  48010. */
  48011. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48012. /**
  48013. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48014. * @param data contains the texture data
  48015. * @param texture defines the BabylonJS internal texture
  48016. * @param callback defines the method to call once ready to upload
  48017. */
  48018. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48019. }
  48020. }
  48021. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48022. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48023. /** @hidden */
  48024. export var rgbdEncodePixelShader: {
  48025. name: string;
  48026. shader: string;
  48027. };
  48028. }
  48029. declare module "babylonjs/Misc/environmentTextureTools" {
  48030. import { Nullable } from "babylonjs/types";
  48031. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48032. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48033. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48034. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48035. import "babylonjs/Shaders/rgbdEncode.fragment";
  48036. import "babylonjs/Shaders/rgbdDecode.fragment";
  48037. /**
  48038. * Raw texture data and descriptor sufficient for WebGL texture upload
  48039. */
  48040. export interface EnvironmentTextureInfo {
  48041. /**
  48042. * Version of the environment map
  48043. */
  48044. version: number;
  48045. /**
  48046. * Width of image
  48047. */
  48048. width: number;
  48049. /**
  48050. * Irradiance information stored in the file.
  48051. */
  48052. irradiance: any;
  48053. /**
  48054. * Specular information stored in the file.
  48055. */
  48056. specular: any;
  48057. }
  48058. /**
  48059. * Sets of helpers addressing the serialization and deserialization of environment texture
  48060. * stored in a BabylonJS env file.
  48061. * Those files are usually stored as .env files.
  48062. */
  48063. export class EnvironmentTextureTools {
  48064. /**
  48065. * Magic number identifying the env file.
  48066. */
  48067. private static _MagicBytes;
  48068. /**
  48069. * Gets the environment info from an env file.
  48070. * @param data The array buffer containing the .env bytes.
  48071. * @returns the environment file info (the json header) if successfully parsed.
  48072. */
  48073. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48074. /**
  48075. * Creates an environment texture from a loaded cube texture.
  48076. * @param texture defines the cube texture to convert in env file
  48077. * @return a promise containing the environment data if succesfull.
  48078. */
  48079. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48080. /**
  48081. * Creates a JSON representation of the spherical data.
  48082. * @param texture defines the texture containing the polynomials
  48083. * @return the JSON representation of the spherical info
  48084. */
  48085. private static _CreateEnvTextureIrradiance;
  48086. /**
  48087. * Uploads the texture info contained in the env file to the GPU.
  48088. * @param texture defines the internal texture to upload to
  48089. * @param arrayBuffer defines the buffer cotaining the data to load
  48090. * @param info defines the texture info retrieved through the GetEnvInfo method
  48091. * @returns a promise
  48092. */
  48093. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48094. /**
  48095. * Uploads the levels of image data to the GPU.
  48096. * @param texture defines the internal texture to upload to
  48097. * @param imageData defines the array buffer views of image data [mipmap][face]
  48098. * @returns a promise
  48099. */
  48100. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48101. /**
  48102. * Uploads spherical polynomials information to the texture.
  48103. * @param texture defines the texture we are trying to upload the information to
  48104. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48105. */
  48106. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48107. /** @hidden */
  48108. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48109. }
  48110. }
  48111. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48112. import { Nullable } from "babylonjs/types";
  48113. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48114. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48115. /**
  48116. * Implementation of the ENV Texture Loader.
  48117. * @hidden
  48118. */
  48119. export class _ENVTextureLoader implements IInternalTextureLoader {
  48120. /**
  48121. * Defines wether the loader supports cascade loading the different faces.
  48122. */
  48123. readonly supportCascades: boolean;
  48124. /**
  48125. * This returns if the loader support the current file information.
  48126. * @param extension defines the file extension of the file being loaded
  48127. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48128. * @param fallback defines the fallback internal texture if any
  48129. * @param isBase64 defines whether the texture is encoded as a base64
  48130. * @param isBuffer defines whether the texture data are stored as a buffer
  48131. * @returns true if the loader can load the specified file
  48132. */
  48133. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48134. /**
  48135. * Transform the url before loading if required.
  48136. * @param rootUrl the url of the texture
  48137. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48138. * @returns the transformed texture
  48139. */
  48140. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48141. /**
  48142. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48143. * @param rootUrl the url of the texture
  48144. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48145. * @returns the fallback texture
  48146. */
  48147. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48148. /**
  48149. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48150. * @param data contains the texture data
  48151. * @param texture defines the BabylonJS internal texture
  48152. * @param createPolynomials will be true if polynomials have been requested
  48153. * @param onLoad defines the callback to trigger once the texture is ready
  48154. * @param onError defines the callback to trigger in case of error
  48155. */
  48156. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48157. /**
  48158. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48159. * @param data contains the texture data
  48160. * @param texture defines the BabylonJS internal texture
  48161. * @param callback defines the method to call once ready to upload
  48162. */
  48163. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48164. }
  48165. }
  48166. declare module "babylonjs/Misc/khronosTextureContainer" {
  48167. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48168. /**
  48169. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48170. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48171. */
  48172. export class KhronosTextureContainer {
  48173. /** contents of the KTX container file */
  48174. arrayBuffer: any;
  48175. private static HEADER_LEN;
  48176. private static COMPRESSED_2D;
  48177. private static COMPRESSED_3D;
  48178. private static TEX_2D;
  48179. private static TEX_3D;
  48180. /**
  48181. * Gets the openGL type
  48182. */
  48183. glType: number;
  48184. /**
  48185. * Gets the openGL type size
  48186. */
  48187. glTypeSize: number;
  48188. /**
  48189. * Gets the openGL format
  48190. */
  48191. glFormat: number;
  48192. /**
  48193. * Gets the openGL internal format
  48194. */
  48195. glInternalFormat: number;
  48196. /**
  48197. * Gets the base internal format
  48198. */
  48199. glBaseInternalFormat: number;
  48200. /**
  48201. * Gets image width in pixel
  48202. */
  48203. pixelWidth: number;
  48204. /**
  48205. * Gets image height in pixel
  48206. */
  48207. pixelHeight: number;
  48208. /**
  48209. * Gets image depth in pixels
  48210. */
  48211. pixelDepth: number;
  48212. /**
  48213. * Gets the number of array elements
  48214. */
  48215. numberOfArrayElements: number;
  48216. /**
  48217. * Gets the number of faces
  48218. */
  48219. numberOfFaces: number;
  48220. /**
  48221. * Gets the number of mipmap levels
  48222. */
  48223. numberOfMipmapLevels: number;
  48224. /**
  48225. * Gets the bytes of key value data
  48226. */
  48227. bytesOfKeyValueData: number;
  48228. /**
  48229. * Gets the load type
  48230. */
  48231. loadType: number;
  48232. /**
  48233. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48234. */
  48235. isInvalid: boolean;
  48236. /**
  48237. * Creates a new KhronosTextureContainer
  48238. * @param arrayBuffer contents of the KTX container file
  48239. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48240. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48241. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48242. */
  48243. constructor(
  48244. /** contents of the KTX container file */
  48245. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48246. /**
  48247. * Uploads KTX content to a Babylon Texture.
  48248. * It is assumed that the texture has already been created & is currently bound
  48249. * @hidden
  48250. */
  48251. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48252. private _upload2DCompressedLevels;
  48253. }
  48254. }
  48255. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48256. import { Nullable } from "babylonjs/types";
  48257. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48258. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48259. /**
  48260. * Implementation of the KTX Texture Loader.
  48261. * @hidden
  48262. */
  48263. export class _KTXTextureLoader implements IInternalTextureLoader {
  48264. /**
  48265. * Defines wether the loader supports cascade loading the different faces.
  48266. */
  48267. readonly supportCascades: boolean;
  48268. /**
  48269. * This returns if the loader support the current file information.
  48270. * @param extension defines the file extension of the file being loaded
  48271. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48272. * @param fallback defines the fallback internal texture if any
  48273. * @param isBase64 defines whether the texture is encoded as a base64
  48274. * @param isBuffer defines whether the texture data are stored as a buffer
  48275. * @returns true if the loader can load the specified file
  48276. */
  48277. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48278. /**
  48279. * Transform the url before loading if required.
  48280. * @param rootUrl the url of the texture
  48281. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48282. * @returns the transformed texture
  48283. */
  48284. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48285. /**
  48286. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48287. * @param rootUrl the url of the texture
  48288. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48289. * @returns the fallback texture
  48290. */
  48291. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48292. /**
  48293. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48294. * @param data contains the texture data
  48295. * @param texture defines the BabylonJS internal texture
  48296. * @param createPolynomials will be true if polynomials have been requested
  48297. * @param onLoad defines the callback to trigger once the texture is ready
  48298. * @param onError defines the callback to trigger in case of error
  48299. */
  48300. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48301. /**
  48302. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48303. * @param data contains the texture data
  48304. * @param texture defines the BabylonJS internal texture
  48305. * @param callback defines the method to call once ready to upload
  48306. */
  48307. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48308. }
  48309. }
  48310. declare module "babylonjs/Helpers/sceneHelpers" {
  48311. import { Nullable } from "babylonjs/types";
  48312. import { Mesh } from "babylonjs/Meshes/mesh";
  48313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48314. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48315. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48316. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48317. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48318. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48319. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48320. import "babylonjs/Meshes/Builders/boxBuilder";
  48321. /** @hidden */
  48322. export var _forceSceneHelpersToBundle: boolean;
  48323. module "babylonjs/scene" {
  48324. interface Scene {
  48325. /**
  48326. * Creates a default light for the scene.
  48327. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48328. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48329. */
  48330. createDefaultLight(replace?: boolean): void;
  48331. /**
  48332. * Creates a default camera for the scene.
  48333. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48334. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48335. * @param replace has default false, when true replaces the active camera in the scene
  48336. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48337. */
  48338. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48339. /**
  48340. * Creates a default camera and a default light.
  48341. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48342. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48343. * @param replace has the default false, when true replaces the active camera/light in the scene
  48344. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48345. */
  48346. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48347. /**
  48348. * Creates a new sky box
  48349. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48350. * @param environmentTexture defines the texture to use as environment texture
  48351. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48352. * @param scale defines the overall scale of the skybox
  48353. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48354. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48355. * @returns a new mesh holding the sky box
  48356. */
  48357. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48358. /**
  48359. * Creates a new environment
  48360. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48361. * @param options defines the options you can use to configure the environment
  48362. * @returns the new EnvironmentHelper
  48363. */
  48364. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48365. /**
  48366. * Creates a new VREXperienceHelper
  48367. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48368. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48369. * @returns a new VREXperienceHelper
  48370. */
  48371. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48372. /**
  48373. * Creates a new XREXperienceHelper
  48374. * @see http://doc.babylonjs.com/how_to/webxr
  48375. * @returns a promise for a new XREXperienceHelper
  48376. */
  48377. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48378. }
  48379. }
  48380. }
  48381. declare module "babylonjs/Helpers/videoDome" {
  48382. import { Scene } from "babylonjs/scene";
  48383. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48384. import { Mesh } from "babylonjs/Meshes/mesh";
  48385. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48386. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48387. import "babylonjs/Meshes/Builders/sphereBuilder";
  48388. /**
  48389. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48390. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48391. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48392. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48393. */
  48394. export class VideoDome extends TransformNode {
  48395. /**
  48396. * Define the video source as a Monoscopic panoramic 360 video.
  48397. */
  48398. static readonly MODE_MONOSCOPIC: number;
  48399. /**
  48400. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48401. */
  48402. static readonly MODE_TOPBOTTOM: number;
  48403. /**
  48404. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48405. */
  48406. static readonly MODE_SIDEBYSIDE: number;
  48407. private _useDirectMapping;
  48408. /**
  48409. * The video texture being displayed on the sphere
  48410. */
  48411. protected _videoTexture: VideoTexture;
  48412. /**
  48413. * Gets the video texture being displayed on the sphere
  48414. */
  48415. readonly videoTexture: VideoTexture;
  48416. /**
  48417. * The skybox material
  48418. */
  48419. protected _material: BackgroundMaterial;
  48420. /**
  48421. * The surface used for the skybox
  48422. */
  48423. protected _mesh: Mesh;
  48424. /**
  48425. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48426. * Also see the options.resolution property.
  48427. */
  48428. fovMultiplier: number;
  48429. private _videoMode;
  48430. /**
  48431. * Gets or set the current video mode for the video. It can be:
  48432. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48433. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48434. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48435. */
  48436. videoMode: number;
  48437. /**
  48438. * Oberserver used in Stereoscopic VR Mode.
  48439. */
  48440. private _onBeforeCameraRenderObserver;
  48441. /**
  48442. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48443. * @param name Element's name, child elements will append suffixes for their own names.
  48444. * @param urlsOrVideo defines the url(s) or the video element to use
  48445. * @param options An object containing optional or exposed sub element properties
  48446. */
  48447. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48448. resolution?: number;
  48449. clickToPlay?: boolean;
  48450. autoPlay?: boolean;
  48451. loop?: boolean;
  48452. size?: number;
  48453. poster?: string;
  48454. faceForward?: boolean;
  48455. useDirectMapping?: boolean;
  48456. }, scene: Scene);
  48457. private _changeVideoMode;
  48458. /**
  48459. * Releases resources associated with this node.
  48460. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48461. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48462. */
  48463. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48464. }
  48465. }
  48466. declare module "babylonjs/Helpers/index" {
  48467. export * from "babylonjs/Helpers/environmentHelper";
  48468. export * from "babylonjs/Helpers/photoDome";
  48469. export * from "babylonjs/Helpers/sceneHelpers";
  48470. export * from "babylonjs/Helpers/videoDome";
  48471. }
  48472. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48473. import { PerfCounter } from "babylonjs/Misc/tools";
  48474. import { IDisposable } from "babylonjs/scene";
  48475. import { Engine } from "babylonjs/Engines/engine";
  48476. /**
  48477. * This class can be used to get instrumentation data from a Babylon engine
  48478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48479. */
  48480. export class EngineInstrumentation implements IDisposable {
  48481. /**
  48482. * Define the instrumented engine.
  48483. */
  48484. engine: Engine;
  48485. private _captureGPUFrameTime;
  48486. private _gpuFrameTimeToken;
  48487. private _gpuFrameTime;
  48488. private _captureShaderCompilationTime;
  48489. private _shaderCompilationTime;
  48490. private _onBeginFrameObserver;
  48491. private _onEndFrameObserver;
  48492. private _onBeforeShaderCompilationObserver;
  48493. private _onAfterShaderCompilationObserver;
  48494. /**
  48495. * Gets the perf counter used for GPU frame time
  48496. */
  48497. readonly gpuFrameTimeCounter: PerfCounter;
  48498. /**
  48499. * Gets the GPU frame time capture status
  48500. */
  48501. /**
  48502. * Enable or disable the GPU frame time capture
  48503. */
  48504. captureGPUFrameTime: boolean;
  48505. /**
  48506. * Gets the perf counter used for shader compilation time
  48507. */
  48508. readonly shaderCompilationTimeCounter: PerfCounter;
  48509. /**
  48510. * Gets the shader compilation time capture status
  48511. */
  48512. /**
  48513. * Enable or disable the shader compilation time capture
  48514. */
  48515. captureShaderCompilationTime: boolean;
  48516. /**
  48517. * Instantiates a new engine instrumentation.
  48518. * This class can be used to get instrumentation data from a Babylon engine
  48519. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48520. * @param engine Defines the engine to instrument
  48521. */
  48522. constructor(
  48523. /**
  48524. * Define the instrumented engine.
  48525. */
  48526. engine: Engine);
  48527. /**
  48528. * Dispose and release associated resources.
  48529. */
  48530. dispose(): void;
  48531. }
  48532. }
  48533. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48534. import { PerfCounter } from "babylonjs/Misc/tools";
  48535. import { Scene, IDisposable } from "babylonjs/scene";
  48536. /**
  48537. * This class can be used to get instrumentation data from a Babylon engine
  48538. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48539. */
  48540. export class SceneInstrumentation implements IDisposable {
  48541. /**
  48542. * Defines the scene to instrument
  48543. */
  48544. scene: Scene;
  48545. private _captureActiveMeshesEvaluationTime;
  48546. private _activeMeshesEvaluationTime;
  48547. private _captureRenderTargetsRenderTime;
  48548. private _renderTargetsRenderTime;
  48549. private _captureFrameTime;
  48550. private _frameTime;
  48551. private _captureRenderTime;
  48552. private _renderTime;
  48553. private _captureInterFrameTime;
  48554. private _interFrameTime;
  48555. private _captureParticlesRenderTime;
  48556. private _particlesRenderTime;
  48557. private _captureSpritesRenderTime;
  48558. private _spritesRenderTime;
  48559. private _capturePhysicsTime;
  48560. private _physicsTime;
  48561. private _captureAnimationsTime;
  48562. private _animationsTime;
  48563. private _captureCameraRenderTime;
  48564. private _cameraRenderTime;
  48565. private _onBeforeActiveMeshesEvaluationObserver;
  48566. private _onAfterActiveMeshesEvaluationObserver;
  48567. private _onBeforeRenderTargetsRenderObserver;
  48568. private _onAfterRenderTargetsRenderObserver;
  48569. private _onAfterRenderObserver;
  48570. private _onBeforeDrawPhaseObserver;
  48571. private _onAfterDrawPhaseObserver;
  48572. private _onBeforeAnimationsObserver;
  48573. private _onBeforeParticlesRenderingObserver;
  48574. private _onAfterParticlesRenderingObserver;
  48575. private _onBeforeSpritesRenderingObserver;
  48576. private _onAfterSpritesRenderingObserver;
  48577. private _onBeforePhysicsObserver;
  48578. private _onAfterPhysicsObserver;
  48579. private _onAfterAnimationsObserver;
  48580. private _onBeforeCameraRenderObserver;
  48581. private _onAfterCameraRenderObserver;
  48582. /**
  48583. * Gets the perf counter used for active meshes evaluation time
  48584. */
  48585. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48586. /**
  48587. * Gets the active meshes evaluation time capture status
  48588. */
  48589. /**
  48590. * Enable or disable the active meshes evaluation time capture
  48591. */
  48592. captureActiveMeshesEvaluationTime: boolean;
  48593. /**
  48594. * Gets the perf counter used for render targets render time
  48595. */
  48596. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48597. /**
  48598. * Gets the render targets render time capture status
  48599. */
  48600. /**
  48601. * Enable or disable the render targets render time capture
  48602. */
  48603. captureRenderTargetsRenderTime: boolean;
  48604. /**
  48605. * Gets the perf counter used for particles render time
  48606. */
  48607. readonly particlesRenderTimeCounter: PerfCounter;
  48608. /**
  48609. * Gets the particles render time capture status
  48610. */
  48611. /**
  48612. * Enable or disable the particles render time capture
  48613. */
  48614. captureParticlesRenderTime: boolean;
  48615. /**
  48616. * Gets the perf counter used for sprites render time
  48617. */
  48618. readonly spritesRenderTimeCounter: PerfCounter;
  48619. /**
  48620. * Gets the sprites render time capture status
  48621. */
  48622. /**
  48623. * Enable or disable the sprites render time capture
  48624. */
  48625. captureSpritesRenderTime: boolean;
  48626. /**
  48627. * Gets the perf counter used for physics time
  48628. */
  48629. readonly physicsTimeCounter: PerfCounter;
  48630. /**
  48631. * Gets the physics time capture status
  48632. */
  48633. /**
  48634. * Enable or disable the physics time capture
  48635. */
  48636. capturePhysicsTime: boolean;
  48637. /**
  48638. * Gets the perf counter used for animations time
  48639. */
  48640. readonly animationsTimeCounter: PerfCounter;
  48641. /**
  48642. * Gets the animations time capture status
  48643. */
  48644. /**
  48645. * Enable or disable the animations time capture
  48646. */
  48647. captureAnimationsTime: boolean;
  48648. /**
  48649. * Gets the perf counter used for frame time capture
  48650. */
  48651. readonly frameTimeCounter: PerfCounter;
  48652. /**
  48653. * Gets the frame time capture status
  48654. */
  48655. /**
  48656. * Enable or disable the frame time capture
  48657. */
  48658. captureFrameTime: boolean;
  48659. /**
  48660. * Gets the perf counter used for inter-frames time capture
  48661. */
  48662. readonly interFrameTimeCounter: PerfCounter;
  48663. /**
  48664. * Gets the inter-frames time capture status
  48665. */
  48666. /**
  48667. * Enable or disable the inter-frames time capture
  48668. */
  48669. captureInterFrameTime: boolean;
  48670. /**
  48671. * Gets the perf counter used for render time capture
  48672. */
  48673. readonly renderTimeCounter: PerfCounter;
  48674. /**
  48675. * Gets the render time capture status
  48676. */
  48677. /**
  48678. * Enable or disable the render time capture
  48679. */
  48680. captureRenderTime: boolean;
  48681. /**
  48682. * Gets the perf counter used for camera render time capture
  48683. */
  48684. readonly cameraRenderTimeCounter: PerfCounter;
  48685. /**
  48686. * Gets the camera render time capture status
  48687. */
  48688. /**
  48689. * Enable or disable the camera render time capture
  48690. */
  48691. captureCameraRenderTime: boolean;
  48692. /**
  48693. * Gets the perf counter used for draw calls
  48694. */
  48695. readonly drawCallsCounter: PerfCounter;
  48696. /**
  48697. * Instantiates a new scene instrumentation.
  48698. * This class can be used to get instrumentation data from a Babylon engine
  48699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48700. * @param scene Defines the scene to instrument
  48701. */
  48702. constructor(
  48703. /**
  48704. * Defines the scene to instrument
  48705. */
  48706. scene: Scene);
  48707. /**
  48708. * Dispose and release associated resources.
  48709. */
  48710. dispose(): void;
  48711. }
  48712. }
  48713. declare module "babylonjs/Instrumentation/index" {
  48714. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48715. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48716. export * from "babylonjs/Instrumentation/timeToken";
  48717. }
  48718. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48719. /** @hidden */
  48720. export var glowMapGenerationPixelShader: {
  48721. name: string;
  48722. shader: string;
  48723. };
  48724. }
  48725. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48726. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48727. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48728. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48729. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48730. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48731. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48732. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48733. /** @hidden */
  48734. export var glowMapGenerationVertexShader: {
  48735. name: string;
  48736. shader: string;
  48737. };
  48738. }
  48739. declare module "babylonjs/Layers/effectLayer" {
  48740. import { Observable } from "babylonjs/Misc/observable";
  48741. import { Nullable } from "babylonjs/types";
  48742. import { Camera } from "babylonjs/Cameras/camera";
  48743. import { Scene } from "babylonjs/scene";
  48744. import { Color4, ISize } from "babylonjs/Maths/math";
  48745. import { Engine } from "babylonjs/Engines/engine";
  48746. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48748. import { Mesh } from "babylonjs/Meshes/mesh";
  48749. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48750. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48751. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48752. import { Effect } from "babylonjs/Materials/effect";
  48753. import { Material } from "babylonjs/Materials/material";
  48754. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48755. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48756. /**
  48757. * Effect layer options. This helps customizing the behaviour
  48758. * of the effect layer.
  48759. */
  48760. export interface IEffectLayerOptions {
  48761. /**
  48762. * Multiplication factor apply to the canvas size to compute the render target size
  48763. * used to generated the objects (the smaller the faster).
  48764. */
  48765. mainTextureRatio: number;
  48766. /**
  48767. * Enforces a fixed size texture to ensure effect stability across devices.
  48768. */
  48769. mainTextureFixedSize?: number;
  48770. /**
  48771. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48772. */
  48773. alphaBlendingMode: number;
  48774. /**
  48775. * The camera attached to the layer.
  48776. */
  48777. camera: Nullable<Camera>;
  48778. /**
  48779. * The rendering group to draw the layer in.
  48780. */
  48781. renderingGroupId: number;
  48782. }
  48783. /**
  48784. * The effect layer Helps adding post process effect blended with the main pass.
  48785. *
  48786. * This can be for instance use to generate glow or higlight effects on the scene.
  48787. *
  48788. * The effect layer class can not be used directly and is intented to inherited from to be
  48789. * customized per effects.
  48790. */
  48791. export abstract class EffectLayer {
  48792. private _vertexBuffers;
  48793. private _indexBuffer;
  48794. private _cachedDefines;
  48795. private _effectLayerMapGenerationEffect;
  48796. private _effectLayerOptions;
  48797. private _mergeEffect;
  48798. protected _scene: Scene;
  48799. protected _engine: Engine;
  48800. protected _maxSize: number;
  48801. protected _mainTextureDesiredSize: ISize;
  48802. protected _mainTexture: RenderTargetTexture;
  48803. protected _shouldRender: boolean;
  48804. protected _postProcesses: PostProcess[];
  48805. protected _textures: BaseTexture[];
  48806. protected _emissiveTextureAndColor: {
  48807. texture: Nullable<BaseTexture>;
  48808. color: Color4;
  48809. };
  48810. /**
  48811. * The name of the layer
  48812. */
  48813. name: string;
  48814. /**
  48815. * The clear color of the texture used to generate the glow map.
  48816. */
  48817. neutralColor: Color4;
  48818. /**
  48819. * Specifies wether the highlight layer is enabled or not.
  48820. */
  48821. isEnabled: boolean;
  48822. /**
  48823. * Gets the camera attached to the layer.
  48824. */
  48825. readonly camera: Nullable<Camera>;
  48826. /**
  48827. * Gets the rendering group id the layer should render in.
  48828. */
  48829. readonly renderingGroupId: number;
  48830. /**
  48831. * An event triggered when the effect layer has been disposed.
  48832. */
  48833. onDisposeObservable: Observable<EffectLayer>;
  48834. /**
  48835. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48836. */
  48837. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48838. /**
  48839. * An event triggered when the generated texture is being merged in the scene.
  48840. */
  48841. onBeforeComposeObservable: Observable<EffectLayer>;
  48842. /**
  48843. * An event triggered when the generated texture has been merged in the scene.
  48844. */
  48845. onAfterComposeObservable: Observable<EffectLayer>;
  48846. /**
  48847. * An event triggered when the efffect layer changes its size.
  48848. */
  48849. onSizeChangedObservable: Observable<EffectLayer>;
  48850. /** @hidden */
  48851. static _SceneComponentInitialization: (scene: Scene) => void;
  48852. /**
  48853. * Instantiates a new effect Layer and references it in the scene.
  48854. * @param name The name of the layer
  48855. * @param scene The scene to use the layer in
  48856. */
  48857. constructor(
  48858. /** The Friendly of the effect in the scene */
  48859. name: string, scene: Scene);
  48860. /**
  48861. * Get the effect name of the layer.
  48862. * @return The effect name
  48863. */
  48864. abstract getEffectName(): string;
  48865. /**
  48866. * Checks for the readiness of the element composing the layer.
  48867. * @param subMesh the mesh to check for
  48868. * @param useInstances specify wether or not to use instances to render the mesh
  48869. * @return true if ready otherwise, false
  48870. */
  48871. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48872. /**
  48873. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48874. * @returns true if the effect requires stencil during the main canvas render pass.
  48875. */
  48876. abstract needStencil(): boolean;
  48877. /**
  48878. * Create the merge effect. This is the shader use to blit the information back
  48879. * to the main canvas at the end of the scene rendering.
  48880. * @returns The effect containing the shader used to merge the effect on the main canvas
  48881. */
  48882. protected abstract _createMergeEffect(): Effect;
  48883. /**
  48884. * Creates the render target textures and post processes used in the effect layer.
  48885. */
  48886. protected abstract _createTextureAndPostProcesses(): void;
  48887. /**
  48888. * Implementation specific of rendering the generating effect on the main canvas.
  48889. * @param effect The effect used to render through
  48890. */
  48891. protected abstract _internalRender(effect: Effect): void;
  48892. /**
  48893. * Sets the required values for both the emissive texture and and the main color.
  48894. */
  48895. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48896. /**
  48897. * Free any resources and references associated to a mesh.
  48898. * Internal use
  48899. * @param mesh The mesh to free.
  48900. */
  48901. abstract _disposeMesh(mesh: Mesh): void;
  48902. /**
  48903. * Serializes this layer (Glow or Highlight for example)
  48904. * @returns a serialized layer object
  48905. */
  48906. abstract serialize?(): any;
  48907. /**
  48908. * Initializes the effect layer with the required options.
  48909. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48910. */
  48911. protected _init(options: Partial<IEffectLayerOptions>): void;
  48912. /**
  48913. * Generates the index buffer of the full screen quad blending to the main canvas.
  48914. */
  48915. private _generateIndexBuffer;
  48916. /**
  48917. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48918. */
  48919. private _generateVertexBuffer;
  48920. /**
  48921. * Sets the main texture desired size which is the closest power of two
  48922. * of the engine canvas size.
  48923. */
  48924. private _setMainTextureSize;
  48925. /**
  48926. * Creates the main texture for the effect layer.
  48927. */
  48928. protected _createMainTexture(): void;
  48929. /**
  48930. * Adds specific effects defines.
  48931. * @param defines The defines to add specifics to.
  48932. */
  48933. protected _addCustomEffectDefines(defines: string[]): void;
  48934. /**
  48935. * Checks for the readiness of the element composing the layer.
  48936. * @param subMesh the mesh to check for
  48937. * @param useInstances specify wether or not to use instances to render the mesh
  48938. * @param emissiveTexture the associated emissive texture used to generate the glow
  48939. * @return true if ready otherwise, false
  48940. */
  48941. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48942. /**
  48943. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48944. */
  48945. render(): void;
  48946. /**
  48947. * Determine if a given mesh will be used in the current effect.
  48948. * @param mesh mesh to test
  48949. * @returns true if the mesh will be used
  48950. */
  48951. hasMesh(mesh: AbstractMesh): boolean;
  48952. /**
  48953. * Returns true if the layer contains information to display, otherwise false.
  48954. * @returns true if the glow layer should be rendered
  48955. */
  48956. shouldRender(): boolean;
  48957. /**
  48958. * Returns true if the mesh should render, otherwise false.
  48959. * @param mesh The mesh to render
  48960. * @returns true if it should render otherwise false
  48961. */
  48962. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48963. /**
  48964. * Returns true if the mesh can be rendered, otherwise false.
  48965. * @param mesh The mesh to render
  48966. * @param material The material used on the mesh
  48967. * @returns true if it can be rendered otherwise false
  48968. */
  48969. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48970. /**
  48971. * Returns true if the mesh should render, otherwise false.
  48972. * @param mesh The mesh to render
  48973. * @returns true if it should render otherwise false
  48974. */
  48975. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48976. /**
  48977. * Renders the submesh passed in parameter to the generation map.
  48978. */
  48979. protected _renderSubMesh(subMesh: SubMesh): void;
  48980. /**
  48981. * Rebuild the required buffers.
  48982. * @hidden Internal use only.
  48983. */
  48984. _rebuild(): void;
  48985. /**
  48986. * Dispose only the render target textures and post process.
  48987. */
  48988. private _disposeTextureAndPostProcesses;
  48989. /**
  48990. * Dispose the highlight layer and free resources.
  48991. */
  48992. dispose(): void;
  48993. /**
  48994. * Gets the class name of the effect layer
  48995. * @returns the string with the class name of the effect layer
  48996. */
  48997. getClassName(): string;
  48998. /**
  48999. * Creates an effect layer from parsed effect layer data
  49000. * @param parsedEffectLayer defines effect layer data
  49001. * @param scene defines the current scene
  49002. * @param rootUrl defines the root URL containing the effect layer information
  49003. * @returns a parsed effect Layer
  49004. */
  49005. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49006. }
  49007. }
  49008. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49009. import { Scene } from "babylonjs/scene";
  49010. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49011. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49012. import { AbstractScene } from "babylonjs/abstractScene";
  49013. module "babylonjs/abstractScene" {
  49014. interface AbstractScene {
  49015. /**
  49016. * The list of effect layers (highlights/glow) added to the scene
  49017. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49018. * @see http://doc.babylonjs.com/how_to/glow_layer
  49019. */
  49020. effectLayers: Array<EffectLayer>;
  49021. /**
  49022. * Removes the given effect layer from this scene.
  49023. * @param toRemove defines the effect layer to remove
  49024. * @returns the index of the removed effect layer
  49025. */
  49026. removeEffectLayer(toRemove: EffectLayer): number;
  49027. /**
  49028. * Adds the given effect layer to this scene
  49029. * @param newEffectLayer defines the effect layer to add
  49030. */
  49031. addEffectLayer(newEffectLayer: EffectLayer): void;
  49032. }
  49033. }
  49034. /**
  49035. * Defines the layer scene component responsible to manage any effect layers
  49036. * in a given scene.
  49037. */
  49038. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49039. /**
  49040. * The component name helpfull to identify the component in the list of scene components.
  49041. */
  49042. readonly name: string;
  49043. /**
  49044. * The scene the component belongs to.
  49045. */
  49046. scene: Scene;
  49047. private _engine;
  49048. private _renderEffects;
  49049. private _needStencil;
  49050. private _previousStencilState;
  49051. /**
  49052. * Creates a new instance of the component for the given scene
  49053. * @param scene Defines the scene to register the component in
  49054. */
  49055. constructor(scene: Scene);
  49056. /**
  49057. * Registers the component in a given scene
  49058. */
  49059. register(): void;
  49060. /**
  49061. * Rebuilds the elements related to this component in case of
  49062. * context lost for instance.
  49063. */
  49064. rebuild(): void;
  49065. /**
  49066. * Serializes the component data to the specified json object
  49067. * @param serializationObject The object to serialize to
  49068. */
  49069. serialize(serializationObject: any): void;
  49070. /**
  49071. * Adds all the element from the container to the scene
  49072. * @param container the container holding the elements
  49073. */
  49074. addFromContainer(container: AbstractScene): void;
  49075. /**
  49076. * Removes all the elements in the container from the scene
  49077. * @param container contains the elements to remove
  49078. * @param dispose if the removed element should be disposed (default: false)
  49079. */
  49080. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49081. /**
  49082. * Disposes the component and the associated ressources.
  49083. */
  49084. dispose(): void;
  49085. private _isReadyForMesh;
  49086. private _renderMainTexture;
  49087. private _setStencil;
  49088. private _setStencilBack;
  49089. private _draw;
  49090. private _drawCamera;
  49091. private _drawRenderingGroup;
  49092. }
  49093. }
  49094. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49095. /** @hidden */
  49096. export var glowMapMergePixelShader: {
  49097. name: string;
  49098. shader: string;
  49099. };
  49100. }
  49101. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49102. /** @hidden */
  49103. export var glowMapMergeVertexShader: {
  49104. name: string;
  49105. shader: string;
  49106. };
  49107. }
  49108. declare module "babylonjs/Layers/glowLayer" {
  49109. import { Nullable } from "babylonjs/types";
  49110. import { Camera } from "babylonjs/Cameras/camera";
  49111. import { Scene } from "babylonjs/scene";
  49112. import { Color4 } from "babylonjs/Maths/math";
  49113. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49115. import { Mesh } from "babylonjs/Meshes/mesh";
  49116. import { Texture } from "babylonjs/Materials/Textures/texture";
  49117. import { Effect } from "babylonjs/Materials/effect";
  49118. import { Material } from "babylonjs/Materials/material";
  49119. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49120. import "babylonjs/Shaders/glowMapMerge.fragment";
  49121. import "babylonjs/Shaders/glowMapMerge.vertex";
  49122. import "babylonjs/Layers/effectLayerSceneComponent";
  49123. module "babylonjs/abstractScene" {
  49124. interface AbstractScene {
  49125. /**
  49126. * Return a the first highlight layer of the scene with a given name.
  49127. * @param name The name of the highlight layer to look for.
  49128. * @return The highlight layer if found otherwise null.
  49129. */
  49130. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49131. }
  49132. }
  49133. /**
  49134. * Glow layer options. This helps customizing the behaviour
  49135. * of the glow layer.
  49136. */
  49137. export interface IGlowLayerOptions {
  49138. /**
  49139. * Multiplication factor apply to the canvas size to compute the render target size
  49140. * used to generated the glowing objects (the smaller the faster).
  49141. */
  49142. mainTextureRatio: number;
  49143. /**
  49144. * Enforces a fixed size texture to ensure resize independant blur.
  49145. */
  49146. mainTextureFixedSize?: number;
  49147. /**
  49148. * How big is the kernel of the blur texture.
  49149. */
  49150. blurKernelSize: number;
  49151. /**
  49152. * The camera attached to the layer.
  49153. */
  49154. camera: Nullable<Camera>;
  49155. /**
  49156. * Enable MSAA by chosing the number of samples.
  49157. */
  49158. mainTextureSamples?: number;
  49159. /**
  49160. * The rendering group to draw the layer in.
  49161. */
  49162. renderingGroupId: number;
  49163. }
  49164. /**
  49165. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49166. *
  49167. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49168. * glowy meshes to your scene.
  49169. *
  49170. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49171. */
  49172. export class GlowLayer extends EffectLayer {
  49173. /**
  49174. * Effect Name of the layer.
  49175. */
  49176. static readonly EffectName: string;
  49177. /**
  49178. * The default blur kernel size used for the glow.
  49179. */
  49180. static DefaultBlurKernelSize: number;
  49181. /**
  49182. * The default texture size ratio used for the glow.
  49183. */
  49184. static DefaultTextureRatio: number;
  49185. /**
  49186. * Sets the kernel size of the blur.
  49187. */
  49188. /**
  49189. * Gets the kernel size of the blur.
  49190. */
  49191. blurKernelSize: number;
  49192. /**
  49193. * Sets the glow intensity.
  49194. */
  49195. /**
  49196. * Gets the glow intensity.
  49197. */
  49198. intensity: number;
  49199. private _options;
  49200. private _intensity;
  49201. private _horizontalBlurPostprocess1;
  49202. private _verticalBlurPostprocess1;
  49203. private _horizontalBlurPostprocess2;
  49204. private _verticalBlurPostprocess2;
  49205. private _blurTexture1;
  49206. private _blurTexture2;
  49207. private _postProcesses1;
  49208. private _postProcesses2;
  49209. private _includedOnlyMeshes;
  49210. private _excludedMeshes;
  49211. /**
  49212. * Callback used to let the user override the color selection on a per mesh basis
  49213. */
  49214. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49215. /**
  49216. * Callback used to let the user override the texture selection on a per mesh basis
  49217. */
  49218. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49219. /**
  49220. * Instantiates a new glow Layer and references it to the scene.
  49221. * @param name The name of the layer
  49222. * @param scene The scene to use the layer in
  49223. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49224. */
  49225. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49226. /**
  49227. * Get the effect name of the layer.
  49228. * @return The effect name
  49229. */
  49230. getEffectName(): string;
  49231. /**
  49232. * Create the merge effect. This is the shader use to blit the information back
  49233. * to the main canvas at the end of the scene rendering.
  49234. */
  49235. protected _createMergeEffect(): Effect;
  49236. /**
  49237. * Creates the render target textures and post processes used in the glow layer.
  49238. */
  49239. protected _createTextureAndPostProcesses(): void;
  49240. /**
  49241. * Checks for the readiness of the element composing the layer.
  49242. * @param subMesh the mesh to check for
  49243. * @param useInstances specify wether or not to use instances to render the mesh
  49244. * @param emissiveTexture the associated emissive texture used to generate the glow
  49245. * @return true if ready otherwise, false
  49246. */
  49247. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49248. /**
  49249. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49250. */
  49251. needStencil(): boolean;
  49252. /**
  49253. * Returns true if the mesh can be rendered, otherwise false.
  49254. * @param mesh The mesh to render
  49255. * @param material The material used on the mesh
  49256. * @returns true if it can be rendered otherwise false
  49257. */
  49258. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49259. /**
  49260. * Implementation specific of rendering the generating effect on the main canvas.
  49261. * @param effect The effect used to render through
  49262. */
  49263. protected _internalRender(effect: Effect): void;
  49264. /**
  49265. * Sets the required values for both the emissive texture and and the main color.
  49266. */
  49267. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49268. /**
  49269. * Returns true if the mesh should render, otherwise false.
  49270. * @param mesh The mesh to render
  49271. * @returns true if it should render otherwise false
  49272. */
  49273. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49274. /**
  49275. * Adds specific effects defines.
  49276. * @param defines The defines to add specifics to.
  49277. */
  49278. protected _addCustomEffectDefines(defines: string[]): void;
  49279. /**
  49280. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49281. * @param mesh The mesh to exclude from the glow layer
  49282. */
  49283. addExcludedMesh(mesh: Mesh): void;
  49284. /**
  49285. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49286. * @param mesh The mesh to remove
  49287. */
  49288. removeExcludedMesh(mesh: Mesh): void;
  49289. /**
  49290. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49291. * @param mesh The mesh to include in the glow layer
  49292. */
  49293. addIncludedOnlyMesh(mesh: Mesh): void;
  49294. /**
  49295. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49296. * @param mesh The mesh to remove
  49297. */
  49298. removeIncludedOnlyMesh(mesh: Mesh): void;
  49299. /**
  49300. * Determine if a given mesh will be used in the glow layer
  49301. * @param mesh The mesh to test
  49302. * @returns true if the mesh will be highlighted by the current glow layer
  49303. */
  49304. hasMesh(mesh: AbstractMesh): boolean;
  49305. /**
  49306. * Free any resources and references associated to a mesh.
  49307. * Internal use
  49308. * @param mesh The mesh to free.
  49309. * @hidden
  49310. */
  49311. _disposeMesh(mesh: Mesh): void;
  49312. /**
  49313. * Gets the class name of the effect layer
  49314. * @returns the string with the class name of the effect layer
  49315. */
  49316. getClassName(): string;
  49317. /**
  49318. * Serializes this glow layer
  49319. * @returns a serialized glow layer object
  49320. */
  49321. serialize(): any;
  49322. /**
  49323. * Creates a Glow Layer from parsed glow layer data
  49324. * @param parsedGlowLayer defines glow layer data
  49325. * @param scene defines the current scene
  49326. * @param rootUrl defines the root URL containing the glow layer information
  49327. * @returns a parsed Glow Layer
  49328. */
  49329. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49330. }
  49331. }
  49332. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49333. /** @hidden */
  49334. export var glowBlurPostProcessPixelShader: {
  49335. name: string;
  49336. shader: string;
  49337. };
  49338. }
  49339. declare module "babylonjs/Layers/highlightLayer" {
  49340. import { Observable } from "babylonjs/Misc/observable";
  49341. import { Nullable } from "babylonjs/types";
  49342. import { Camera } from "babylonjs/Cameras/camera";
  49343. import { Scene } from "babylonjs/scene";
  49344. import { Color3, Color4 } from "babylonjs/Maths/math";
  49345. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49347. import { Mesh } from "babylonjs/Meshes/mesh";
  49348. import { Effect } from "babylonjs/Materials/effect";
  49349. import { Material } from "babylonjs/Materials/material";
  49350. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49351. import "babylonjs/Shaders/glowMapMerge.fragment";
  49352. import "babylonjs/Shaders/glowMapMerge.vertex";
  49353. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49354. module "babylonjs/abstractScene" {
  49355. interface AbstractScene {
  49356. /**
  49357. * Return a the first highlight layer of the scene with a given name.
  49358. * @param name The name of the highlight layer to look for.
  49359. * @return The highlight layer if found otherwise null.
  49360. */
  49361. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49362. }
  49363. }
  49364. /**
  49365. * Highlight layer options. This helps customizing the behaviour
  49366. * of the highlight layer.
  49367. */
  49368. export interface IHighlightLayerOptions {
  49369. /**
  49370. * Multiplication factor apply to the canvas size to compute the render target size
  49371. * used to generated the glowing objects (the smaller the faster).
  49372. */
  49373. mainTextureRatio: number;
  49374. /**
  49375. * Enforces a fixed size texture to ensure resize independant blur.
  49376. */
  49377. mainTextureFixedSize?: number;
  49378. /**
  49379. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49380. * of the picture to blur (the smaller the faster).
  49381. */
  49382. blurTextureSizeRatio: number;
  49383. /**
  49384. * How big in texel of the blur texture is the vertical blur.
  49385. */
  49386. blurVerticalSize: number;
  49387. /**
  49388. * How big in texel of the blur texture is the horizontal blur.
  49389. */
  49390. blurHorizontalSize: number;
  49391. /**
  49392. * Alpha blending mode used to apply the blur. Default is combine.
  49393. */
  49394. alphaBlendingMode: number;
  49395. /**
  49396. * The camera attached to the layer.
  49397. */
  49398. camera: Nullable<Camera>;
  49399. /**
  49400. * Should we display highlight as a solid stroke?
  49401. */
  49402. isStroke?: boolean;
  49403. /**
  49404. * The rendering group to draw the layer in.
  49405. */
  49406. renderingGroupId: number;
  49407. }
  49408. /**
  49409. * The highlight layer Helps adding a glow effect around a mesh.
  49410. *
  49411. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49412. * glowy meshes to your scene.
  49413. *
  49414. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49415. */
  49416. export class HighlightLayer extends EffectLayer {
  49417. name: string;
  49418. /**
  49419. * Effect Name of the highlight layer.
  49420. */
  49421. static readonly EffectName: string;
  49422. /**
  49423. * The neutral color used during the preparation of the glow effect.
  49424. * This is black by default as the blend operation is a blend operation.
  49425. */
  49426. static NeutralColor: Color4;
  49427. /**
  49428. * Stencil value used for glowing meshes.
  49429. */
  49430. static GlowingMeshStencilReference: number;
  49431. /**
  49432. * Stencil value used for the other meshes in the scene.
  49433. */
  49434. static NormalMeshStencilReference: number;
  49435. /**
  49436. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49437. */
  49438. innerGlow: boolean;
  49439. /**
  49440. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49441. */
  49442. outerGlow: boolean;
  49443. /**
  49444. * Specifies the horizontal size of the blur.
  49445. */
  49446. /**
  49447. * Gets the horizontal size of the blur.
  49448. */
  49449. blurHorizontalSize: number;
  49450. /**
  49451. * Specifies the vertical size of the blur.
  49452. */
  49453. /**
  49454. * Gets the vertical size of the blur.
  49455. */
  49456. blurVerticalSize: number;
  49457. /**
  49458. * An event triggered when the highlight layer is being blurred.
  49459. */
  49460. onBeforeBlurObservable: Observable<HighlightLayer>;
  49461. /**
  49462. * An event triggered when the highlight layer has been blurred.
  49463. */
  49464. onAfterBlurObservable: Observable<HighlightLayer>;
  49465. private _instanceGlowingMeshStencilReference;
  49466. private _options;
  49467. private _downSamplePostprocess;
  49468. private _horizontalBlurPostprocess;
  49469. private _verticalBlurPostprocess;
  49470. private _blurTexture;
  49471. private _meshes;
  49472. private _excludedMeshes;
  49473. /**
  49474. * Instantiates a new highlight Layer and references it to the scene..
  49475. * @param name The name of the layer
  49476. * @param scene The scene to use the layer in
  49477. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49478. */
  49479. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49480. /**
  49481. * Get the effect name of the layer.
  49482. * @return The effect name
  49483. */
  49484. getEffectName(): string;
  49485. /**
  49486. * Create the merge effect. This is the shader use to blit the information back
  49487. * to the main canvas at the end of the scene rendering.
  49488. */
  49489. protected _createMergeEffect(): Effect;
  49490. /**
  49491. * Creates the render target textures and post processes used in the highlight layer.
  49492. */
  49493. protected _createTextureAndPostProcesses(): void;
  49494. /**
  49495. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49496. */
  49497. needStencil(): boolean;
  49498. /**
  49499. * Checks for the readiness of the element composing the layer.
  49500. * @param subMesh the mesh to check for
  49501. * @param useInstances specify wether or not to use instances to render the mesh
  49502. * @param emissiveTexture the associated emissive texture used to generate the glow
  49503. * @return true if ready otherwise, false
  49504. */
  49505. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49506. /**
  49507. * Implementation specific of rendering the generating effect on the main canvas.
  49508. * @param effect The effect used to render through
  49509. */
  49510. protected _internalRender(effect: Effect): void;
  49511. /**
  49512. * Returns true if the layer contains information to display, otherwise false.
  49513. */
  49514. shouldRender(): boolean;
  49515. /**
  49516. * Returns true if the mesh should render, otherwise false.
  49517. * @param mesh The mesh to render
  49518. * @returns true if it should render otherwise false
  49519. */
  49520. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49521. /**
  49522. * Sets the required values for both the emissive texture and and the main color.
  49523. */
  49524. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49525. /**
  49526. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49527. * @param mesh The mesh to exclude from the highlight layer
  49528. */
  49529. addExcludedMesh(mesh: Mesh): void;
  49530. /**
  49531. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49532. * @param mesh The mesh to highlight
  49533. */
  49534. removeExcludedMesh(mesh: Mesh): void;
  49535. /**
  49536. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49537. * @param mesh mesh to test
  49538. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49539. */
  49540. hasMesh(mesh: AbstractMesh): boolean;
  49541. /**
  49542. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49543. * @param mesh The mesh to highlight
  49544. * @param color The color of the highlight
  49545. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49546. */
  49547. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49548. /**
  49549. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49550. * @param mesh The mesh to highlight
  49551. */
  49552. removeMesh(mesh: Mesh): void;
  49553. /**
  49554. * Force the stencil to the normal expected value for none glowing parts
  49555. */
  49556. private _defaultStencilReference;
  49557. /**
  49558. * Free any resources and references associated to a mesh.
  49559. * Internal use
  49560. * @param mesh The mesh to free.
  49561. * @hidden
  49562. */
  49563. _disposeMesh(mesh: Mesh): void;
  49564. /**
  49565. * Dispose the highlight layer and free resources.
  49566. */
  49567. dispose(): void;
  49568. /**
  49569. * Gets the class name of the effect layer
  49570. * @returns the string with the class name of the effect layer
  49571. */
  49572. getClassName(): string;
  49573. /**
  49574. * Serializes this Highlight layer
  49575. * @returns a serialized Highlight layer object
  49576. */
  49577. serialize(): any;
  49578. /**
  49579. * Creates a Highlight layer from parsed Highlight layer data
  49580. * @param parsedHightlightLayer defines the Highlight layer data
  49581. * @param scene defines the current scene
  49582. * @param rootUrl defines the root URL containing the Highlight layer information
  49583. * @returns a parsed Highlight layer
  49584. */
  49585. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49586. }
  49587. }
  49588. declare module "babylonjs/Layers/index" {
  49589. export * from "babylonjs/Layers/effectLayer";
  49590. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49591. export * from "babylonjs/Layers/glowLayer";
  49592. export * from "babylonjs/Layers/highlightLayer";
  49593. export * from "babylonjs/Layers/layer";
  49594. export * from "babylonjs/Layers/layerSceneComponent";
  49595. }
  49596. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49597. /** @hidden */
  49598. export var lensFlarePixelShader: {
  49599. name: string;
  49600. shader: string;
  49601. };
  49602. }
  49603. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49604. /** @hidden */
  49605. export var lensFlareVertexShader: {
  49606. name: string;
  49607. shader: string;
  49608. };
  49609. }
  49610. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49611. import { Scene } from "babylonjs/scene";
  49612. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49614. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49615. import "babylonjs/Shaders/lensFlare.fragment";
  49616. import "babylonjs/Shaders/lensFlare.vertex";
  49617. /**
  49618. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49619. * It is usually composed of several `lensFlare`.
  49620. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49621. */
  49622. export class LensFlareSystem {
  49623. /**
  49624. * Define the name of the lens flare system
  49625. */
  49626. name: string;
  49627. /**
  49628. * List of lens flares used in this system.
  49629. */
  49630. lensFlares: LensFlare[];
  49631. /**
  49632. * Define a limit from the border the lens flare can be visible.
  49633. */
  49634. borderLimit: number;
  49635. /**
  49636. * Define a viewport border we do not want to see the lens flare in.
  49637. */
  49638. viewportBorder: number;
  49639. /**
  49640. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49641. */
  49642. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49643. /**
  49644. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49645. */
  49646. layerMask: number;
  49647. /**
  49648. * Define the id of the lens flare system in the scene.
  49649. * (equal to name by default)
  49650. */
  49651. id: string;
  49652. private _scene;
  49653. private _emitter;
  49654. private _vertexBuffers;
  49655. private _indexBuffer;
  49656. private _effect;
  49657. private _positionX;
  49658. private _positionY;
  49659. private _isEnabled;
  49660. /** @hidden */
  49661. static _SceneComponentInitialization: (scene: Scene) => void;
  49662. /**
  49663. * Instantiates a lens flare system.
  49664. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49665. * It is usually composed of several `lensFlare`.
  49666. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49667. * @param name Define the name of the lens flare system in the scene
  49668. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49669. * @param scene Define the scene the lens flare system belongs to
  49670. */
  49671. constructor(
  49672. /**
  49673. * Define the name of the lens flare system
  49674. */
  49675. name: string, emitter: any, scene: Scene);
  49676. /**
  49677. * Define if the lens flare system is enabled.
  49678. */
  49679. isEnabled: boolean;
  49680. /**
  49681. * Get the scene the effects belongs to.
  49682. * @returns the scene holding the lens flare system
  49683. */
  49684. getScene(): Scene;
  49685. /**
  49686. * Get the emitter of the lens flare system.
  49687. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49688. * @returns the emitter of the lens flare system
  49689. */
  49690. getEmitter(): any;
  49691. /**
  49692. * Set the emitter of the lens flare system.
  49693. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49694. * @param newEmitter Define the new emitter of the system
  49695. */
  49696. setEmitter(newEmitter: any): void;
  49697. /**
  49698. * Get the lens flare system emitter position.
  49699. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49700. * @returns the position
  49701. */
  49702. getEmitterPosition(): Vector3;
  49703. /**
  49704. * @hidden
  49705. */
  49706. computeEffectivePosition(globalViewport: Viewport): boolean;
  49707. /** @hidden */
  49708. _isVisible(): boolean;
  49709. /**
  49710. * @hidden
  49711. */
  49712. render(): boolean;
  49713. /**
  49714. * Dispose and release the lens flare with its associated resources.
  49715. */
  49716. dispose(): void;
  49717. /**
  49718. * Parse a lens flare system from a JSON repressentation
  49719. * @param parsedLensFlareSystem Define the JSON to parse
  49720. * @param scene Define the scene the parsed system should be instantiated in
  49721. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49722. * @returns the parsed system
  49723. */
  49724. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49725. /**
  49726. * Serialize the current Lens Flare System into a JSON representation.
  49727. * @returns the serialized JSON
  49728. */
  49729. serialize(): any;
  49730. }
  49731. }
  49732. declare module "babylonjs/LensFlares/lensFlare" {
  49733. import { Nullable } from "babylonjs/types";
  49734. import { Color3 } from "babylonjs/Maths/math";
  49735. import { Texture } from "babylonjs/Materials/Textures/texture";
  49736. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49737. /**
  49738. * This represents one of the lens effect in a `lensFlareSystem`.
  49739. * It controls one of the indiviual texture used in the effect.
  49740. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49741. */
  49742. export class LensFlare {
  49743. /**
  49744. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49745. */
  49746. size: number;
  49747. /**
  49748. * 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.
  49749. */
  49750. position: number;
  49751. /**
  49752. * Define the lens color.
  49753. */
  49754. color: Color3;
  49755. /**
  49756. * Define the lens texture.
  49757. */
  49758. texture: Nullable<Texture>;
  49759. /**
  49760. * Define the alpha mode to render this particular lens.
  49761. */
  49762. alphaMode: number;
  49763. private _system;
  49764. /**
  49765. * Creates a new Lens Flare.
  49766. * This represents one of the lens effect in a `lensFlareSystem`.
  49767. * It controls one of the indiviual texture used in the effect.
  49768. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49769. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49770. * @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.
  49771. * @param color Define the lens color
  49772. * @param imgUrl Define the lens texture url
  49773. * @param system Define the `lensFlareSystem` this flare is part of
  49774. * @returns The newly created Lens Flare
  49775. */
  49776. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49777. /**
  49778. * Instantiates a new Lens Flare.
  49779. * This represents one of the lens effect in a `lensFlareSystem`.
  49780. * It controls one of the indiviual texture used in the effect.
  49781. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49782. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49783. * @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.
  49784. * @param color Define the lens color
  49785. * @param imgUrl Define the lens texture url
  49786. * @param system Define the `lensFlareSystem` this flare is part of
  49787. */
  49788. constructor(
  49789. /**
  49790. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49791. */
  49792. size: number,
  49793. /**
  49794. * 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.
  49795. */
  49796. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49797. /**
  49798. * Dispose and release the lens flare with its associated resources.
  49799. */
  49800. dispose(): void;
  49801. }
  49802. }
  49803. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49804. import { Nullable } from "babylonjs/types";
  49805. import { Scene } from "babylonjs/scene";
  49806. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49807. import { AbstractScene } from "babylonjs/abstractScene";
  49808. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49809. module "babylonjs/abstractScene" {
  49810. interface AbstractScene {
  49811. /**
  49812. * The list of lens flare system added to the scene
  49813. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49814. */
  49815. lensFlareSystems: Array<LensFlareSystem>;
  49816. /**
  49817. * Removes the given lens flare system from this scene.
  49818. * @param toRemove The lens flare system to remove
  49819. * @returns The index of the removed lens flare system
  49820. */
  49821. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49822. /**
  49823. * Adds the given lens flare system to this scene
  49824. * @param newLensFlareSystem The lens flare system to add
  49825. */
  49826. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49827. /**
  49828. * Gets a lens flare system using its name
  49829. * @param name defines the name to look for
  49830. * @returns the lens flare system or null if not found
  49831. */
  49832. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49833. /**
  49834. * Gets a lens flare system using its id
  49835. * @param id defines the id to look for
  49836. * @returns the lens flare system or null if not found
  49837. */
  49838. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49839. }
  49840. }
  49841. /**
  49842. * Defines the lens flare scene component responsible to manage any lens flares
  49843. * in a given scene.
  49844. */
  49845. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49846. /**
  49847. * The component name helpfull to identify the component in the list of scene components.
  49848. */
  49849. readonly name: string;
  49850. /**
  49851. * The scene the component belongs to.
  49852. */
  49853. scene: Scene;
  49854. /**
  49855. * Creates a new instance of the component for the given scene
  49856. * @param scene Defines the scene to register the component in
  49857. */
  49858. constructor(scene: Scene);
  49859. /**
  49860. * Registers the component in a given scene
  49861. */
  49862. register(): void;
  49863. /**
  49864. * Rebuilds the elements related to this component in case of
  49865. * context lost for instance.
  49866. */
  49867. rebuild(): void;
  49868. /**
  49869. * Adds all the element from the container to the scene
  49870. * @param container the container holding the elements
  49871. */
  49872. addFromContainer(container: AbstractScene): void;
  49873. /**
  49874. * Removes all the elements in the container from the scene
  49875. * @param container contains the elements to remove
  49876. * @param dispose if the removed element should be disposed (default: false)
  49877. */
  49878. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49879. /**
  49880. * Serializes the component data to the specified json object
  49881. * @param serializationObject The object to serialize to
  49882. */
  49883. serialize(serializationObject: any): void;
  49884. /**
  49885. * Disposes the component and the associated ressources.
  49886. */
  49887. dispose(): void;
  49888. private _draw;
  49889. }
  49890. }
  49891. declare module "babylonjs/LensFlares/index" {
  49892. export * from "babylonjs/LensFlares/lensFlare";
  49893. export * from "babylonjs/LensFlares/lensFlareSystem";
  49894. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49895. }
  49896. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49897. import { Scene } from "babylonjs/scene";
  49898. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49899. import { AbstractScene } from "babylonjs/abstractScene";
  49900. /**
  49901. * Defines the shadow generator component responsible to manage any shadow generators
  49902. * in a given scene.
  49903. */
  49904. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49905. /**
  49906. * The component name helpfull to identify the component in the list of scene components.
  49907. */
  49908. readonly name: string;
  49909. /**
  49910. * The scene the component belongs to.
  49911. */
  49912. scene: Scene;
  49913. /**
  49914. * Creates a new instance of the component for the given scene
  49915. * @param scene Defines the scene to register the component in
  49916. */
  49917. constructor(scene: Scene);
  49918. /**
  49919. * Registers the component in a given scene
  49920. */
  49921. register(): void;
  49922. /**
  49923. * Rebuilds the elements related to this component in case of
  49924. * context lost for instance.
  49925. */
  49926. rebuild(): void;
  49927. /**
  49928. * Serializes the component data to the specified json object
  49929. * @param serializationObject The object to serialize to
  49930. */
  49931. serialize(serializationObject: any): void;
  49932. /**
  49933. * Adds all the element from the container to the scene
  49934. * @param container the container holding the elements
  49935. */
  49936. addFromContainer(container: AbstractScene): void;
  49937. /**
  49938. * Removes all the elements in the container from the scene
  49939. * @param container contains the elements to remove
  49940. * @param dispose if the removed element should be disposed (default: false)
  49941. */
  49942. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49943. /**
  49944. * Rebuilds the elements related to this component in case of
  49945. * context lost for instance.
  49946. */
  49947. dispose(): void;
  49948. private _gatherRenderTargets;
  49949. }
  49950. }
  49951. declare module "babylonjs/Lights/Shadows/index" {
  49952. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49953. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49954. }
  49955. declare module "babylonjs/Lights/pointLight" {
  49956. import { Scene } from "babylonjs/scene";
  49957. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49959. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49960. import { Effect } from "babylonjs/Materials/effect";
  49961. /**
  49962. * A point light is a light defined by an unique point in world space.
  49963. * The light is emitted in every direction from this point.
  49964. * A good example of a point light is a standard light bulb.
  49965. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49966. */
  49967. export class PointLight extends ShadowLight {
  49968. private _shadowAngle;
  49969. /**
  49970. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49971. * This specifies what angle the shadow will use to be created.
  49972. *
  49973. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49974. */
  49975. /**
  49976. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49977. * This specifies what angle the shadow will use to be created.
  49978. *
  49979. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49980. */
  49981. shadowAngle: number;
  49982. /**
  49983. * Gets the direction if it has been set.
  49984. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49985. */
  49986. /**
  49987. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49988. */
  49989. direction: Vector3;
  49990. /**
  49991. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49992. * A PointLight emits the light in every direction.
  49993. * It can cast shadows.
  49994. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49995. * ```javascript
  49996. * var pointLight = new PointLight("pl", camera.position, scene);
  49997. * ```
  49998. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49999. * @param name The light friendly name
  50000. * @param position The position of the point light in the scene
  50001. * @param scene The scene the lights belongs to
  50002. */
  50003. constructor(name: string, position: Vector3, scene: Scene);
  50004. /**
  50005. * Returns the string "PointLight"
  50006. * @returns the class name
  50007. */
  50008. getClassName(): string;
  50009. /**
  50010. * Returns the integer 0.
  50011. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50012. */
  50013. getTypeID(): number;
  50014. /**
  50015. * Specifies wether or not the shadowmap should be a cube texture.
  50016. * @returns true if the shadowmap needs to be a cube texture.
  50017. */
  50018. needCube(): boolean;
  50019. /**
  50020. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50021. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50022. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50023. */
  50024. getShadowDirection(faceIndex?: number): Vector3;
  50025. /**
  50026. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50027. * - fov = PI / 2
  50028. * - aspect ratio : 1.0
  50029. * - z-near and far equal to the active camera minZ and maxZ.
  50030. * Returns the PointLight.
  50031. */
  50032. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50033. protected _buildUniformLayout(): void;
  50034. /**
  50035. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50036. * @param effect The effect to update
  50037. * @param lightIndex The index of the light in the effect to update
  50038. * @returns The point light
  50039. */
  50040. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50041. /**
  50042. * Prepares the list of defines specific to the light type.
  50043. * @param defines the list of defines
  50044. * @param lightIndex defines the index of the light for the effect
  50045. */
  50046. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50047. }
  50048. }
  50049. declare module "babylonjs/Lights/index" {
  50050. export * from "babylonjs/Lights/light";
  50051. export * from "babylonjs/Lights/shadowLight";
  50052. export * from "babylonjs/Lights/Shadows/index";
  50053. export * from "babylonjs/Lights/directionalLight";
  50054. export * from "babylonjs/Lights/hemisphericLight";
  50055. export * from "babylonjs/Lights/pointLight";
  50056. export * from "babylonjs/Lights/spotLight";
  50057. }
  50058. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50059. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50060. /**
  50061. * Header information of HDR texture files.
  50062. */
  50063. export interface HDRInfo {
  50064. /**
  50065. * The height of the texture in pixels.
  50066. */
  50067. height: number;
  50068. /**
  50069. * The width of the texture in pixels.
  50070. */
  50071. width: number;
  50072. /**
  50073. * The index of the beginning of the data in the binary file.
  50074. */
  50075. dataPosition: number;
  50076. }
  50077. /**
  50078. * This groups tools to convert HDR texture to native colors array.
  50079. */
  50080. export class HDRTools {
  50081. private static Ldexp;
  50082. private static Rgbe2float;
  50083. private static readStringLine;
  50084. /**
  50085. * Reads header information from an RGBE texture stored in a native array.
  50086. * More information on this format are available here:
  50087. * https://en.wikipedia.org/wiki/RGBE_image_format
  50088. *
  50089. * @param uint8array The binary file stored in native array.
  50090. * @return The header information.
  50091. */
  50092. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50093. /**
  50094. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50095. * This RGBE texture needs to store the information as a panorama.
  50096. *
  50097. * More information on this format are available here:
  50098. * https://en.wikipedia.org/wiki/RGBE_image_format
  50099. *
  50100. * @param buffer The binary file stored in an array buffer.
  50101. * @param size The expected size of the extracted cubemap.
  50102. * @return The Cube Map information.
  50103. */
  50104. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50105. /**
  50106. * Returns the pixels data extracted from an RGBE texture.
  50107. * This pixels will be stored left to right up to down in the R G B order in one array.
  50108. *
  50109. * More information on this format are available here:
  50110. * https://en.wikipedia.org/wiki/RGBE_image_format
  50111. *
  50112. * @param uint8array The binary file stored in an array buffer.
  50113. * @param hdrInfo The header information of the file.
  50114. * @return The pixels data in RGB right to left up to down order.
  50115. */
  50116. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50117. private static RGBE_ReadPixels_RLE;
  50118. }
  50119. }
  50120. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50121. import { Nullable } from "babylonjs/types";
  50122. import { Scene } from "babylonjs/scene";
  50123. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50124. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50125. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50126. /**
  50127. * This represents a texture coming from an HDR input.
  50128. *
  50129. * The only supported format is currently panorama picture stored in RGBE format.
  50130. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50131. */
  50132. export class HDRCubeTexture extends BaseTexture {
  50133. private static _facesMapping;
  50134. private _generateHarmonics;
  50135. private _noMipmap;
  50136. private _textureMatrix;
  50137. private _size;
  50138. private _onLoad;
  50139. private _onError;
  50140. /**
  50141. * The texture URL.
  50142. */
  50143. url: string;
  50144. /**
  50145. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50146. */
  50147. coordinatesMode: number;
  50148. protected _isBlocking: boolean;
  50149. /**
  50150. * Sets wether or not the texture is blocking during loading.
  50151. */
  50152. /**
  50153. * Gets wether or not the texture is blocking during loading.
  50154. */
  50155. isBlocking: boolean;
  50156. protected _rotationY: number;
  50157. /**
  50158. * Sets texture matrix rotation angle around Y axis in radians.
  50159. */
  50160. /**
  50161. * Gets texture matrix rotation angle around Y axis radians.
  50162. */
  50163. rotationY: number;
  50164. /**
  50165. * Gets or sets the center of the bounding box associated with the cube texture
  50166. * It must define where the camera used to render the texture was set
  50167. */
  50168. boundingBoxPosition: Vector3;
  50169. private _boundingBoxSize;
  50170. /**
  50171. * Gets or sets the size of the bounding box associated with the cube texture
  50172. * When defined, the cubemap will switch to local mode
  50173. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50174. * @example https://www.babylonjs-playground.com/#RNASML
  50175. */
  50176. boundingBoxSize: Vector3;
  50177. /**
  50178. * Instantiates an HDRTexture from the following parameters.
  50179. *
  50180. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50181. * @param scene The scene the texture will be used in
  50182. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50183. * @param noMipmap Forces to not generate the mipmap if true
  50184. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50185. * @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)
  50186. * @param reserved Reserved flag for internal use.
  50187. */
  50188. 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>);
  50189. /**
  50190. * Get the current class name of the texture useful for serialization or dynamic coding.
  50191. * @returns "HDRCubeTexture"
  50192. */
  50193. getClassName(): string;
  50194. /**
  50195. * Occurs when the file is raw .hdr file.
  50196. */
  50197. private loadTexture;
  50198. clone(): HDRCubeTexture;
  50199. delayLoad(): void;
  50200. /**
  50201. * Get the texture reflection matrix used to rotate/transform the reflection.
  50202. * @returns the reflection matrix
  50203. */
  50204. getReflectionTextureMatrix(): Matrix;
  50205. /**
  50206. * Set the texture reflection matrix used to rotate/transform the reflection.
  50207. * @param value Define the reflection matrix to set
  50208. */
  50209. setReflectionTextureMatrix(value: Matrix): void;
  50210. /**
  50211. * Parses a JSON representation of an HDR Texture in order to create the texture
  50212. * @param parsedTexture Define the JSON representation
  50213. * @param scene Define the scene the texture should be created in
  50214. * @param rootUrl Define the root url in case we need to load relative dependencies
  50215. * @returns the newly created texture after parsing
  50216. */
  50217. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50218. serialize(): any;
  50219. }
  50220. }
  50221. declare module "babylonjs/Physics/physicsEngine" {
  50222. import { Nullable } from "babylonjs/types";
  50223. import { Vector3 } from "babylonjs/Maths/math";
  50224. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50225. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50226. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50227. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50228. /**
  50229. * Class used to control physics engine
  50230. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50231. */
  50232. export class PhysicsEngine implements IPhysicsEngine {
  50233. private _physicsPlugin;
  50234. /**
  50235. * Global value used to control the smallest number supported by the simulation
  50236. */
  50237. static Epsilon: number;
  50238. private _impostors;
  50239. private _joints;
  50240. /**
  50241. * Gets the gravity vector used by the simulation
  50242. */
  50243. gravity: Vector3;
  50244. /**
  50245. * Factory used to create the default physics plugin.
  50246. * @returns The default physics plugin
  50247. */
  50248. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50249. /**
  50250. * Creates a new Physics Engine
  50251. * @param gravity defines the gravity vector used by the simulation
  50252. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50253. */
  50254. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50255. /**
  50256. * Sets the gravity vector used by the simulation
  50257. * @param gravity defines the gravity vector to use
  50258. */
  50259. setGravity(gravity: Vector3): void;
  50260. /**
  50261. * Set the time step of the physics engine.
  50262. * Default is 1/60.
  50263. * To slow it down, enter 1/600 for example.
  50264. * To speed it up, 1/30
  50265. * @param newTimeStep defines the new timestep to apply to this world.
  50266. */
  50267. setTimeStep(newTimeStep?: number): void;
  50268. /**
  50269. * Get the time step of the physics engine.
  50270. * @returns the current time step
  50271. */
  50272. getTimeStep(): number;
  50273. /**
  50274. * Release all resources
  50275. */
  50276. dispose(): void;
  50277. /**
  50278. * Gets the name of the current physics plugin
  50279. * @returns the name of the plugin
  50280. */
  50281. getPhysicsPluginName(): string;
  50282. /**
  50283. * Adding a new impostor for the impostor tracking.
  50284. * This will be done by the impostor itself.
  50285. * @param impostor the impostor to add
  50286. */
  50287. addImpostor(impostor: PhysicsImpostor): void;
  50288. /**
  50289. * Remove an impostor from the engine.
  50290. * This impostor and its mesh will not longer be updated by the physics engine.
  50291. * @param impostor the impostor to remove
  50292. */
  50293. removeImpostor(impostor: PhysicsImpostor): void;
  50294. /**
  50295. * Add a joint to the physics engine
  50296. * @param mainImpostor defines the main impostor to which the joint is added.
  50297. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50298. * @param joint defines the joint that will connect both impostors.
  50299. */
  50300. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50301. /**
  50302. * Removes a joint from the simulation
  50303. * @param mainImpostor defines the impostor used with the joint
  50304. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50305. * @param joint defines the joint to remove
  50306. */
  50307. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50308. /**
  50309. * Called by the scene. No need to call it.
  50310. * @param delta defines the timespam between frames
  50311. */
  50312. _step(delta: number): void;
  50313. /**
  50314. * Gets the current plugin used to run the simulation
  50315. * @returns current plugin
  50316. */
  50317. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50318. /**
  50319. * Gets the list of physic impostors
  50320. * @returns an array of PhysicsImpostor
  50321. */
  50322. getImpostors(): Array<PhysicsImpostor>;
  50323. /**
  50324. * Gets the impostor for a physics enabled object
  50325. * @param object defines the object impersonated by the impostor
  50326. * @returns the PhysicsImpostor or null if not found
  50327. */
  50328. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50329. /**
  50330. * Gets the impostor for a physics body object
  50331. * @param body defines physics body used by the impostor
  50332. * @returns the PhysicsImpostor or null if not found
  50333. */
  50334. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50335. /**
  50336. * Does a raycast in the physics world
  50337. * @param from when should the ray start?
  50338. * @param to when should the ray end?
  50339. * @returns PhysicsRaycastResult
  50340. */
  50341. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50342. }
  50343. }
  50344. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50345. import { Nullable } from "babylonjs/types";
  50346. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50348. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50349. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50350. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50351. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50352. /** @hidden */
  50353. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50354. private _useDeltaForWorldStep;
  50355. world: any;
  50356. name: string;
  50357. private _physicsMaterials;
  50358. private _fixedTimeStep;
  50359. private _cannonRaycastResult;
  50360. private _raycastResult;
  50361. private _removeAfterStep;
  50362. BJSCANNON: any;
  50363. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50364. setGravity(gravity: Vector3): void;
  50365. setTimeStep(timeStep: number): void;
  50366. getTimeStep(): number;
  50367. executeStep(delta: number): void;
  50368. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50369. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50370. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50371. private _processChildMeshes;
  50372. removePhysicsBody(impostor: PhysicsImpostor): void;
  50373. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50374. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50375. private _addMaterial;
  50376. private _checkWithEpsilon;
  50377. private _createShape;
  50378. private _createHeightmap;
  50379. private _minus90X;
  50380. private _plus90X;
  50381. private _tmpPosition;
  50382. private _tmpDeltaPosition;
  50383. private _tmpUnityRotation;
  50384. private _updatePhysicsBodyTransformation;
  50385. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50386. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50387. isSupported(): boolean;
  50388. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50389. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50390. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50391. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50392. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50393. getBodyMass(impostor: PhysicsImpostor): number;
  50394. getBodyFriction(impostor: PhysicsImpostor): number;
  50395. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50396. getBodyRestitution(impostor: PhysicsImpostor): number;
  50397. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50398. sleepBody(impostor: PhysicsImpostor): void;
  50399. wakeUpBody(impostor: PhysicsImpostor): void;
  50400. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50401. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50402. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50403. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50404. getRadius(impostor: PhysicsImpostor): number;
  50405. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50406. dispose(): void;
  50407. private _extendNamespace;
  50408. /**
  50409. * Does a raycast in the physics world
  50410. * @param from when should the ray start?
  50411. * @param to when should the ray end?
  50412. * @returns PhysicsRaycastResult
  50413. */
  50414. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50415. }
  50416. }
  50417. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50418. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50419. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50420. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50422. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50423. import { Nullable } from "babylonjs/types";
  50424. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50425. /** @hidden */
  50426. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50427. world: any;
  50428. name: string;
  50429. BJSOIMO: any;
  50430. private _raycastResult;
  50431. constructor(iterations?: number, oimoInjection?: any);
  50432. setGravity(gravity: Vector3): void;
  50433. setTimeStep(timeStep: number): void;
  50434. getTimeStep(): number;
  50435. private _tmpImpostorsArray;
  50436. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50437. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50438. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50439. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50440. private _tmpPositionVector;
  50441. removePhysicsBody(impostor: PhysicsImpostor): void;
  50442. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50443. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50444. isSupported(): boolean;
  50445. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50446. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50447. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50448. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50449. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50450. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50451. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50452. getBodyMass(impostor: PhysicsImpostor): number;
  50453. getBodyFriction(impostor: PhysicsImpostor): number;
  50454. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50455. getBodyRestitution(impostor: PhysicsImpostor): number;
  50456. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50457. sleepBody(impostor: PhysicsImpostor): void;
  50458. wakeUpBody(impostor: PhysicsImpostor): void;
  50459. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50460. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50461. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50462. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50463. getRadius(impostor: PhysicsImpostor): number;
  50464. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50465. dispose(): void;
  50466. /**
  50467. * Does a raycast in the physics world
  50468. * @param from when should the ray start?
  50469. * @param to when should the ray end?
  50470. * @returns PhysicsRaycastResult
  50471. */
  50472. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50473. }
  50474. }
  50475. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50476. import { Nullable } from "babylonjs/types";
  50477. import { Scene } from "babylonjs/scene";
  50478. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50479. import { Mesh } from "babylonjs/Meshes/mesh";
  50480. /**
  50481. * Class containing static functions to help procedurally build meshes
  50482. */
  50483. export class RibbonBuilder {
  50484. /**
  50485. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50486. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50487. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50488. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50489. * * 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
  50490. * * 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
  50491. * * 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
  50492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50494. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50495. * * 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
  50496. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50497. * * 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
  50498. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50500. * @param name defines the name of the mesh
  50501. * @param options defines the options used to create the mesh
  50502. * @param scene defines the hosting scene
  50503. * @returns the ribbon mesh
  50504. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50505. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50506. */
  50507. static CreateRibbon(name: string, options: {
  50508. pathArray: Vector3[][];
  50509. closeArray?: boolean;
  50510. closePath?: boolean;
  50511. offset?: number;
  50512. updatable?: boolean;
  50513. sideOrientation?: number;
  50514. frontUVs?: Vector4;
  50515. backUVs?: Vector4;
  50516. instance?: Mesh;
  50517. invertUV?: boolean;
  50518. uvs?: Vector2[];
  50519. colors?: Color4[];
  50520. }, scene?: Nullable<Scene>): Mesh;
  50521. }
  50522. }
  50523. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50524. import { Nullable } from "babylonjs/types";
  50525. import { Scene } from "babylonjs/scene";
  50526. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50527. import { Mesh } from "babylonjs/Meshes/mesh";
  50528. /**
  50529. * Class containing static functions to help procedurally build meshes
  50530. */
  50531. export class ShapeBuilder {
  50532. /**
  50533. * 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.
  50534. * * 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.
  50535. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50536. * * 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.
  50537. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50538. * * 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
  50539. * * 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
  50540. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50543. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50545. * @param name defines the name of the mesh
  50546. * @param options defines the options used to create the mesh
  50547. * @param scene defines the hosting scene
  50548. * @returns the extruded shape mesh
  50549. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50550. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50551. */
  50552. static ExtrudeShape(name: string, options: {
  50553. shape: Vector3[];
  50554. path: Vector3[];
  50555. scale?: number;
  50556. rotation?: number;
  50557. cap?: number;
  50558. updatable?: boolean;
  50559. sideOrientation?: number;
  50560. frontUVs?: Vector4;
  50561. backUVs?: Vector4;
  50562. instance?: Mesh;
  50563. invertUV?: boolean;
  50564. }, scene?: Nullable<Scene>): Mesh;
  50565. /**
  50566. * Creates an custom extruded shape mesh.
  50567. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50568. * * 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.
  50569. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50570. * * 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
  50571. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50572. * * 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
  50573. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50574. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50575. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50576. * * 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
  50577. * * 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
  50578. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50581. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50583. * @param name defines the name of the mesh
  50584. * @param options defines the options used to create the mesh
  50585. * @param scene defines the hosting scene
  50586. * @returns the custom extruded shape mesh
  50587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50588. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50590. */
  50591. static ExtrudeShapeCustom(name: string, options: {
  50592. shape: Vector3[];
  50593. path: Vector3[];
  50594. scaleFunction?: any;
  50595. rotationFunction?: any;
  50596. ribbonCloseArray?: boolean;
  50597. ribbonClosePath?: boolean;
  50598. cap?: number;
  50599. updatable?: boolean;
  50600. sideOrientation?: number;
  50601. frontUVs?: Vector4;
  50602. backUVs?: Vector4;
  50603. instance?: Mesh;
  50604. invertUV?: boolean;
  50605. }, scene?: Nullable<Scene>): Mesh;
  50606. private static _ExtrudeShapeGeneric;
  50607. }
  50608. }
  50609. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50610. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50611. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50612. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50613. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50614. import { Nullable } from "babylonjs/types";
  50615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50616. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50617. /**
  50618. * AmmoJS Physics plugin
  50619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50620. * @see https://github.com/kripken/ammo.js/
  50621. */
  50622. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50623. private _useDeltaForWorldStep;
  50624. /**
  50625. * Reference to the Ammo library
  50626. */
  50627. bjsAMMO: any;
  50628. /**
  50629. * Created ammoJS world which physics bodies are added to
  50630. */
  50631. world: any;
  50632. /**
  50633. * Name of the plugin
  50634. */
  50635. name: string;
  50636. private _timeStep;
  50637. private _fixedTimeStep;
  50638. private _maxSteps;
  50639. private _tmpQuaternion;
  50640. private _tmpAmmoTransform;
  50641. private _tmpAmmoQuaternion;
  50642. private _tmpAmmoConcreteContactResultCallback;
  50643. private _collisionConfiguration;
  50644. private _dispatcher;
  50645. private _overlappingPairCache;
  50646. private _solver;
  50647. private _softBodySolver;
  50648. private _tmpAmmoVectorA;
  50649. private _tmpAmmoVectorB;
  50650. private _tmpAmmoVectorC;
  50651. private _tmpAmmoVectorD;
  50652. private _tmpContactCallbackResult;
  50653. private _tmpAmmoVectorRCA;
  50654. private _tmpAmmoVectorRCB;
  50655. private _raycastResult;
  50656. private static readonly DISABLE_COLLISION_FLAG;
  50657. private static readonly KINEMATIC_FLAG;
  50658. private static readonly DISABLE_DEACTIVATION_FLAG;
  50659. /**
  50660. * Initializes the ammoJS plugin
  50661. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50662. * @param ammoInjection can be used to inject your own ammo reference
  50663. */
  50664. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50665. /**
  50666. * Sets the gravity of the physics world (m/(s^2))
  50667. * @param gravity Gravity to set
  50668. */
  50669. setGravity(gravity: Vector3): void;
  50670. /**
  50671. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50672. * @param timeStep timestep to use in seconds
  50673. */
  50674. setTimeStep(timeStep: number): void;
  50675. /**
  50676. * 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)
  50677. * @param fixedTimeStep fixedTimeStep to use in seconds
  50678. */
  50679. setFixedTimeStep(fixedTimeStep: number): void;
  50680. /**
  50681. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50682. * @param maxSteps the maximum number of steps by the physics engine per frame
  50683. */
  50684. setMaxSteps(maxSteps: number): void;
  50685. /**
  50686. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50687. * @returns the current timestep in seconds
  50688. */
  50689. getTimeStep(): number;
  50690. private _isImpostorInContact;
  50691. private _isImpostorPairInContact;
  50692. private _stepSimulation;
  50693. /**
  50694. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50695. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50696. * After the step the babylon meshes are set to the position of the physics imposters
  50697. * @param delta amount of time to step forward
  50698. * @param impostors array of imposters to update before/after the step
  50699. */
  50700. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50701. /**
  50702. * Update babylon mesh to match physics world object
  50703. * @param impostor imposter to match
  50704. */
  50705. private _afterSoftStep;
  50706. /**
  50707. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50708. * @param impostor imposter to match
  50709. */
  50710. private _ropeStep;
  50711. /**
  50712. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50713. * @param impostor imposter to match
  50714. */
  50715. private _softbodyOrClothStep;
  50716. private _tmpVector;
  50717. private _tmpMatrix;
  50718. /**
  50719. * Applies an impulse on the imposter
  50720. * @param impostor imposter to apply impulse to
  50721. * @param force amount of force to be applied to the imposter
  50722. * @param contactPoint the location to apply the impulse on the imposter
  50723. */
  50724. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50725. /**
  50726. * Applies a force on the imposter
  50727. * @param impostor imposter to apply force
  50728. * @param force amount of force to be applied to the imposter
  50729. * @param contactPoint the location to apply the force on the imposter
  50730. */
  50731. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50732. /**
  50733. * Creates a physics body using the plugin
  50734. * @param impostor the imposter to create the physics body on
  50735. */
  50736. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50737. /**
  50738. * Removes the physics body from the imposter and disposes of the body's memory
  50739. * @param impostor imposter to remove the physics body from
  50740. */
  50741. removePhysicsBody(impostor: PhysicsImpostor): void;
  50742. /**
  50743. * Generates a joint
  50744. * @param impostorJoint the imposter joint to create the joint with
  50745. */
  50746. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50747. /**
  50748. * Removes a joint
  50749. * @param impostorJoint the imposter joint to remove the joint from
  50750. */
  50751. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50752. private _addMeshVerts;
  50753. /**
  50754. * Initialise the soft body vertices to match its object's (mesh) vertices
  50755. * Softbody vertices (nodes) are in world space and to match this
  50756. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50757. * @param impostor to create the softbody for
  50758. */
  50759. private _softVertexData;
  50760. /**
  50761. * Create an impostor's soft body
  50762. * @param impostor to create the softbody for
  50763. */
  50764. private _createSoftbody;
  50765. /**
  50766. * Create cloth for an impostor
  50767. * @param impostor to create the softbody for
  50768. */
  50769. private _createCloth;
  50770. /**
  50771. * Create rope for an impostor
  50772. * @param impostor to create the softbody for
  50773. */
  50774. private _createRope;
  50775. private _addHullVerts;
  50776. private _createShape;
  50777. /**
  50778. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50779. * @param impostor imposter containing the physics body and babylon object
  50780. */
  50781. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50782. /**
  50783. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50784. * @param impostor imposter containing the physics body and babylon object
  50785. * @param newPosition new position
  50786. * @param newRotation new rotation
  50787. */
  50788. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50789. /**
  50790. * If this plugin is supported
  50791. * @returns true if its supported
  50792. */
  50793. isSupported(): boolean;
  50794. /**
  50795. * Sets the linear velocity of the physics body
  50796. * @param impostor imposter to set the velocity on
  50797. * @param velocity velocity to set
  50798. */
  50799. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50800. /**
  50801. * Sets the angular velocity of the physics body
  50802. * @param impostor imposter to set the velocity on
  50803. * @param velocity velocity to set
  50804. */
  50805. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50806. /**
  50807. * gets the linear velocity
  50808. * @param impostor imposter to get linear velocity from
  50809. * @returns linear velocity
  50810. */
  50811. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50812. /**
  50813. * gets the angular velocity
  50814. * @param impostor imposter to get angular velocity from
  50815. * @returns angular velocity
  50816. */
  50817. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50818. /**
  50819. * Sets the mass of physics body
  50820. * @param impostor imposter to set the mass on
  50821. * @param mass mass to set
  50822. */
  50823. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50824. /**
  50825. * Gets the mass of the physics body
  50826. * @param impostor imposter to get the mass from
  50827. * @returns mass
  50828. */
  50829. getBodyMass(impostor: PhysicsImpostor): number;
  50830. /**
  50831. * Gets friction of the impostor
  50832. * @param impostor impostor to get friction from
  50833. * @returns friction value
  50834. */
  50835. getBodyFriction(impostor: PhysicsImpostor): number;
  50836. /**
  50837. * Sets friction of the impostor
  50838. * @param impostor impostor to set friction on
  50839. * @param friction friction value
  50840. */
  50841. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50842. /**
  50843. * Gets restitution of the impostor
  50844. * @param impostor impostor to get restitution from
  50845. * @returns restitution value
  50846. */
  50847. getBodyRestitution(impostor: PhysicsImpostor): number;
  50848. /**
  50849. * Sets resitution of the impostor
  50850. * @param impostor impostor to set resitution on
  50851. * @param restitution resitution value
  50852. */
  50853. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50854. /**
  50855. * Gets pressure inside the impostor
  50856. * @param impostor impostor to get pressure from
  50857. * @returns pressure value
  50858. */
  50859. getBodyPressure(impostor: PhysicsImpostor): number;
  50860. /**
  50861. * Sets pressure inside a soft body impostor
  50862. * Cloth and rope must remain 0 pressure
  50863. * @param impostor impostor to set pressure on
  50864. * @param pressure pressure value
  50865. */
  50866. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50867. /**
  50868. * Gets stiffness of the impostor
  50869. * @param impostor impostor to get stiffness from
  50870. * @returns pressure value
  50871. */
  50872. getBodyStiffness(impostor: PhysicsImpostor): number;
  50873. /**
  50874. * Sets stiffness of the impostor
  50875. * @param impostor impostor to set stiffness on
  50876. * @param stiffness stiffness value from 0 to 1
  50877. */
  50878. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50879. /**
  50880. * Gets velocityIterations of the impostor
  50881. * @param impostor impostor to get velocity iterations from
  50882. * @returns velocityIterations value
  50883. */
  50884. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50885. /**
  50886. * Sets velocityIterations of the impostor
  50887. * @param impostor impostor to set velocity iterations on
  50888. * @param velocityIterations velocityIterations value
  50889. */
  50890. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50891. /**
  50892. * Gets positionIterations of the impostor
  50893. * @param impostor impostor to get position iterations from
  50894. * @returns positionIterations value
  50895. */
  50896. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50897. /**
  50898. * Sets positionIterations of the impostor
  50899. * @param impostor impostor to set position on
  50900. * @param positionIterations positionIterations value
  50901. */
  50902. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50903. /**
  50904. * Append an anchor to a cloth object
  50905. * @param impostor is the cloth impostor to add anchor to
  50906. * @param otherImpostor is the rigid impostor to anchor to
  50907. * @param width ratio across width from 0 to 1
  50908. * @param height ratio up height from 0 to 1
  50909. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50910. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50911. */
  50912. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50913. /**
  50914. * Append an hook to a rope object
  50915. * @param impostor is the rope impostor to add hook to
  50916. * @param otherImpostor is the rigid impostor to hook to
  50917. * @param length ratio along the rope from 0 to 1
  50918. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50919. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50920. */
  50921. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50922. /**
  50923. * Sleeps the physics body and stops it from being active
  50924. * @param impostor impostor to sleep
  50925. */
  50926. sleepBody(impostor: PhysicsImpostor): void;
  50927. /**
  50928. * Activates the physics body
  50929. * @param impostor impostor to activate
  50930. */
  50931. wakeUpBody(impostor: PhysicsImpostor): void;
  50932. /**
  50933. * Updates the distance parameters of the joint
  50934. * @param joint joint to update
  50935. * @param maxDistance maximum distance of the joint
  50936. * @param minDistance minimum distance of the joint
  50937. */
  50938. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50939. /**
  50940. * Sets a motor on the joint
  50941. * @param joint joint to set motor on
  50942. * @param speed speed of the motor
  50943. * @param maxForce maximum force of the motor
  50944. * @param motorIndex index of the motor
  50945. */
  50946. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50947. /**
  50948. * Sets the motors limit
  50949. * @param joint joint to set limit on
  50950. * @param upperLimit upper limit
  50951. * @param lowerLimit lower limit
  50952. */
  50953. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50954. /**
  50955. * Syncs the position and rotation of a mesh with the impostor
  50956. * @param mesh mesh to sync
  50957. * @param impostor impostor to update the mesh with
  50958. */
  50959. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50960. /**
  50961. * Gets the radius of the impostor
  50962. * @param impostor impostor to get radius from
  50963. * @returns the radius
  50964. */
  50965. getRadius(impostor: PhysicsImpostor): number;
  50966. /**
  50967. * Gets the box size of the impostor
  50968. * @param impostor impostor to get box size from
  50969. * @param result the resulting box size
  50970. */
  50971. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50972. /**
  50973. * Disposes of the impostor
  50974. */
  50975. dispose(): void;
  50976. /**
  50977. * Does a raycast in the physics world
  50978. * @param from when should the ray start?
  50979. * @param to when should the ray end?
  50980. * @returns PhysicsRaycastResult
  50981. */
  50982. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50983. }
  50984. }
  50985. declare module "babylonjs/Probes/reflectionProbe" {
  50986. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50987. import { Vector3 } from "babylonjs/Maths/math";
  50988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50989. import { Nullable } from "babylonjs/types";
  50990. import { Scene } from "babylonjs/scene";
  50991. module "babylonjs/abstractScene" {
  50992. interface AbstractScene {
  50993. /**
  50994. * The list of reflection probes added to the scene
  50995. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50996. */
  50997. reflectionProbes: Array<ReflectionProbe>;
  50998. /**
  50999. * Removes the given reflection probe from this scene.
  51000. * @param toRemove The reflection probe to remove
  51001. * @returns The index of the removed reflection probe
  51002. */
  51003. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51004. /**
  51005. * Adds the given reflection probe to this scene.
  51006. * @param newReflectionProbe The reflection probe to add
  51007. */
  51008. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51009. }
  51010. }
  51011. /**
  51012. * Class used to generate realtime reflection / refraction cube textures
  51013. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51014. */
  51015. export class ReflectionProbe {
  51016. /** defines the name of the probe */
  51017. name: string;
  51018. private _scene;
  51019. private _renderTargetTexture;
  51020. private _projectionMatrix;
  51021. private _viewMatrix;
  51022. private _target;
  51023. private _add;
  51024. private _attachedMesh;
  51025. private _invertYAxis;
  51026. /** Gets or sets probe position (center of the cube map) */
  51027. position: Vector3;
  51028. /**
  51029. * Creates a new reflection probe
  51030. * @param name defines the name of the probe
  51031. * @param size defines the texture resolution (for each face)
  51032. * @param scene defines the hosting scene
  51033. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51034. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51035. */
  51036. constructor(
  51037. /** defines the name of the probe */
  51038. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51039. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51040. samples: number;
  51041. /** Gets or sets the refresh rate to use (on every frame by default) */
  51042. refreshRate: number;
  51043. /**
  51044. * Gets the hosting scene
  51045. * @returns a Scene
  51046. */
  51047. getScene(): Scene;
  51048. /** Gets the internal CubeTexture used to render to */
  51049. readonly cubeTexture: RenderTargetTexture;
  51050. /** Gets the list of meshes to render */
  51051. readonly renderList: Nullable<AbstractMesh[]>;
  51052. /**
  51053. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51054. * @param mesh defines the mesh to attach to
  51055. */
  51056. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51057. /**
  51058. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51059. * @param renderingGroupId The rendering group id corresponding to its index
  51060. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51061. */
  51062. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51063. /**
  51064. * Clean all associated resources
  51065. */
  51066. dispose(): void;
  51067. /**
  51068. * Converts the reflection probe information to a readable string for debug purpose.
  51069. * @param fullDetails Supports for multiple levels of logging within scene loading
  51070. * @returns the human readable reflection probe info
  51071. */
  51072. toString(fullDetails?: boolean): string;
  51073. /**
  51074. * Get the class name of the relfection probe.
  51075. * @returns "ReflectionProbe"
  51076. */
  51077. getClassName(): string;
  51078. /**
  51079. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51080. * @returns The JSON representation of the texture
  51081. */
  51082. serialize(): any;
  51083. /**
  51084. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51085. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51086. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51087. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51088. * @returns The parsed reflection probe if successful
  51089. */
  51090. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51091. }
  51092. }
  51093. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51094. /** @hidden */
  51095. export var _BabylonLoaderRegistered: boolean;
  51096. }
  51097. declare module "babylonjs/Loading/Plugins/index" {
  51098. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51099. }
  51100. declare module "babylonjs/Loading/index" {
  51101. export * from "babylonjs/Loading/loadingScreen";
  51102. export * from "babylonjs/Loading/Plugins/index";
  51103. export * from "babylonjs/Loading/sceneLoader";
  51104. export * from "babylonjs/Loading/sceneLoaderFlags";
  51105. }
  51106. declare module "babylonjs/Materials/Background/index" {
  51107. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51108. }
  51109. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51110. import { Scene } from "babylonjs/scene";
  51111. import { Color3 } from "babylonjs/Maths/math";
  51112. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51113. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51114. /**
  51115. * The Physically based simple base material of BJS.
  51116. *
  51117. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51118. * It is used as the base class for both the specGloss and metalRough conventions.
  51119. */
  51120. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51121. /**
  51122. * Number of Simultaneous lights allowed on the material.
  51123. */
  51124. maxSimultaneousLights: number;
  51125. /**
  51126. * If sets to true, disables all the lights affecting the material.
  51127. */
  51128. disableLighting: boolean;
  51129. /**
  51130. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51131. */
  51132. environmentTexture: BaseTexture;
  51133. /**
  51134. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51135. */
  51136. invertNormalMapX: boolean;
  51137. /**
  51138. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51139. */
  51140. invertNormalMapY: boolean;
  51141. /**
  51142. * Normal map used in the model.
  51143. */
  51144. normalTexture: BaseTexture;
  51145. /**
  51146. * Emissivie color used to self-illuminate the model.
  51147. */
  51148. emissiveColor: Color3;
  51149. /**
  51150. * Emissivie texture used to self-illuminate the model.
  51151. */
  51152. emissiveTexture: BaseTexture;
  51153. /**
  51154. * Occlusion Channel Strenght.
  51155. */
  51156. occlusionStrength: number;
  51157. /**
  51158. * Occlusion Texture of the material (adding extra occlusion effects).
  51159. */
  51160. occlusionTexture: BaseTexture;
  51161. /**
  51162. * Defines the alpha limits in alpha test mode.
  51163. */
  51164. alphaCutOff: number;
  51165. /**
  51166. * Gets the current double sided mode.
  51167. */
  51168. /**
  51169. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51170. */
  51171. doubleSided: boolean;
  51172. /**
  51173. * Stores the pre-calculated light information of a mesh in a texture.
  51174. */
  51175. lightmapTexture: BaseTexture;
  51176. /**
  51177. * If true, the light map contains occlusion information instead of lighting info.
  51178. */
  51179. useLightmapAsShadowmap: boolean;
  51180. /**
  51181. * Instantiates a new PBRMaterial instance.
  51182. *
  51183. * @param name The material name
  51184. * @param scene The scene the material will be use in.
  51185. */
  51186. constructor(name: string, scene: Scene);
  51187. getClassName(): string;
  51188. }
  51189. }
  51190. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51191. import { Scene } from "babylonjs/scene";
  51192. import { Color3 } from "babylonjs/Maths/math";
  51193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51194. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51195. /**
  51196. * The PBR material of BJS following the metal roughness convention.
  51197. *
  51198. * This fits to the PBR convention in the GLTF definition:
  51199. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51200. */
  51201. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51202. /**
  51203. * The base color has two different interpretations depending on the value of metalness.
  51204. * When the material is a metal, the base color is the specific measured reflectance value
  51205. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51206. * of the material.
  51207. */
  51208. baseColor: Color3;
  51209. /**
  51210. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51211. * well as opacity information in the alpha channel.
  51212. */
  51213. baseTexture: BaseTexture;
  51214. /**
  51215. * Specifies the metallic scalar value of the material.
  51216. * Can also be used to scale the metalness values of the metallic texture.
  51217. */
  51218. metallic: number;
  51219. /**
  51220. * Specifies the roughness scalar value of the material.
  51221. * Can also be used to scale the roughness values of the metallic texture.
  51222. */
  51223. roughness: number;
  51224. /**
  51225. * Texture containing both the metallic value in the B channel and the
  51226. * roughness value in the G channel to keep better precision.
  51227. */
  51228. metallicRoughnessTexture: BaseTexture;
  51229. /**
  51230. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51231. *
  51232. * @param name The material name
  51233. * @param scene The scene the material will be use in.
  51234. */
  51235. constructor(name: string, scene: Scene);
  51236. /**
  51237. * Return the currrent class name of the material.
  51238. */
  51239. getClassName(): string;
  51240. /**
  51241. * Makes a duplicate of the current material.
  51242. * @param name - name to use for the new material.
  51243. */
  51244. clone(name: string): PBRMetallicRoughnessMaterial;
  51245. /**
  51246. * Serialize the material to a parsable JSON object.
  51247. */
  51248. serialize(): any;
  51249. /**
  51250. * Parses a JSON object correponding to the serialize function.
  51251. */
  51252. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51253. }
  51254. }
  51255. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51256. import { Scene } from "babylonjs/scene";
  51257. import { Color3 } from "babylonjs/Maths/math";
  51258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51259. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51260. /**
  51261. * The PBR material of BJS following the specular glossiness convention.
  51262. *
  51263. * This fits to the PBR convention in the GLTF definition:
  51264. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51265. */
  51266. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51267. /**
  51268. * Specifies the diffuse color of the material.
  51269. */
  51270. diffuseColor: Color3;
  51271. /**
  51272. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51273. * channel.
  51274. */
  51275. diffuseTexture: BaseTexture;
  51276. /**
  51277. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51278. */
  51279. specularColor: Color3;
  51280. /**
  51281. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51282. */
  51283. glossiness: number;
  51284. /**
  51285. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51286. */
  51287. specularGlossinessTexture: BaseTexture;
  51288. /**
  51289. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51290. *
  51291. * @param name The material name
  51292. * @param scene The scene the material will be use in.
  51293. */
  51294. constructor(name: string, scene: Scene);
  51295. /**
  51296. * Return the currrent class name of the material.
  51297. */
  51298. getClassName(): string;
  51299. /**
  51300. * Makes a duplicate of the current material.
  51301. * @param name - name to use for the new material.
  51302. */
  51303. clone(name: string): PBRSpecularGlossinessMaterial;
  51304. /**
  51305. * Serialize the material to a parsable JSON object.
  51306. */
  51307. serialize(): any;
  51308. /**
  51309. * Parses a JSON object correponding to the serialize function.
  51310. */
  51311. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51312. }
  51313. }
  51314. declare module "babylonjs/Materials/PBR/index" {
  51315. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51316. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51317. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51318. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51319. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51320. }
  51321. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51322. import { Nullable } from "babylonjs/types";
  51323. import { Scene } from "babylonjs/scene";
  51324. import { Matrix } from "babylonjs/Maths/math";
  51325. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51326. /**
  51327. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51328. * It can help converting any input color in a desired output one. This can then be used to create effects
  51329. * from sepia, black and white to sixties or futuristic rendering...
  51330. *
  51331. * The only supported format is currently 3dl.
  51332. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51333. */
  51334. export class ColorGradingTexture extends BaseTexture {
  51335. /**
  51336. * The current texture matrix. (will always be identity in color grading texture)
  51337. */
  51338. private _textureMatrix;
  51339. /**
  51340. * The texture URL.
  51341. */
  51342. url: string;
  51343. /**
  51344. * Empty line regex stored for GC.
  51345. */
  51346. private static _noneEmptyLineRegex;
  51347. private _engine;
  51348. /**
  51349. * Instantiates a ColorGradingTexture from the following parameters.
  51350. *
  51351. * @param url The location of the color gradind data (currently only supporting 3dl)
  51352. * @param scene The scene the texture will be used in
  51353. */
  51354. constructor(url: string, scene: Scene);
  51355. /**
  51356. * Returns the texture matrix used in most of the material.
  51357. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51358. */
  51359. getTextureMatrix(): Matrix;
  51360. /**
  51361. * Occurs when the file being loaded is a .3dl LUT file.
  51362. */
  51363. private load3dlTexture;
  51364. /**
  51365. * Starts the loading process of the texture.
  51366. */
  51367. private loadTexture;
  51368. /**
  51369. * Clones the color gradind texture.
  51370. */
  51371. clone(): ColorGradingTexture;
  51372. /**
  51373. * Called during delayed load for textures.
  51374. */
  51375. delayLoad(): void;
  51376. /**
  51377. * Parses a color grading texture serialized by Babylon.
  51378. * @param parsedTexture The texture information being parsedTexture
  51379. * @param scene The scene to load the texture in
  51380. * @param rootUrl The root url of the data assets to load
  51381. * @return A color gradind texture
  51382. */
  51383. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51384. /**
  51385. * Serializes the LUT texture to json format.
  51386. */
  51387. serialize(): any;
  51388. }
  51389. }
  51390. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51391. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51392. import { Scene } from "babylonjs/scene";
  51393. import { Nullable } from "babylonjs/types";
  51394. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51395. /**
  51396. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51397. */
  51398. export class EquiRectangularCubeTexture extends BaseTexture {
  51399. /** The six faces of the cube. */
  51400. private static _FacesMapping;
  51401. private _noMipmap;
  51402. private _onLoad;
  51403. private _onError;
  51404. /** The size of the cubemap. */
  51405. private _size;
  51406. /** The buffer of the image. */
  51407. private _buffer;
  51408. /** The width of the input image. */
  51409. private _width;
  51410. /** The height of the input image. */
  51411. private _height;
  51412. /** The URL to the image. */
  51413. url: string;
  51414. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51415. coordinatesMode: number;
  51416. /**
  51417. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51418. * @param url The location of the image
  51419. * @param scene The scene the texture will be used in
  51420. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51421. * @param noMipmap Forces to not generate the mipmap if true
  51422. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51423. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51424. * @param onLoad — defines a callback called when texture is loaded
  51425. * @param onError — defines a callback called if there is an error
  51426. */
  51427. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51428. /**
  51429. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51430. */
  51431. private loadImage;
  51432. /**
  51433. * Convert the image buffer into a cubemap and create a CubeTexture.
  51434. */
  51435. private loadTexture;
  51436. /**
  51437. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51438. * @param buffer The ArrayBuffer that should be converted.
  51439. * @returns The buffer as Float32Array.
  51440. */
  51441. private getFloat32ArrayFromArrayBuffer;
  51442. /**
  51443. * Get the current class name of the texture useful for serialization or dynamic coding.
  51444. * @returns "EquiRectangularCubeTexture"
  51445. */
  51446. getClassName(): string;
  51447. /**
  51448. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51449. * @returns A clone of the current EquiRectangularCubeTexture.
  51450. */
  51451. clone(): EquiRectangularCubeTexture;
  51452. }
  51453. }
  51454. declare module "babylonjs/Misc/tga" {
  51455. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51456. /**
  51457. * Based on jsTGALoader - Javascript loader for TGA file
  51458. * By Vincent Thibault
  51459. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51460. */
  51461. export class TGATools {
  51462. private static _TYPE_INDEXED;
  51463. private static _TYPE_RGB;
  51464. private static _TYPE_GREY;
  51465. private static _TYPE_RLE_INDEXED;
  51466. private static _TYPE_RLE_RGB;
  51467. private static _TYPE_RLE_GREY;
  51468. private static _ORIGIN_MASK;
  51469. private static _ORIGIN_SHIFT;
  51470. private static _ORIGIN_BL;
  51471. private static _ORIGIN_BR;
  51472. private static _ORIGIN_UL;
  51473. private static _ORIGIN_UR;
  51474. /**
  51475. * Gets the header of a TGA file
  51476. * @param data defines the TGA data
  51477. * @returns the header
  51478. */
  51479. static GetTGAHeader(data: Uint8Array): any;
  51480. /**
  51481. * Uploads TGA content to a Babylon Texture
  51482. * @hidden
  51483. */
  51484. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51485. /** @hidden */
  51486. 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;
  51487. /** @hidden */
  51488. 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;
  51489. /** @hidden */
  51490. 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;
  51491. /** @hidden */
  51492. 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;
  51493. /** @hidden */
  51494. 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;
  51495. /** @hidden */
  51496. 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;
  51497. }
  51498. }
  51499. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51500. import { Nullable } from "babylonjs/types";
  51501. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51502. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51503. /**
  51504. * Implementation of the TGA Texture Loader.
  51505. * @hidden
  51506. */
  51507. export class _TGATextureLoader implements IInternalTextureLoader {
  51508. /**
  51509. * Defines wether the loader supports cascade loading the different faces.
  51510. */
  51511. readonly supportCascades: boolean;
  51512. /**
  51513. * This returns if the loader support the current file information.
  51514. * @param extension defines the file extension of the file being loaded
  51515. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51516. * @param fallback defines the fallback internal texture if any
  51517. * @param isBase64 defines whether the texture is encoded as a base64
  51518. * @param isBuffer defines whether the texture data are stored as a buffer
  51519. * @returns true if the loader can load the specified file
  51520. */
  51521. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51522. /**
  51523. * Transform the url before loading if required.
  51524. * @param rootUrl the url of the texture
  51525. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51526. * @returns the transformed texture
  51527. */
  51528. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51529. /**
  51530. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51531. * @param rootUrl the url of the texture
  51532. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51533. * @returns the fallback texture
  51534. */
  51535. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51536. /**
  51537. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51538. * @param data contains the texture data
  51539. * @param texture defines the BabylonJS internal texture
  51540. * @param createPolynomials will be true if polynomials have been requested
  51541. * @param onLoad defines the callback to trigger once the texture is ready
  51542. * @param onError defines the callback to trigger in case of error
  51543. */
  51544. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51545. /**
  51546. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51547. * @param data contains the texture data
  51548. * @param texture defines the BabylonJS internal texture
  51549. * @param callback defines the method to call once ready to upload
  51550. */
  51551. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51552. }
  51553. }
  51554. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51555. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51556. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51557. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51558. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51559. }
  51560. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51561. import { Scene } from "babylonjs/scene";
  51562. import { Texture } from "babylonjs/Materials/Textures/texture";
  51563. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51564. /**
  51565. * 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.
  51566. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51567. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51568. */
  51569. export class CustomProceduralTexture extends ProceduralTexture {
  51570. private _animate;
  51571. private _time;
  51572. private _config;
  51573. private _texturePath;
  51574. /**
  51575. * Instantiates a new Custom Procedural Texture.
  51576. * 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.
  51577. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51578. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51579. * @param name Define the name of the texture
  51580. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51581. * @param size Define the size of the texture to create
  51582. * @param scene Define the scene the texture belongs to
  51583. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51584. * @param generateMipMaps Define if the texture should creates mip maps or not
  51585. */
  51586. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51587. private _loadJson;
  51588. /**
  51589. * Is the texture ready to be used ? (rendered at least once)
  51590. * @returns true if ready, otherwise, false.
  51591. */
  51592. isReady(): boolean;
  51593. /**
  51594. * Render the texture to its associated render target.
  51595. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51596. */
  51597. render(useCameraPostProcess?: boolean): void;
  51598. /**
  51599. * Update the list of dependant textures samplers in the shader.
  51600. */
  51601. updateTextures(): void;
  51602. /**
  51603. * Update the uniform values of the procedural texture in the shader.
  51604. */
  51605. updateShaderUniforms(): void;
  51606. /**
  51607. * Define if the texture animates or not.
  51608. */
  51609. animate: boolean;
  51610. }
  51611. }
  51612. declare module "babylonjs/Shaders/noise.fragment" {
  51613. /** @hidden */
  51614. export var noisePixelShader: {
  51615. name: string;
  51616. shader: string;
  51617. };
  51618. }
  51619. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51620. import { Nullable } from "babylonjs/types";
  51621. import { Scene } from "babylonjs/scene";
  51622. import { Texture } from "babylonjs/Materials/Textures/texture";
  51623. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51624. import "babylonjs/Shaders/noise.fragment";
  51625. /**
  51626. * Class used to generate noise procedural textures
  51627. */
  51628. export class NoiseProceduralTexture extends ProceduralTexture {
  51629. private _time;
  51630. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51631. brightness: number;
  51632. /** Defines the number of octaves to process */
  51633. octaves: number;
  51634. /** Defines the level of persistence (0.8 by default) */
  51635. persistence: number;
  51636. /** Gets or sets animation speed factor (default is 1) */
  51637. animationSpeedFactor: number;
  51638. /**
  51639. * Creates a new NoiseProceduralTexture
  51640. * @param name defines the name fo the texture
  51641. * @param size defines the size of the texture (default is 256)
  51642. * @param scene defines the hosting scene
  51643. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51644. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51645. */
  51646. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51647. private _updateShaderUniforms;
  51648. protected _getDefines(): string;
  51649. /** Generate the current state of the procedural texture */
  51650. render(useCameraPostProcess?: boolean): void;
  51651. /**
  51652. * Serializes this noise procedural texture
  51653. * @returns a serialized noise procedural texture object
  51654. */
  51655. serialize(): any;
  51656. /**
  51657. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51658. * @param parsedTexture defines parsed texture data
  51659. * @param scene defines the current scene
  51660. * @param rootUrl defines the root URL containing noise procedural texture information
  51661. * @returns a parsed NoiseProceduralTexture
  51662. */
  51663. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51664. }
  51665. }
  51666. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51667. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51668. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51669. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51670. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51671. }
  51672. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51673. import { Nullable } from "babylonjs/types";
  51674. import { Scene } from "babylonjs/scene";
  51675. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51677. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51678. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51679. /**
  51680. * Raw cube texture where the raw buffers are passed in
  51681. */
  51682. export class RawCubeTexture extends CubeTexture {
  51683. /**
  51684. * Creates a cube texture where the raw buffers are passed in.
  51685. * @param scene defines the scene the texture is attached to
  51686. * @param data defines the array of data to use to create each face
  51687. * @param size defines the size of the textures
  51688. * @param format defines the format of the data
  51689. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51690. * @param generateMipMaps defines if the engine should generate the mip levels
  51691. * @param invertY defines if data must be stored with Y axis inverted
  51692. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51693. * @param compression defines the compression used (null by default)
  51694. */
  51695. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51696. /**
  51697. * Updates the raw cube texture.
  51698. * @param data defines the data to store
  51699. * @param format defines the data format
  51700. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51701. * @param invertY defines if data must be stored with Y axis inverted
  51702. * @param compression defines the compression used (null by default)
  51703. * @param level defines which level of the texture to update
  51704. */
  51705. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51706. /**
  51707. * Updates a raw cube texture with RGBD encoded data.
  51708. * @param data defines the array of data [mipmap][face] to use to create each face
  51709. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51710. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51711. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51712. * @returns a promsie that resolves when the operation is complete
  51713. */
  51714. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51715. /**
  51716. * Clones the raw cube texture.
  51717. * @return a new cube texture
  51718. */
  51719. clone(): CubeTexture;
  51720. /** @hidden */
  51721. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51722. }
  51723. }
  51724. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51725. import { Scene } from "babylonjs/scene";
  51726. import { Texture } from "babylonjs/Materials/Textures/texture";
  51727. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51728. /**
  51729. * Class used to store 3D textures containing user data
  51730. */
  51731. export class RawTexture3D extends Texture {
  51732. /** Gets or sets the texture format to use */
  51733. format: number;
  51734. private _engine;
  51735. /**
  51736. * Create a new RawTexture3D
  51737. * @param data defines the data of the texture
  51738. * @param width defines the width of the texture
  51739. * @param height defines the height of the texture
  51740. * @param depth defines the depth of the texture
  51741. * @param format defines the texture format to use
  51742. * @param scene defines the hosting scene
  51743. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51744. * @param invertY defines if texture must be stored with Y axis inverted
  51745. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51746. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51747. */
  51748. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51749. /** Gets or sets the texture format to use */
  51750. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51751. /**
  51752. * Update the texture with new data
  51753. * @param data defines the data to store in the texture
  51754. */
  51755. update(data: ArrayBufferView): void;
  51756. }
  51757. }
  51758. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51759. import { Scene } from "babylonjs/scene";
  51760. import { Plane } from "babylonjs/Maths/math";
  51761. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51762. /**
  51763. * Creates a refraction texture used by refraction channel of the standard material.
  51764. * It is like a mirror but to see through a material.
  51765. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51766. */
  51767. export class RefractionTexture extends RenderTargetTexture {
  51768. /**
  51769. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51770. * 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.
  51771. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51772. */
  51773. refractionPlane: Plane;
  51774. /**
  51775. * Define how deep under the surface we should see.
  51776. */
  51777. depth: number;
  51778. /**
  51779. * Creates a refraction texture used by refraction channel of the standard material.
  51780. * It is like a mirror but to see through a material.
  51781. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51782. * @param name Define the texture name
  51783. * @param size Define the size of the underlying texture
  51784. * @param scene Define the scene the refraction belongs to
  51785. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51786. */
  51787. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51788. /**
  51789. * Clone the refraction texture.
  51790. * @returns the cloned texture
  51791. */
  51792. clone(): RefractionTexture;
  51793. /**
  51794. * Serialize the texture to a JSON representation you could use in Parse later on
  51795. * @returns the serialized JSON representation
  51796. */
  51797. serialize(): any;
  51798. }
  51799. }
  51800. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51801. import { Nullable } from "babylonjs/types";
  51802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51803. import { Matrix } from "babylonjs/Maths/math";
  51804. import { Engine } from "babylonjs/Engines/engine";
  51805. import { Scene } from "babylonjs/scene";
  51806. /**
  51807. * Defines the options related to the creation of an HtmlElementTexture
  51808. */
  51809. export interface IHtmlElementTextureOptions {
  51810. /**
  51811. * Defines wether mip maps should be created or not.
  51812. */
  51813. generateMipMaps?: boolean;
  51814. /**
  51815. * Defines the sampling mode of the texture.
  51816. */
  51817. samplingMode?: number;
  51818. /**
  51819. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51820. */
  51821. engine: Nullable<Engine>;
  51822. /**
  51823. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51824. */
  51825. scene: Nullable<Scene>;
  51826. }
  51827. /**
  51828. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51829. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51830. * is automatically managed.
  51831. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51832. * in your application.
  51833. *
  51834. * As the update is not automatic, you need to call them manually.
  51835. */
  51836. export class HtmlElementTexture extends BaseTexture {
  51837. /**
  51838. * The texture URL.
  51839. */
  51840. element: HTMLVideoElement | HTMLCanvasElement;
  51841. private static readonly DefaultOptions;
  51842. private _textureMatrix;
  51843. private _engine;
  51844. private _isVideo;
  51845. private _generateMipMaps;
  51846. private _samplingMode;
  51847. /**
  51848. * Instantiates a HtmlElementTexture from the following parameters.
  51849. *
  51850. * @param name Defines the name of the texture
  51851. * @param element Defines the video or canvas the texture is filled with
  51852. * @param options Defines the other none mandatory texture creation options
  51853. */
  51854. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51855. private _createInternalTexture;
  51856. /**
  51857. * Returns the texture matrix used in most of the material.
  51858. */
  51859. getTextureMatrix(): Matrix;
  51860. /**
  51861. * Updates the content of the texture.
  51862. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51863. */
  51864. update(invertY?: Nullable<boolean>): void;
  51865. }
  51866. }
  51867. declare module "babylonjs/Materials/Textures/index" {
  51868. export * from "babylonjs/Materials/Textures/baseTexture";
  51869. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51870. export * from "babylonjs/Materials/Textures/cubeTexture";
  51871. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51872. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51873. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51874. export * from "babylonjs/Materials/Textures/internalTexture";
  51875. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51876. export * from "babylonjs/Materials/Textures/Loaders/index";
  51877. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51878. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51879. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51880. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51881. export * from "babylonjs/Materials/Textures/rawTexture";
  51882. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51883. export * from "babylonjs/Materials/Textures/refractionTexture";
  51884. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51885. export * from "babylonjs/Materials/Textures/texture";
  51886. export * from "babylonjs/Materials/Textures/videoTexture";
  51887. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51888. }
  51889. declare module "babylonjs/Materials/index" {
  51890. export * from "babylonjs/Materials/Background/index";
  51891. export * from "babylonjs/Materials/colorCurves";
  51892. export * from "babylonjs/Materials/effect";
  51893. export * from "babylonjs/Materials/fresnelParameters";
  51894. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51895. export * from "babylonjs/Materials/material";
  51896. export * from "babylonjs/Materials/materialDefines";
  51897. export * from "babylonjs/Materials/materialHelper";
  51898. export * from "babylonjs/Materials/multiMaterial";
  51899. export * from "babylonjs/Materials/PBR/index";
  51900. export * from "babylonjs/Materials/pushMaterial";
  51901. export * from "babylonjs/Materials/shaderMaterial";
  51902. export * from "babylonjs/Materials/standardMaterial";
  51903. export * from "babylonjs/Materials/Textures/index";
  51904. export * from "babylonjs/Materials/uniformBuffer";
  51905. export * from "babylonjs/Materials/materialFlags";
  51906. }
  51907. declare module "babylonjs/Maths/index" {
  51908. export * from "babylonjs/Maths/math.scalar";
  51909. export * from "babylonjs/Maths/math";
  51910. export * from "babylonjs/Maths/sphericalPolynomial";
  51911. }
  51912. declare module "babylonjs/Misc/workerPool" {
  51913. import { IDisposable } from "babylonjs/scene";
  51914. /**
  51915. * Helper class to push actions to a pool of workers.
  51916. */
  51917. export class WorkerPool implements IDisposable {
  51918. private _workerInfos;
  51919. private _pendingActions;
  51920. /**
  51921. * Constructor
  51922. * @param workers Array of workers to use for actions
  51923. */
  51924. constructor(workers: Array<Worker>);
  51925. /**
  51926. * Terminates all workers and clears any pending actions.
  51927. */
  51928. dispose(): void;
  51929. /**
  51930. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51931. * pended until a worker has completed its action.
  51932. * @param action The action to perform. Call onComplete when the action is complete.
  51933. */
  51934. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51935. private _execute;
  51936. }
  51937. }
  51938. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51939. import { IDisposable } from "babylonjs/scene";
  51940. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51941. /**
  51942. * Configuration for Draco compression
  51943. */
  51944. export interface IDracoCompressionConfiguration {
  51945. /**
  51946. * Configuration for the decoder.
  51947. */
  51948. decoder?: {
  51949. /**
  51950. * The url to the WebAssembly module.
  51951. */
  51952. wasmUrl?: string;
  51953. /**
  51954. * The url to the WebAssembly binary.
  51955. */
  51956. wasmBinaryUrl?: string;
  51957. /**
  51958. * The url to the fallback JavaScript module.
  51959. */
  51960. fallbackUrl?: string;
  51961. };
  51962. }
  51963. /**
  51964. * Draco compression (https://google.github.io/draco/)
  51965. *
  51966. * This class wraps the Draco module.
  51967. *
  51968. * **Encoder**
  51969. *
  51970. * The encoder is not currently implemented.
  51971. *
  51972. * **Decoder**
  51973. *
  51974. * 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.
  51975. *
  51976. * To update the configuration, use the following code:
  51977. * ```javascript
  51978. * DracoCompression.Configuration = {
  51979. * decoder: {
  51980. * wasmUrl: "<url to the WebAssembly library>",
  51981. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51982. * fallbackUrl: "<url to the fallback JavaScript library>",
  51983. * }
  51984. * };
  51985. * ```
  51986. *
  51987. * 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.
  51988. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51989. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51990. *
  51991. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51992. * ```javascript
  51993. * var dracoCompression = new DracoCompression();
  51994. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51995. * [VertexBuffer.PositionKind]: 0
  51996. * });
  51997. * ```
  51998. *
  51999. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52000. */
  52001. export class DracoCompression implements IDisposable {
  52002. private _workerPoolPromise;
  52003. /**
  52004. * The configuration. Defaults to the following urls:
  52005. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52006. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52007. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52008. */
  52009. static Configuration: IDracoCompressionConfiguration;
  52010. /**
  52011. * Returns true if the decoder is available.
  52012. */
  52013. static readonly DecoderAvailable: boolean;
  52014. /**
  52015. * Default number of workers to create when creating the draco compression object.
  52016. */
  52017. static DefaultNumWorkers: number;
  52018. private static GetDefaultNumWorkers;
  52019. /**
  52020. * Constructor
  52021. * @param numWorkers The number of workers for async operations
  52022. */
  52023. constructor(numWorkers?: number);
  52024. /**
  52025. * Stop all async operations and release resources.
  52026. */
  52027. dispose(): void;
  52028. /**
  52029. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52030. * @returns a promise that resolves when ready
  52031. */
  52032. whenReadyAsync(): Promise<void>;
  52033. /**
  52034. * Decode Draco compressed mesh data to vertex data.
  52035. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52036. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52037. * @returns A promise that resolves with the decoded vertex data
  52038. */
  52039. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52040. [kind: string]: number;
  52041. }): Promise<VertexData>;
  52042. /**
  52043. * The worker function that gets converted to a blob url to pass into a worker.
  52044. */
  52045. private static _Worker;
  52046. private _loadDecoderWasmBinaryAsync;
  52047. }
  52048. }
  52049. declare module "babylonjs/Meshes/Compression/index" {
  52050. export * from "babylonjs/Meshes/Compression/dracoCompression";
  52051. }
  52052. declare module "babylonjs/Meshes/csg" {
  52053. import { Nullable } from "babylonjs/types";
  52054. import { Scene } from "babylonjs/scene";
  52055. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  52056. import { Mesh } from "babylonjs/Meshes/mesh";
  52057. import { Material } from "babylonjs/Materials/material";
  52058. /**
  52059. * Class for building Constructive Solid Geometry
  52060. */
  52061. export class CSG {
  52062. private polygons;
  52063. /**
  52064. * The world matrix
  52065. */
  52066. matrix: Matrix;
  52067. /**
  52068. * Stores the position
  52069. */
  52070. position: Vector3;
  52071. /**
  52072. * Stores the rotation
  52073. */
  52074. rotation: Vector3;
  52075. /**
  52076. * Stores the rotation quaternion
  52077. */
  52078. rotationQuaternion: Nullable<Quaternion>;
  52079. /**
  52080. * Stores the scaling vector
  52081. */
  52082. scaling: Vector3;
  52083. /**
  52084. * Convert the Mesh to CSG
  52085. * @param mesh The Mesh to convert to CSG
  52086. * @returns A new CSG from the Mesh
  52087. */
  52088. static FromMesh(mesh: Mesh): CSG;
  52089. /**
  52090. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52091. * @param polygons Polygons used to construct a CSG solid
  52092. */
  52093. private static FromPolygons;
  52094. /**
  52095. * Clones, or makes a deep copy, of the CSG
  52096. * @returns A new CSG
  52097. */
  52098. clone(): CSG;
  52099. /**
  52100. * Unions this CSG with another CSG
  52101. * @param csg The CSG to union against this CSG
  52102. * @returns The unioned CSG
  52103. */
  52104. union(csg: CSG): CSG;
  52105. /**
  52106. * Unions this CSG with another CSG in place
  52107. * @param csg The CSG to union against this CSG
  52108. */
  52109. unionInPlace(csg: CSG): void;
  52110. /**
  52111. * Subtracts this CSG with another CSG
  52112. * @param csg The CSG to subtract against this CSG
  52113. * @returns A new CSG
  52114. */
  52115. subtract(csg: CSG): CSG;
  52116. /**
  52117. * Subtracts this CSG with another CSG in place
  52118. * @param csg The CSG to subtact against this CSG
  52119. */
  52120. subtractInPlace(csg: CSG): void;
  52121. /**
  52122. * Intersect this CSG with another CSG
  52123. * @param csg The CSG to intersect against this CSG
  52124. * @returns A new CSG
  52125. */
  52126. intersect(csg: CSG): CSG;
  52127. /**
  52128. * Intersects this CSG with another CSG in place
  52129. * @param csg The CSG to intersect against this CSG
  52130. */
  52131. intersectInPlace(csg: CSG): void;
  52132. /**
  52133. * Return a new CSG solid with solid and empty space switched. This solid is
  52134. * not modified.
  52135. * @returns A new CSG solid with solid and empty space switched
  52136. */
  52137. inverse(): CSG;
  52138. /**
  52139. * Inverses the CSG in place
  52140. */
  52141. inverseInPlace(): void;
  52142. /**
  52143. * This is used to keep meshes transformations so they can be restored
  52144. * when we build back a Babylon Mesh
  52145. * NB : All CSG operations are performed in world coordinates
  52146. * @param csg The CSG to copy the transform attributes from
  52147. * @returns This CSG
  52148. */
  52149. copyTransformAttributes(csg: CSG): CSG;
  52150. /**
  52151. * Build Raw mesh from CSG
  52152. * Coordinates here are in world space
  52153. * @param name The name of the mesh geometry
  52154. * @param scene The Scene
  52155. * @param keepSubMeshes Specifies if the submeshes should be kept
  52156. * @returns A new Mesh
  52157. */
  52158. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52159. /**
  52160. * Build Mesh from CSG taking material and transforms into account
  52161. * @param name The name of the Mesh
  52162. * @param material The material of the Mesh
  52163. * @param scene The Scene
  52164. * @param keepSubMeshes Specifies if submeshes should be kept
  52165. * @returns The new Mesh
  52166. */
  52167. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52168. }
  52169. }
  52170. declare module "babylonjs/Meshes/trailMesh" {
  52171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52172. import { Mesh } from "babylonjs/Meshes/mesh";
  52173. import { Scene } from "babylonjs/scene";
  52174. /**
  52175. * Class used to create a trail following a mesh
  52176. */
  52177. export class TrailMesh extends Mesh {
  52178. private _generator;
  52179. private _autoStart;
  52180. private _running;
  52181. private _diameter;
  52182. private _length;
  52183. private _sectionPolygonPointsCount;
  52184. private _sectionVectors;
  52185. private _sectionNormalVectors;
  52186. private _beforeRenderObserver;
  52187. /**
  52188. * @constructor
  52189. * @param name The value used by scene.getMeshByName() to do a lookup.
  52190. * @param generator The mesh to generate a trail.
  52191. * @param scene The scene to add this mesh to.
  52192. * @param diameter Diameter of trailing mesh. Default is 1.
  52193. * @param length Length of trailing mesh. Default is 60.
  52194. * @param autoStart Automatically start trailing mesh. Default true.
  52195. */
  52196. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52197. /**
  52198. * "TrailMesh"
  52199. * @returns "TrailMesh"
  52200. */
  52201. getClassName(): string;
  52202. private _createMesh;
  52203. /**
  52204. * Start trailing mesh.
  52205. */
  52206. start(): void;
  52207. /**
  52208. * Stop trailing mesh.
  52209. */
  52210. stop(): void;
  52211. /**
  52212. * Update trailing mesh geometry.
  52213. */
  52214. update(): void;
  52215. /**
  52216. * Returns a new TrailMesh object.
  52217. * @param name is a string, the name given to the new mesh
  52218. * @param newGenerator use new generator object for cloned trail mesh
  52219. * @returns a new mesh
  52220. */
  52221. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52222. /**
  52223. * Serializes this trail mesh
  52224. * @param serializationObject object to write serialization to
  52225. */
  52226. serialize(serializationObject: any): void;
  52227. /**
  52228. * Parses a serialized trail mesh
  52229. * @param parsedMesh the serialized mesh
  52230. * @param scene the scene to create the trail mesh in
  52231. * @returns the created trail mesh
  52232. */
  52233. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52234. }
  52235. }
  52236. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  52237. import { Vector4 } from "babylonjs/Maths/math";
  52238. import { Mesh } from "babylonjs/Meshes/mesh";
  52239. /**
  52240. * Class containing static functions to help procedurally build meshes
  52241. */
  52242. export class TorusKnotBuilder {
  52243. /**
  52244. * Creates a torus knot mesh
  52245. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52246. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52247. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52248. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52252. * @param name defines the name of the mesh
  52253. * @param options defines the options used to create the mesh
  52254. * @param scene defines the hosting scene
  52255. * @returns the torus knot mesh
  52256. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52257. */
  52258. static CreateTorusKnot(name: string, options: {
  52259. radius?: number;
  52260. tube?: number;
  52261. radialSegments?: number;
  52262. tubularSegments?: number;
  52263. p?: number;
  52264. q?: number;
  52265. updatable?: boolean;
  52266. sideOrientation?: number;
  52267. frontUVs?: Vector4;
  52268. backUVs?: Vector4;
  52269. }, scene: any): Mesh;
  52270. }
  52271. }
  52272. declare module "babylonjs/Meshes/polygonMesh" {
  52273. import { Scene } from "babylonjs/scene";
  52274. import { Vector2, Path2 } from "babylonjs/Maths/math";
  52275. import { Mesh } from "babylonjs/Meshes/mesh";
  52276. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52277. /**
  52278. * Polygon
  52279. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52280. */
  52281. export class Polygon {
  52282. /**
  52283. * Creates a rectangle
  52284. * @param xmin bottom X coord
  52285. * @param ymin bottom Y coord
  52286. * @param xmax top X coord
  52287. * @param ymax top Y coord
  52288. * @returns points that make the resulting rectation
  52289. */
  52290. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52291. /**
  52292. * Creates a circle
  52293. * @param radius radius of circle
  52294. * @param cx scale in x
  52295. * @param cy scale in y
  52296. * @param numberOfSides number of sides that make up the circle
  52297. * @returns points that make the resulting circle
  52298. */
  52299. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52300. /**
  52301. * Creates a polygon from input string
  52302. * @param input Input polygon data
  52303. * @returns the parsed points
  52304. */
  52305. static Parse(input: string): Vector2[];
  52306. /**
  52307. * Starts building a polygon from x and y coordinates
  52308. * @param x x coordinate
  52309. * @param y y coordinate
  52310. * @returns the started path2
  52311. */
  52312. static StartingAt(x: number, y: number): Path2;
  52313. }
  52314. /**
  52315. * Builds a polygon
  52316. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52317. */
  52318. export class PolygonMeshBuilder {
  52319. private _points;
  52320. private _outlinepoints;
  52321. private _holes;
  52322. private _name;
  52323. private _scene;
  52324. private _epoints;
  52325. private _eholes;
  52326. private _addToepoint;
  52327. /**
  52328. * Babylon reference to the earcut plugin.
  52329. */
  52330. bjsEarcut: any;
  52331. /**
  52332. * Creates a PolygonMeshBuilder
  52333. * @param name name of the builder
  52334. * @param contours Path of the polygon
  52335. * @param scene scene to add to when creating the mesh
  52336. * @param earcutInjection can be used to inject your own earcut reference
  52337. */
  52338. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52339. /**
  52340. * Adds a whole within the polygon
  52341. * @param hole Array of points defining the hole
  52342. * @returns this
  52343. */
  52344. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52345. /**
  52346. * Creates the polygon
  52347. * @param updatable If the mesh should be updatable
  52348. * @param depth The depth of the mesh created
  52349. * @returns the created mesh
  52350. */
  52351. build(updatable?: boolean, depth?: number): Mesh;
  52352. /**
  52353. * Creates the polygon
  52354. * @param depth The depth of the mesh created
  52355. * @returns the created VertexData
  52356. */
  52357. buildVertexData(depth?: number): VertexData;
  52358. /**
  52359. * Adds a side to the polygon
  52360. * @param positions points that make the polygon
  52361. * @param normals normals of the polygon
  52362. * @param uvs uvs of the polygon
  52363. * @param indices indices of the polygon
  52364. * @param bounds bounds of the polygon
  52365. * @param points points of the polygon
  52366. * @param depth depth of the polygon
  52367. * @param flip flip of the polygon
  52368. */
  52369. private addSide;
  52370. }
  52371. }
  52372. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52373. import { Scene } from "babylonjs/scene";
  52374. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52375. import { Mesh } from "babylonjs/Meshes/mesh";
  52376. import { Nullable } from "babylonjs/types";
  52377. /**
  52378. * Class containing static functions to help procedurally build meshes
  52379. */
  52380. export class PolygonBuilder {
  52381. /**
  52382. * Creates a polygon mesh
  52383. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52384. * * 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
  52385. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52388. * * Remember you can only change the shape positions, not their number when updating a polygon
  52389. * @param name defines the name of the mesh
  52390. * @param options defines the options used to create the mesh
  52391. * @param scene defines the hosting scene
  52392. * @param earcutInjection can be used to inject your own earcut reference
  52393. * @returns the polygon mesh
  52394. */
  52395. static CreatePolygon(name: string, options: {
  52396. shape: Vector3[];
  52397. holes?: Vector3[][];
  52398. depth?: number;
  52399. faceUV?: Vector4[];
  52400. faceColors?: Color4[];
  52401. updatable?: boolean;
  52402. sideOrientation?: number;
  52403. frontUVs?: Vector4;
  52404. backUVs?: Vector4;
  52405. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52406. /**
  52407. * Creates an extruded polygon mesh, with depth in the Y direction.
  52408. * * 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)
  52409. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52410. * @param name defines the name of the mesh
  52411. * @param options defines the options used to create the mesh
  52412. * @param scene defines the hosting scene
  52413. * @param earcutInjection can be used to inject your own earcut reference
  52414. * @returns the polygon mesh
  52415. */
  52416. static ExtrudePolygon(name: string, options: {
  52417. shape: Vector3[];
  52418. holes?: Vector3[][];
  52419. depth?: number;
  52420. faceUV?: Vector4[];
  52421. faceColors?: Color4[];
  52422. updatable?: boolean;
  52423. sideOrientation?: number;
  52424. frontUVs?: Vector4;
  52425. backUVs?: Vector4;
  52426. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52427. }
  52428. }
  52429. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52430. import { Scene } from "babylonjs/scene";
  52431. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52432. import { Mesh } from "babylonjs/Meshes/mesh";
  52433. import { Nullable } from "babylonjs/types";
  52434. /**
  52435. * Class containing static functions to help procedurally build meshes
  52436. */
  52437. export class LatheBuilder {
  52438. /**
  52439. * Creates lathe mesh.
  52440. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52441. * * 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
  52442. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52443. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52444. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52445. * * 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
  52446. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52447. * * 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
  52448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52450. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52452. * @param name defines the name of the mesh
  52453. * @param options defines the options used to create the mesh
  52454. * @param scene defines the hosting scene
  52455. * @returns the lathe mesh
  52456. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52457. */
  52458. static CreateLathe(name: string, options: {
  52459. shape: Vector3[];
  52460. radius?: number;
  52461. tessellation?: number;
  52462. clip?: number;
  52463. arc?: number;
  52464. closed?: boolean;
  52465. updatable?: boolean;
  52466. sideOrientation?: number;
  52467. frontUVs?: Vector4;
  52468. backUVs?: Vector4;
  52469. cap?: number;
  52470. invertUV?: boolean;
  52471. }, scene?: Nullable<Scene>): Mesh;
  52472. }
  52473. }
  52474. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52475. import { Nullable } from "babylonjs/types";
  52476. import { Scene } from "babylonjs/scene";
  52477. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52478. import { Mesh } from "babylonjs/Meshes/mesh";
  52479. /**
  52480. * Class containing static functions to help procedurally build meshes
  52481. */
  52482. export class TubeBuilder {
  52483. /**
  52484. * Creates a tube mesh.
  52485. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52486. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52487. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52488. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52489. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52490. * * 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)
  52491. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52492. * * 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
  52493. * * 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
  52494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52496. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52498. * @param name defines the name of the mesh
  52499. * @param options defines the options used to create the mesh
  52500. * @param scene defines the hosting scene
  52501. * @returns the tube mesh
  52502. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52503. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52504. */
  52505. static CreateTube(name: string, options: {
  52506. path: Vector3[];
  52507. radius?: number;
  52508. tessellation?: number;
  52509. radiusFunction?: {
  52510. (i: number, distance: number): number;
  52511. };
  52512. cap?: number;
  52513. arc?: number;
  52514. updatable?: boolean;
  52515. sideOrientation?: number;
  52516. frontUVs?: Vector4;
  52517. backUVs?: Vector4;
  52518. instance?: Mesh;
  52519. invertUV?: boolean;
  52520. }, scene?: Nullable<Scene>): Mesh;
  52521. }
  52522. }
  52523. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52524. import { Scene } from "babylonjs/scene";
  52525. import { Vector4 } from "babylonjs/Maths/math";
  52526. import { Mesh } from "babylonjs/Meshes/mesh";
  52527. import { Nullable } from "babylonjs/types";
  52528. /**
  52529. * Class containing static functions to help procedurally build meshes
  52530. */
  52531. export class IcoSphereBuilder {
  52532. /**
  52533. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52534. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52535. * * 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`)
  52536. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52537. * * 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
  52538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52541. * @param name defines the name of the mesh
  52542. * @param options defines the options used to create the mesh
  52543. * @param scene defines the hosting scene
  52544. * @returns the icosahedron mesh
  52545. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52546. */
  52547. static CreateIcoSphere(name: string, options: {
  52548. radius?: number;
  52549. radiusX?: number;
  52550. radiusY?: number;
  52551. radiusZ?: number;
  52552. flat?: boolean;
  52553. subdivisions?: number;
  52554. sideOrientation?: number;
  52555. frontUVs?: Vector4;
  52556. backUVs?: Vector4;
  52557. updatable?: boolean;
  52558. }, scene?: Nullable<Scene>): Mesh;
  52559. }
  52560. }
  52561. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52562. import { Vector3 } from "babylonjs/Maths/math";
  52563. import { Mesh } from "babylonjs/Meshes/mesh";
  52564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52565. /**
  52566. * Class containing static functions to help procedurally build meshes
  52567. */
  52568. export class DecalBuilder {
  52569. /**
  52570. * Creates a decal mesh.
  52571. * 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
  52572. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52573. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52574. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52575. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52576. * @param name defines the name of the mesh
  52577. * @param sourceMesh defines the mesh where the decal must be applied
  52578. * @param options defines the options used to create the mesh
  52579. * @param scene defines the hosting scene
  52580. * @returns the decal mesh
  52581. * @see https://doc.babylonjs.com/how_to/decals
  52582. */
  52583. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52584. position?: Vector3;
  52585. normal?: Vector3;
  52586. size?: Vector3;
  52587. angle?: number;
  52588. }): Mesh;
  52589. }
  52590. }
  52591. declare module "babylonjs/Meshes/meshBuilder" {
  52592. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52593. import { Nullable } from "babylonjs/types";
  52594. import { Scene } from "babylonjs/scene";
  52595. import { Mesh } from "babylonjs/Meshes/mesh";
  52596. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52597. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52599. /**
  52600. * Class containing static functions to help procedurally build meshes
  52601. */
  52602. export class MeshBuilder {
  52603. /**
  52604. * Creates a box mesh
  52605. * * The parameter `size` sets the size (float) of each box side (default 1)
  52606. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52607. * * 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)
  52608. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52612. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52613. * @param name defines the name of the mesh
  52614. * @param options defines the options used to create the mesh
  52615. * @param scene defines the hosting scene
  52616. * @returns the box mesh
  52617. */
  52618. static CreateBox(name: string, options: {
  52619. size?: number;
  52620. width?: number;
  52621. height?: number;
  52622. depth?: number;
  52623. faceUV?: Vector4[];
  52624. faceColors?: Color4[];
  52625. sideOrientation?: number;
  52626. frontUVs?: Vector4;
  52627. backUVs?: Vector4;
  52628. updatable?: boolean;
  52629. }, scene?: Nullable<Scene>): Mesh;
  52630. /**
  52631. * Creates a sphere mesh
  52632. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52633. * * 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`)
  52634. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52635. * * 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
  52636. * * 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)
  52637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52640. * @param name defines the name of the mesh
  52641. * @param options defines the options used to create the mesh
  52642. * @param scene defines the hosting scene
  52643. * @returns the sphere mesh
  52644. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52645. */
  52646. static CreateSphere(name: string, options: {
  52647. segments?: number;
  52648. diameter?: number;
  52649. diameterX?: number;
  52650. diameterY?: number;
  52651. diameterZ?: number;
  52652. arc?: number;
  52653. slice?: number;
  52654. sideOrientation?: number;
  52655. frontUVs?: Vector4;
  52656. backUVs?: Vector4;
  52657. updatable?: boolean;
  52658. }, scene?: Nullable<Scene>): Mesh;
  52659. /**
  52660. * Creates a plane polygonal mesh. By default, this is a disc
  52661. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52662. * * 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
  52663. * * 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
  52664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52667. * @param name defines the name of the mesh
  52668. * @param options defines the options used to create the mesh
  52669. * @param scene defines the hosting scene
  52670. * @returns the plane polygonal mesh
  52671. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52672. */
  52673. static CreateDisc(name: string, options: {
  52674. radius?: number;
  52675. tessellation?: number;
  52676. arc?: number;
  52677. updatable?: boolean;
  52678. sideOrientation?: number;
  52679. frontUVs?: Vector4;
  52680. backUVs?: Vector4;
  52681. }, scene?: Nullable<Scene>): Mesh;
  52682. /**
  52683. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52684. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52685. * * 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`)
  52686. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52687. * * 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
  52688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52691. * @param name defines the name of the mesh
  52692. * @param options defines the options used to create the mesh
  52693. * @param scene defines the hosting scene
  52694. * @returns the icosahedron mesh
  52695. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52696. */
  52697. static CreateIcoSphere(name: string, options: {
  52698. radius?: number;
  52699. radiusX?: number;
  52700. radiusY?: number;
  52701. radiusZ?: number;
  52702. flat?: boolean;
  52703. subdivisions?: number;
  52704. sideOrientation?: number;
  52705. frontUVs?: Vector4;
  52706. backUVs?: Vector4;
  52707. updatable?: boolean;
  52708. }, scene?: Nullable<Scene>): Mesh;
  52709. /**
  52710. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52711. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52712. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52713. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52714. * * 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
  52715. * * 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
  52716. * * 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
  52717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52719. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52720. * * 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
  52721. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52722. * * 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
  52723. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52725. * @param name defines the name of the mesh
  52726. * @param options defines the options used to create the mesh
  52727. * @param scene defines the hosting scene
  52728. * @returns the ribbon mesh
  52729. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52730. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52731. */
  52732. static CreateRibbon(name: string, options: {
  52733. pathArray: Vector3[][];
  52734. closeArray?: boolean;
  52735. closePath?: boolean;
  52736. offset?: number;
  52737. updatable?: boolean;
  52738. sideOrientation?: number;
  52739. frontUVs?: Vector4;
  52740. backUVs?: Vector4;
  52741. instance?: Mesh;
  52742. invertUV?: boolean;
  52743. uvs?: Vector2[];
  52744. colors?: Color4[];
  52745. }, scene?: Nullable<Scene>): Mesh;
  52746. /**
  52747. * Creates a cylinder or a cone mesh
  52748. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52749. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52750. * * 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.
  52751. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52752. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52753. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52754. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52755. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52756. * * 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).
  52757. * * 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
  52758. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52759. * * 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
  52760. * * 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.
  52761. * * If `enclose` is false, a ring surface is one element.
  52762. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52763. * * 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
  52764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52767. * @param name defines the name of the mesh
  52768. * @param options defines the options used to create the mesh
  52769. * @param scene defines the hosting scene
  52770. * @returns the cylinder mesh
  52771. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52772. */
  52773. static CreateCylinder(name: string, options: {
  52774. height?: number;
  52775. diameterTop?: number;
  52776. diameterBottom?: number;
  52777. diameter?: number;
  52778. tessellation?: number;
  52779. subdivisions?: number;
  52780. arc?: number;
  52781. faceColors?: Color4[];
  52782. faceUV?: Vector4[];
  52783. updatable?: boolean;
  52784. hasRings?: boolean;
  52785. enclose?: boolean;
  52786. sideOrientation?: number;
  52787. frontUVs?: Vector4;
  52788. backUVs?: Vector4;
  52789. }, scene?: Nullable<Scene>): Mesh;
  52790. /**
  52791. * Creates a torus mesh
  52792. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52793. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52794. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52796. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52798. * @param name defines the name of the mesh
  52799. * @param options defines the options used to create the mesh
  52800. * @param scene defines the hosting scene
  52801. * @returns the torus mesh
  52802. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52803. */
  52804. static CreateTorus(name: string, options: {
  52805. diameter?: number;
  52806. thickness?: number;
  52807. tessellation?: number;
  52808. updatable?: boolean;
  52809. sideOrientation?: number;
  52810. frontUVs?: Vector4;
  52811. backUVs?: Vector4;
  52812. }, scene?: Nullable<Scene>): Mesh;
  52813. /**
  52814. * Creates a torus knot mesh
  52815. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52816. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52817. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52818. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52822. * @param name defines the name of the mesh
  52823. * @param options defines the options used to create the mesh
  52824. * @param scene defines the hosting scene
  52825. * @returns the torus knot mesh
  52826. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52827. */
  52828. static CreateTorusKnot(name: string, options: {
  52829. radius?: number;
  52830. tube?: number;
  52831. radialSegments?: number;
  52832. tubularSegments?: number;
  52833. p?: number;
  52834. q?: number;
  52835. updatable?: boolean;
  52836. sideOrientation?: number;
  52837. frontUVs?: Vector4;
  52838. backUVs?: Vector4;
  52839. }, scene?: Nullable<Scene>): Mesh;
  52840. /**
  52841. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52842. * * 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
  52843. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52844. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52845. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52846. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52847. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52848. * * 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
  52849. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52852. * @param name defines the name of the new line system
  52853. * @param options defines the options used to create the line system
  52854. * @param scene defines the hosting scene
  52855. * @returns a new line system mesh
  52856. */
  52857. static CreateLineSystem(name: string, options: {
  52858. lines: Vector3[][];
  52859. updatable?: boolean;
  52860. instance?: Nullable<LinesMesh>;
  52861. colors?: Nullable<Color4[][]>;
  52862. useVertexAlpha?: boolean;
  52863. }, scene: Nullable<Scene>): LinesMesh;
  52864. /**
  52865. * Creates a line mesh
  52866. * 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
  52867. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52868. * * The parameter `points` is an array successive Vector3
  52869. * * 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
  52870. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52871. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52872. * * When updating an instance, remember that only point positions can change, not the number of points
  52873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52874. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52875. * @param name defines the name of the new line system
  52876. * @param options defines the options used to create the line system
  52877. * @param scene defines the hosting scene
  52878. * @returns a new line mesh
  52879. */
  52880. static CreateLines(name: string, options: {
  52881. points: Vector3[];
  52882. updatable?: boolean;
  52883. instance?: Nullable<LinesMesh>;
  52884. colors?: Color4[];
  52885. useVertexAlpha?: boolean;
  52886. }, scene?: Nullable<Scene>): LinesMesh;
  52887. /**
  52888. * Creates a dashed line mesh
  52889. * * 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
  52890. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52891. * * The parameter `points` is an array successive Vector3
  52892. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52893. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52894. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52895. * * 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
  52896. * * When updating an instance, remember that only point positions can change, not the number of points
  52897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52898. * @param name defines the name of the mesh
  52899. * @param options defines the options used to create the mesh
  52900. * @param scene defines the hosting scene
  52901. * @returns the dashed line mesh
  52902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52903. */
  52904. static CreateDashedLines(name: string, options: {
  52905. points: Vector3[];
  52906. dashSize?: number;
  52907. gapSize?: number;
  52908. dashNb?: number;
  52909. updatable?: boolean;
  52910. instance?: LinesMesh;
  52911. }, scene?: Nullable<Scene>): LinesMesh;
  52912. /**
  52913. * 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.
  52914. * * 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.
  52915. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52916. * * 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.
  52917. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52918. * * 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
  52919. * * 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
  52920. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52923. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52925. * @param name defines the name of the mesh
  52926. * @param options defines the options used to create the mesh
  52927. * @param scene defines the hosting scene
  52928. * @returns the extruded shape mesh
  52929. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52931. */
  52932. static ExtrudeShape(name: string, options: {
  52933. shape: Vector3[];
  52934. path: Vector3[];
  52935. scale?: number;
  52936. rotation?: number;
  52937. cap?: number;
  52938. updatable?: boolean;
  52939. sideOrientation?: number;
  52940. frontUVs?: Vector4;
  52941. backUVs?: Vector4;
  52942. instance?: Mesh;
  52943. invertUV?: boolean;
  52944. }, scene?: Nullable<Scene>): Mesh;
  52945. /**
  52946. * Creates an custom extruded shape mesh.
  52947. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52948. * * 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.
  52949. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52950. * * 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
  52951. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52952. * * 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
  52953. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52954. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52955. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52956. * * 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
  52957. * * 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
  52958. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52961. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52963. * @param name defines the name of the mesh
  52964. * @param options defines the options used to create the mesh
  52965. * @param scene defines the hosting scene
  52966. * @returns the custom extruded shape mesh
  52967. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52968. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52969. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52970. */
  52971. static ExtrudeShapeCustom(name: string, options: {
  52972. shape: Vector3[];
  52973. path: Vector3[];
  52974. scaleFunction?: any;
  52975. rotationFunction?: any;
  52976. ribbonCloseArray?: boolean;
  52977. ribbonClosePath?: boolean;
  52978. cap?: number;
  52979. updatable?: boolean;
  52980. sideOrientation?: number;
  52981. frontUVs?: Vector4;
  52982. backUVs?: Vector4;
  52983. instance?: Mesh;
  52984. invertUV?: boolean;
  52985. }, scene?: Nullable<Scene>): Mesh;
  52986. /**
  52987. * Creates lathe mesh.
  52988. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52989. * * 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
  52990. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52991. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52992. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52993. * * 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
  52994. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52995. * * 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
  52996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52998. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53000. * @param name defines the name of the mesh
  53001. * @param options defines the options used to create the mesh
  53002. * @param scene defines the hosting scene
  53003. * @returns the lathe mesh
  53004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53005. */
  53006. static CreateLathe(name: string, options: {
  53007. shape: Vector3[];
  53008. radius?: number;
  53009. tessellation?: number;
  53010. clip?: number;
  53011. arc?: number;
  53012. closed?: boolean;
  53013. updatable?: boolean;
  53014. sideOrientation?: number;
  53015. frontUVs?: Vector4;
  53016. backUVs?: Vector4;
  53017. cap?: number;
  53018. invertUV?: boolean;
  53019. }, scene?: Nullable<Scene>): Mesh;
  53020. /**
  53021. * Creates a plane mesh
  53022. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53023. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53024. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53028. * @param name defines the name of the mesh
  53029. * @param options defines the options used to create the mesh
  53030. * @param scene defines the hosting scene
  53031. * @returns the plane mesh
  53032. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53033. */
  53034. static CreatePlane(name: string, options: {
  53035. size?: number;
  53036. width?: number;
  53037. height?: number;
  53038. sideOrientation?: number;
  53039. frontUVs?: Vector4;
  53040. backUVs?: Vector4;
  53041. updatable?: boolean;
  53042. sourcePlane?: Plane;
  53043. }, scene?: Nullable<Scene>): Mesh;
  53044. /**
  53045. * Creates a ground mesh
  53046. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53047. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53049. * @param name defines the name of the mesh
  53050. * @param options defines the options used to create the mesh
  53051. * @param scene defines the hosting scene
  53052. * @returns the ground mesh
  53053. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53054. */
  53055. static CreateGround(name: string, options: {
  53056. width?: number;
  53057. height?: number;
  53058. subdivisions?: number;
  53059. subdivisionsX?: number;
  53060. subdivisionsY?: number;
  53061. updatable?: boolean;
  53062. }, scene?: Nullable<Scene>): Mesh;
  53063. /**
  53064. * Creates a tiled ground mesh
  53065. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53066. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53067. * * 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
  53068. * * 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
  53069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53070. * @param name defines the name of the mesh
  53071. * @param options defines the options used to create the mesh
  53072. * @param scene defines the hosting scene
  53073. * @returns the tiled ground mesh
  53074. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53075. */
  53076. static CreateTiledGround(name: string, options: {
  53077. xmin: number;
  53078. zmin: number;
  53079. xmax: number;
  53080. zmax: number;
  53081. subdivisions?: {
  53082. w: number;
  53083. h: number;
  53084. };
  53085. precision?: {
  53086. w: number;
  53087. h: number;
  53088. };
  53089. updatable?: boolean;
  53090. }, scene?: Nullable<Scene>): Mesh;
  53091. /**
  53092. * Creates a ground mesh from a height map
  53093. * * The parameter `url` sets the URL of the height map image resource.
  53094. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53095. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53096. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53097. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53098. * * 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.
  53099. * * 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).
  53100. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53102. * @param name defines the name of the mesh
  53103. * @param url defines the url to the height map
  53104. * @param options defines the options used to create the mesh
  53105. * @param scene defines the hosting scene
  53106. * @returns the ground mesh
  53107. * @see https://doc.babylonjs.com/babylon101/height_map
  53108. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53109. */
  53110. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53111. width?: number;
  53112. height?: number;
  53113. subdivisions?: number;
  53114. minHeight?: number;
  53115. maxHeight?: number;
  53116. colorFilter?: Color3;
  53117. alphaFilter?: number;
  53118. updatable?: boolean;
  53119. onReady?: (mesh: GroundMesh) => void;
  53120. }, scene?: Nullable<Scene>): GroundMesh;
  53121. /**
  53122. * Creates a polygon mesh
  53123. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53124. * * 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
  53125. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  53128. * * Remember you can only change the shape positions, not their number when updating a polygon
  53129. * @param name defines the name of the mesh
  53130. * @param options defines the options used to create the mesh
  53131. * @param scene defines the hosting scene
  53132. * @param earcutInjection can be used to inject your own earcut reference
  53133. * @returns the polygon mesh
  53134. */
  53135. static CreatePolygon(name: string, options: {
  53136. shape: Vector3[];
  53137. holes?: Vector3[][];
  53138. depth?: number;
  53139. faceUV?: Vector4[];
  53140. faceColors?: Color4[];
  53141. updatable?: boolean;
  53142. sideOrientation?: number;
  53143. frontUVs?: Vector4;
  53144. backUVs?: Vector4;
  53145. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53146. /**
  53147. * Creates an extruded polygon mesh, with depth in the Y direction.
  53148. * * 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)
  53149. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53150. * @param name defines the name of the mesh
  53151. * @param options defines the options used to create the mesh
  53152. * @param scene defines the hosting scene
  53153. * @param earcutInjection can be used to inject your own earcut reference
  53154. * @returns the polygon mesh
  53155. */
  53156. static ExtrudePolygon(name: string, options: {
  53157. shape: Vector3[];
  53158. holes?: Vector3[][];
  53159. depth?: number;
  53160. faceUV?: Vector4[];
  53161. faceColors?: Color4[];
  53162. updatable?: boolean;
  53163. sideOrientation?: number;
  53164. frontUVs?: Vector4;
  53165. backUVs?: Vector4;
  53166. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53167. /**
  53168. * Creates a tube mesh.
  53169. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53170. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53171. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53172. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53173. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53174. * * 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)
  53175. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53176. * * 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
  53177. * * 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
  53178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53180. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53182. * @param name defines the name of the mesh
  53183. * @param options defines the options used to create the mesh
  53184. * @param scene defines the hosting scene
  53185. * @returns the tube mesh
  53186. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53187. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53188. */
  53189. static CreateTube(name: string, options: {
  53190. path: Vector3[];
  53191. radius?: number;
  53192. tessellation?: number;
  53193. radiusFunction?: {
  53194. (i: number, distance: number): number;
  53195. };
  53196. cap?: number;
  53197. arc?: number;
  53198. updatable?: boolean;
  53199. sideOrientation?: number;
  53200. frontUVs?: Vector4;
  53201. backUVs?: Vector4;
  53202. instance?: Mesh;
  53203. invertUV?: boolean;
  53204. }, scene?: Nullable<Scene>): Mesh;
  53205. /**
  53206. * Creates a polyhedron mesh
  53207. * * 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
  53208. * * The parameter `size` (positive float, default 1) sets the polygon size
  53209. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53210. * * 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`
  53211. * * 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
  53212. * * 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)`)
  53213. * * 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
  53214. * * 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
  53215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53218. * @param name defines the name of the mesh
  53219. * @param options defines the options used to create the mesh
  53220. * @param scene defines the hosting scene
  53221. * @returns the polyhedron mesh
  53222. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53223. */
  53224. static CreatePolyhedron(name: string, options: {
  53225. type?: number;
  53226. size?: number;
  53227. sizeX?: number;
  53228. sizeY?: number;
  53229. sizeZ?: number;
  53230. custom?: any;
  53231. faceUV?: Vector4[];
  53232. faceColors?: Color4[];
  53233. flat?: boolean;
  53234. updatable?: boolean;
  53235. sideOrientation?: number;
  53236. frontUVs?: Vector4;
  53237. backUVs?: Vector4;
  53238. }, scene?: Nullable<Scene>): Mesh;
  53239. /**
  53240. * Creates a decal mesh.
  53241. * 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
  53242. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53243. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53244. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53245. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53246. * @param name defines the name of the mesh
  53247. * @param sourceMesh defines the mesh where the decal must be applied
  53248. * @param options defines the options used to create the mesh
  53249. * @param scene defines the hosting scene
  53250. * @returns the decal mesh
  53251. * @see https://doc.babylonjs.com/how_to/decals
  53252. */
  53253. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53254. position?: Vector3;
  53255. normal?: Vector3;
  53256. size?: Vector3;
  53257. angle?: number;
  53258. }): Mesh;
  53259. }
  53260. }
  53261. declare module "babylonjs/Meshes/meshSimplification" {
  53262. import { Mesh } from "babylonjs/Meshes/mesh";
  53263. /**
  53264. * A simplifier interface for future simplification implementations
  53265. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53266. */
  53267. export interface ISimplifier {
  53268. /**
  53269. * Simplification of a given mesh according to the given settings.
  53270. * Since this requires computation, it is assumed that the function runs async.
  53271. * @param settings The settings of the simplification, including quality and distance
  53272. * @param successCallback A callback that will be called after the mesh was simplified.
  53273. * @param errorCallback in case of an error, this callback will be called. optional.
  53274. */
  53275. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53276. }
  53277. /**
  53278. * Expected simplification settings.
  53279. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53280. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53281. */
  53282. export interface ISimplificationSettings {
  53283. /**
  53284. * Gets or sets the expected quality
  53285. */
  53286. quality: number;
  53287. /**
  53288. * Gets or sets the distance when this optimized version should be used
  53289. */
  53290. distance: number;
  53291. /**
  53292. * Gets an already optimized mesh
  53293. */
  53294. optimizeMesh?: boolean;
  53295. }
  53296. /**
  53297. * Class used to specify simplification options
  53298. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53299. */
  53300. export class SimplificationSettings implements ISimplificationSettings {
  53301. /** expected quality */
  53302. quality: number;
  53303. /** distance when this optimized version should be used */
  53304. distance: number;
  53305. /** already optimized mesh */
  53306. optimizeMesh?: boolean | undefined;
  53307. /**
  53308. * Creates a SimplificationSettings
  53309. * @param quality expected quality
  53310. * @param distance distance when this optimized version should be used
  53311. * @param optimizeMesh already optimized mesh
  53312. */
  53313. constructor(
  53314. /** expected quality */
  53315. quality: number,
  53316. /** distance when this optimized version should be used */
  53317. distance: number,
  53318. /** already optimized mesh */
  53319. optimizeMesh?: boolean | undefined);
  53320. }
  53321. /**
  53322. * Interface used to define a simplification task
  53323. */
  53324. export interface ISimplificationTask {
  53325. /**
  53326. * Array of settings
  53327. */
  53328. settings: Array<ISimplificationSettings>;
  53329. /**
  53330. * Simplification type
  53331. */
  53332. simplificationType: SimplificationType;
  53333. /**
  53334. * Mesh to simplify
  53335. */
  53336. mesh: Mesh;
  53337. /**
  53338. * Callback called on success
  53339. */
  53340. successCallback?: () => void;
  53341. /**
  53342. * Defines if parallel processing can be used
  53343. */
  53344. parallelProcessing: boolean;
  53345. }
  53346. /**
  53347. * Queue used to order the simplification tasks
  53348. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53349. */
  53350. export class SimplificationQueue {
  53351. private _simplificationArray;
  53352. /**
  53353. * Gets a boolean indicating that the process is still running
  53354. */
  53355. running: boolean;
  53356. /**
  53357. * Creates a new queue
  53358. */
  53359. constructor();
  53360. /**
  53361. * Adds a new simplification task
  53362. * @param task defines a task to add
  53363. */
  53364. addTask(task: ISimplificationTask): void;
  53365. /**
  53366. * Execute next task
  53367. */
  53368. executeNext(): void;
  53369. /**
  53370. * Execute a simplification task
  53371. * @param task defines the task to run
  53372. */
  53373. runSimplification(task: ISimplificationTask): void;
  53374. private getSimplifier;
  53375. }
  53376. /**
  53377. * The implemented types of simplification
  53378. * At the moment only Quadratic Error Decimation is implemented
  53379. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53380. */
  53381. export enum SimplificationType {
  53382. /** Quadratic error decimation */
  53383. QUADRATIC = 0
  53384. }
  53385. }
  53386. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53387. import { Scene } from "babylonjs/scene";
  53388. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53389. import { ISceneComponent } from "babylonjs/sceneComponent";
  53390. module "babylonjs/scene" {
  53391. interface Scene {
  53392. /** @hidden (Backing field) */
  53393. _simplificationQueue: SimplificationQueue;
  53394. /**
  53395. * Gets or sets the simplification queue attached to the scene
  53396. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53397. */
  53398. simplificationQueue: SimplificationQueue;
  53399. }
  53400. }
  53401. module "babylonjs/Meshes/mesh" {
  53402. interface Mesh {
  53403. /**
  53404. * Simplify the mesh according to the given array of settings.
  53405. * Function will return immediately and will simplify async
  53406. * @param settings a collection of simplification settings
  53407. * @param parallelProcessing should all levels calculate parallel or one after the other
  53408. * @param simplificationType the type of simplification to run
  53409. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53410. * @returns the current mesh
  53411. */
  53412. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53413. }
  53414. }
  53415. /**
  53416. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53417. * created in a scene
  53418. */
  53419. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53420. /**
  53421. * The component name helpfull to identify the component in the list of scene components.
  53422. */
  53423. readonly name: string;
  53424. /**
  53425. * The scene the component belongs to.
  53426. */
  53427. scene: Scene;
  53428. /**
  53429. * Creates a new instance of the component for the given scene
  53430. * @param scene Defines the scene to register the component in
  53431. */
  53432. constructor(scene: Scene);
  53433. /**
  53434. * Registers the component in a given scene
  53435. */
  53436. register(): void;
  53437. /**
  53438. * Rebuilds the elements related to this component in case of
  53439. * context lost for instance.
  53440. */
  53441. rebuild(): void;
  53442. /**
  53443. * Disposes the component and the associated ressources
  53444. */
  53445. dispose(): void;
  53446. private _beforeCameraUpdate;
  53447. }
  53448. }
  53449. declare module "babylonjs/Meshes/Builders/index" {
  53450. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53451. export * from "babylonjs/Meshes/Builders/discBuilder";
  53452. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53453. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53454. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53455. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53456. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53457. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53458. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53459. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53460. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53461. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53462. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53463. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53464. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53465. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53466. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53467. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53468. }
  53469. declare module "babylonjs/Meshes/index" {
  53470. export * from "babylonjs/Meshes/abstractMesh";
  53471. export * from "babylonjs/Meshes/buffer";
  53472. export * from "babylonjs/Meshes/Compression/index";
  53473. export * from "babylonjs/Meshes/csg";
  53474. export * from "babylonjs/Meshes/geometry";
  53475. export * from "babylonjs/Meshes/groundMesh";
  53476. export * from "babylonjs/Meshes/trailMesh";
  53477. export * from "babylonjs/Meshes/instancedMesh";
  53478. export * from "babylonjs/Meshes/linesMesh";
  53479. export * from "babylonjs/Meshes/mesh";
  53480. export * from "babylonjs/Meshes/mesh.vertexData";
  53481. export * from "babylonjs/Meshes/meshBuilder";
  53482. export * from "babylonjs/Meshes/meshSimplification";
  53483. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53484. export * from "babylonjs/Meshes/polygonMesh";
  53485. export * from "babylonjs/Meshes/subMesh";
  53486. export * from "babylonjs/Meshes/meshLODLevel";
  53487. export * from "babylonjs/Meshes/transformNode";
  53488. export * from "babylonjs/Meshes/Builders/index";
  53489. export * from "babylonjs/Meshes/dataBuffer";
  53490. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  53491. }
  53492. declare module "babylonjs/Morph/index" {
  53493. export * from "babylonjs/Morph/morphTarget";
  53494. export * from "babylonjs/Morph/morphTargetManager";
  53495. }
  53496. declare module "babylonjs/Offline/database" {
  53497. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53498. /**
  53499. * Class used to enable access to IndexedDB
  53500. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53501. */
  53502. export class Database implements IOfflineProvider {
  53503. private _callbackManifestChecked;
  53504. private _currentSceneUrl;
  53505. private _db;
  53506. private _enableSceneOffline;
  53507. private _enableTexturesOffline;
  53508. private _manifestVersionFound;
  53509. private _mustUpdateRessources;
  53510. private _hasReachedQuota;
  53511. private _isSupported;
  53512. private _idbFactory;
  53513. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53514. private static IsUASupportingBlobStorage;
  53515. /**
  53516. * Gets a boolean indicating if Database storate is enabled (off by default)
  53517. */
  53518. static IDBStorageEnabled: boolean;
  53519. /**
  53520. * Gets a boolean indicating if scene must be saved in the database
  53521. */
  53522. readonly enableSceneOffline: boolean;
  53523. /**
  53524. * Gets a boolean indicating if textures must be saved in the database
  53525. */
  53526. readonly enableTexturesOffline: boolean;
  53527. /**
  53528. * Creates a new Database
  53529. * @param urlToScene defines the url to load the scene
  53530. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53531. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53532. */
  53533. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53534. private static _ParseURL;
  53535. private static _ReturnFullUrlLocation;
  53536. private _checkManifestFile;
  53537. /**
  53538. * Open the database and make it available
  53539. * @param successCallback defines the callback to call on success
  53540. * @param errorCallback defines the callback to call on error
  53541. */
  53542. open(successCallback: () => void, errorCallback: () => void): void;
  53543. /**
  53544. * Loads an image from the database
  53545. * @param url defines the url to load from
  53546. * @param image defines the target DOM image
  53547. */
  53548. loadImage(url: string, image: HTMLImageElement): void;
  53549. private _loadImageFromDBAsync;
  53550. private _saveImageIntoDBAsync;
  53551. private _checkVersionFromDB;
  53552. private _loadVersionFromDBAsync;
  53553. private _saveVersionIntoDBAsync;
  53554. /**
  53555. * Loads a file from database
  53556. * @param url defines the URL to load from
  53557. * @param sceneLoaded defines a callback to call on success
  53558. * @param progressCallBack defines a callback to call when progress changed
  53559. * @param errorCallback defines a callback to call on error
  53560. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53561. */
  53562. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53563. private _loadFileAsync;
  53564. private _saveFileAsync;
  53565. /**
  53566. * Validates if xhr data is correct
  53567. * @param xhr defines the request to validate
  53568. * @param dataType defines the expected data type
  53569. * @returns true if data is correct
  53570. */
  53571. private static _ValidateXHRData;
  53572. }
  53573. }
  53574. declare module "babylonjs/Offline/index" {
  53575. export * from "babylonjs/Offline/database";
  53576. export * from "babylonjs/Offline/IOfflineProvider";
  53577. }
  53578. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53579. /** @hidden */
  53580. export var gpuUpdateParticlesPixelShader: {
  53581. name: string;
  53582. shader: string;
  53583. };
  53584. }
  53585. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53586. /** @hidden */
  53587. export var gpuUpdateParticlesVertexShader: {
  53588. name: string;
  53589. shader: string;
  53590. };
  53591. }
  53592. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53593. /** @hidden */
  53594. export var clipPlaneFragmentDeclaration2: {
  53595. name: string;
  53596. shader: string;
  53597. };
  53598. }
  53599. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53600. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53601. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53602. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53603. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53604. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53605. /** @hidden */
  53606. export var gpuRenderParticlesPixelShader: {
  53607. name: string;
  53608. shader: string;
  53609. };
  53610. }
  53611. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53612. /** @hidden */
  53613. export var clipPlaneVertexDeclaration2: {
  53614. name: string;
  53615. shader: string;
  53616. };
  53617. }
  53618. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53619. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53620. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53621. /** @hidden */
  53622. export var gpuRenderParticlesVertexShader: {
  53623. name: string;
  53624. shader: string;
  53625. };
  53626. }
  53627. declare module "babylonjs/Particles/gpuParticleSystem" {
  53628. import { Nullable } from "babylonjs/types";
  53629. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53630. import { Observable } from "babylonjs/Misc/observable";
  53631. import { Color4, Color3 } from "babylonjs/Maths/math";
  53632. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53633. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53634. import { Scene, IDisposable } from "babylonjs/scene";
  53635. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53636. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53637. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53638. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53639. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53640. /**
  53641. * This represents a GPU particle system in Babylon
  53642. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53643. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53644. */
  53645. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53646. /**
  53647. * The layer mask we are rendering the particles through.
  53648. */
  53649. layerMask: number;
  53650. private _capacity;
  53651. private _activeCount;
  53652. private _currentActiveCount;
  53653. private _accumulatedCount;
  53654. private _renderEffect;
  53655. private _updateEffect;
  53656. private _buffer0;
  53657. private _buffer1;
  53658. private _spriteBuffer;
  53659. private _updateVAO;
  53660. private _renderVAO;
  53661. private _targetIndex;
  53662. private _sourceBuffer;
  53663. private _targetBuffer;
  53664. private _engine;
  53665. private _currentRenderId;
  53666. private _started;
  53667. private _stopped;
  53668. private _timeDelta;
  53669. private _randomTexture;
  53670. private _randomTexture2;
  53671. private _attributesStrideSize;
  53672. private _updateEffectOptions;
  53673. private _randomTextureSize;
  53674. private _actualFrame;
  53675. private readonly _rawTextureWidth;
  53676. /**
  53677. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53678. */
  53679. static readonly IsSupported: boolean;
  53680. /**
  53681. * An event triggered when the system is disposed.
  53682. */
  53683. onDisposeObservable: Observable<GPUParticleSystem>;
  53684. /**
  53685. * Gets the maximum number of particles active at the same time.
  53686. * @returns The max number of active particles.
  53687. */
  53688. getCapacity(): number;
  53689. /**
  53690. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53691. * to override the particles.
  53692. */
  53693. forceDepthWrite: boolean;
  53694. /**
  53695. * Gets or set the number of active particles
  53696. */
  53697. activeParticleCount: number;
  53698. private _preWarmDone;
  53699. /**
  53700. * Is this system ready to be used/rendered
  53701. * @return true if the system is ready
  53702. */
  53703. isReady(): boolean;
  53704. /**
  53705. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53706. * @returns True if it has been started, otherwise false.
  53707. */
  53708. isStarted(): boolean;
  53709. /**
  53710. * Starts the particle system and begins to emit
  53711. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53712. */
  53713. start(delay?: number): void;
  53714. /**
  53715. * Stops the particle system.
  53716. */
  53717. stop(): void;
  53718. /**
  53719. * Remove all active particles
  53720. */
  53721. reset(): void;
  53722. /**
  53723. * Returns the string "GPUParticleSystem"
  53724. * @returns a string containing the class name
  53725. */
  53726. getClassName(): string;
  53727. private _colorGradientsTexture;
  53728. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53729. /**
  53730. * Adds a new color gradient
  53731. * @param gradient defines the gradient to use (between 0 and 1)
  53732. * @param color1 defines the color to affect to the specified gradient
  53733. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53734. * @returns the current particle system
  53735. */
  53736. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53737. /**
  53738. * Remove a specific color gradient
  53739. * @param gradient defines the gradient to remove
  53740. * @returns the current particle system
  53741. */
  53742. removeColorGradient(gradient: number): GPUParticleSystem;
  53743. private _angularSpeedGradientsTexture;
  53744. private _sizeGradientsTexture;
  53745. private _velocityGradientsTexture;
  53746. private _limitVelocityGradientsTexture;
  53747. private _dragGradientsTexture;
  53748. private _addFactorGradient;
  53749. /**
  53750. * Adds a new size gradient
  53751. * @param gradient defines the gradient to use (between 0 and 1)
  53752. * @param factor defines the size factor to affect to the specified gradient
  53753. * @returns the current particle system
  53754. */
  53755. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53756. /**
  53757. * Remove a specific size gradient
  53758. * @param gradient defines the gradient to remove
  53759. * @returns the current particle system
  53760. */
  53761. removeSizeGradient(gradient: number): GPUParticleSystem;
  53762. /**
  53763. * Adds a new angular speed gradient
  53764. * @param gradient defines the gradient to use (between 0 and 1)
  53765. * @param factor defines the angular speed to affect to the specified gradient
  53766. * @returns the current particle system
  53767. */
  53768. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53769. /**
  53770. * Remove a specific angular speed gradient
  53771. * @param gradient defines the gradient to remove
  53772. * @returns the current particle system
  53773. */
  53774. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53775. /**
  53776. * Adds a new velocity gradient
  53777. * @param gradient defines the gradient to use (between 0 and 1)
  53778. * @param factor defines the velocity to affect to the specified gradient
  53779. * @returns the current particle system
  53780. */
  53781. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53782. /**
  53783. * Remove a specific velocity gradient
  53784. * @param gradient defines the gradient to remove
  53785. * @returns the current particle system
  53786. */
  53787. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53788. /**
  53789. * Adds a new limit velocity gradient
  53790. * @param gradient defines the gradient to use (between 0 and 1)
  53791. * @param factor defines the limit velocity value to affect to the specified gradient
  53792. * @returns the current particle system
  53793. */
  53794. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53795. /**
  53796. * Remove a specific limit velocity gradient
  53797. * @param gradient defines the gradient to remove
  53798. * @returns the current particle system
  53799. */
  53800. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53801. /**
  53802. * Adds a new drag gradient
  53803. * @param gradient defines the gradient to use (between 0 and 1)
  53804. * @param factor defines the drag value to affect to the specified gradient
  53805. * @returns the current particle system
  53806. */
  53807. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53808. /**
  53809. * Remove a specific drag gradient
  53810. * @param gradient defines the gradient to remove
  53811. * @returns the current particle system
  53812. */
  53813. removeDragGradient(gradient: number): GPUParticleSystem;
  53814. /**
  53815. * Not supported by GPUParticleSystem
  53816. * @param gradient defines the gradient to use (between 0 and 1)
  53817. * @param factor defines the emit rate value to affect to the specified gradient
  53818. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53819. * @returns the current particle system
  53820. */
  53821. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53822. /**
  53823. * Not supported by GPUParticleSystem
  53824. * @param gradient defines the gradient to remove
  53825. * @returns the current particle system
  53826. */
  53827. removeEmitRateGradient(gradient: number): IParticleSystem;
  53828. /**
  53829. * Not supported by GPUParticleSystem
  53830. * @param gradient defines the gradient to use (between 0 and 1)
  53831. * @param factor defines the start size value to affect to the specified gradient
  53832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53833. * @returns the current particle system
  53834. */
  53835. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53836. /**
  53837. * Not supported by GPUParticleSystem
  53838. * @param gradient defines the gradient to remove
  53839. * @returns the current particle system
  53840. */
  53841. removeStartSizeGradient(gradient: number): IParticleSystem;
  53842. /**
  53843. * Not supported by GPUParticleSystem
  53844. * @param gradient defines the gradient to use (between 0 and 1)
  53845. * @param min defines the color remap minimal range
  53846. * @param max defines the color remap maximal range
  53847. * @returns the current particle system
  53848. */
  53849. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53850. /**
  53851. * Not supported by GPUParticleSystem
  53852. * @param gradient defines the gradient to remove
  53853. * @returns the current particle system
  53854. */
  53855. removeColorRemapGradient(): IParticleSystem;
  53856. /**
  53857. * Not supported by GPUParticleSystem
  53858. * @param gradient defines the gradient to use (between 0 and 1)
  53859. * @param min defines the alpha remap minimal range
  53860. * @param max defines the alpha remap maximal range
  53861. * @returns the current particle system
  53862. */
  53863. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53864. /**
  53865. * Not supported by GPUParticleSystem
  53866. * @param gradient defines the gradient to remove
  53867. * @returns the current particle system
  53868. */
  53869. removeAlphaRemapGradient(): IParticleSystem;
  53870. /**
  53871. * Not supported by GPUParticleSystem
  53872. * @param gradient defines the gradient to use (between 0 and 1)
  53873. * @param color defines the color to affect to the specified gradient
  53874. * @returns the current particle system
  53875. */
  53876. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53877. /**
  53878. * Not supported by GPUParticleSystem
  53879. * @param gradient defines the gradient to remove
  53880. * @returns the current particle system
  53881. */
  53882. removeRampGradient(): IParticleSystem;
  53883. /**
  53884. * Not supported by GPUParticleSystem
  53885. * @returns the list of ramp gradients
  53886. */
  53887. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53888. /**
  53889. * Not supported by GPUParticleSystem
  53890. * Gets or sets a boolean indicating that ramp gradients must be used
  53891. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53892. */
  53893. useRampGradients: boolean;
  53894. /**
  53895. * Not supported by GPUParticleSystem
  53896. * @param gradient defines the gradient to use (between 0 and 1)
  53897. * @param factor defines the life time factor to affect to the specified gradient
  53898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53899. * @returns the current particle system
  53900. */
  53901. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53902. /**
  53903. * Not supported by GPUParticleSystem
  53904. * @param gradient defines the gradient to remove
  53905. * @returns the current particle system
  53906. */
  53907. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53908. /**
  53909. * Instantiates a GPU particle system.
  53910. * 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.
  53911. * @param name The name of the particle system
  53912. * @param options The options used to create the system
  53913. * @param scene The scene the particle system belongs to
  53914. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53915. */
  53916. constructor(name: string, options: Partial<{
  53917. capacity: number;
  53918. randomTextureSize: number;
  53919. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53920. protected _reset(): void;
  53921. private _createUpdateVAO;
  53922. private _createRenderVAO;
  53923. private _initialize;
  53924. /** @hidden */
  53925. _recreateUpdateEffect(): void;
  53926. /** @hidden */
  53927. _recreateRenderEffect(): void;
  53928. /**
  53929. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53930. * @param preWarm defines if we are in the pre-warmimg phase
  53931. */
  53932. animate(preWarm?: boolean): void;
  53933. private _createFactorGradientTexture;
  53934. private _createSizeGradientTexture;
  53935. private _createAngularSpeedGradientTexture;
  53936. private _createVelocityGradientTexture;
  53937. private _createLimitVelocityGradientTexture;
  53938. private _createDragGradientTexture;
  53939. private _createColorGradientTexture;
  53940. /**
  53941. * Renders the particle system in its current state
  53942. * @param preWarm defines if the system should only update the particles but not render them
  53943. * @returns the current number of particles
  53944. */
  53945. render(preWarm?: boolean): number;
  53946. /**
  53947. * Rebuilds the particle system
  53948. */
  53949. rebuild(): void;
  53950. private _releaseBuffers;
  53951. private _releaseVAOs;
  53952. /**
  53953. * Disposes the particle system and free the associated resources
  53954. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53955. */
  53956. dispose(disposeTexture?: boolean): void;
  53957. /**
  53958. * Clones the particle system.
  53959. * @param name The name of the cloned object
  53960. * @param newEmitter The new emitter to use
  53961. * @returns the cloned particle system
  53962. */
  53963. clone(name: string, newEmitter: any): GPUParticleSystem;
  53964. /**
  53965. * Serializes the particle system to a JSON object.
  53966. * @returns the JSON object
  53967. */
  53968. serialize(): any;
  53969. /**
  53970. * Parses a JSON object to create a GPU particle system.
  53971. * @param parsedParticleSystem The JSON object to parse
  53972. * @param scene The scene to create the particle system in
  53973. * @param rootUrl The root url to use to load external dependencies like texture
  53974. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53975. * @returns the parsed GPU particle system
  53976. */
  53977. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53978. }
  53979. }
  53980. declare module "babylonjs/Particles/particleSystemSet" {
  53981. import { Nullable } from "babylonjs/types";
  53982. import { Color3 } from "babylonjs/Maths/math";
  53983. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53985. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53986. import { Scene, IDisposable } from "babylonjs/scene";
  53987. /**
  53988. * Represents a set of particle systems working together to create a specific effect
  53989. */
  53990. export class ParticleSystemSet implements IDisposable {
  53991. private _emitterCreationOptions;
  53992. private _emitterNode;
  53993. /**
  53994. * Gets the particle system list
  53995. */
  53996. systems: IParticleSystem[];
  53997. /**
  53998. * Gets the emitter node used with this set
  53999. */
  54000. readonly emitterNode: Nullable<TransformNode>;
  54001. /**
  54002. * Creates a new emitter mesh as a sphere
  54003. * @param options defines the options used to create the sphere
  54004. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54005. * @param scene defines the hosting scene
  54006. */
  54007. setEmitterAsSphere(options: {
  54008. diameter: number;
  54009. segments: number;
  54010. color: Color3;
  54011. }, renderingGroupId: number, scene: Scene): void;
  54012. /**
  54013. * Starts all particle systems of the set
  54014. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54015. */
  54016. start(emitter?: AbstractMesh): void;
  54017. /**
  54018. * Release all associated resources
  54019. */
  54020. dispose(): void;
  54021. /**
  54022. * Serialize the set into a JSON compatible object
  54023. * @returns a JSON compatible representation of the set
  54024. */
  54025. serialize(): any;
  54026. /**
  54027. * Parse a new ParticleSystemSet from a serialized source
  54028. * @param data defines a JSON compatible representation of the set
  54029. * @param scene defines the hosting scene
  54030. * @param gpu defines if we want GPU particles or CPU particles
  54031. * @returns a new ParticleSystemSet
  54032. */
  54033. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54034. }
  54035. }
  54036. declare module "babylonjs/Particles/particleHelper" {
  54037. import { Nullable } from "babylonjs/types";
  54038. import { Scene } from "babylonjs/scene";
  54039. import { Vector3 } from "babylonjs/Maths/math";
  54040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54041. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54042. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  54043. /**
  54044. * This class is made for on one-liner static method to help creating particle system set.
  54045. */
  54046. export class ParticleHelper {
  54047. /**
  54048. * Gets or sets base Assets URL
  54049. */
  54050. static BaseAssetsUrl: string;
  54051. /**
  54052. * Create a default particle system that you can tweak
  54053. * @param emitter defines the emitter to use
  54054. * @param capacity defines the system capacity (default is 500 particles)
  54055. * @param scene defines the hosting scene
  54056. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54057. * @returns the new Particle system
  54058. */
  54059. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54060. /**
  54061. * This is the main static method (one-liner) of this helper to create different particle systems
  54062. * @param type This string represents the type to the particle system to create
  54063. * @param scene The scene where the particle system should live
  54064. * @param gpu If the system will use gpu
  54065. * @returns the ParticleSystemSet created
  54066. */
  54067. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54068. /**
  54069. * Static function used to export a particle system to a ParticleSystemSet variable.
  54070. * Please note that the emitter shape is not exported
  54071. * @param systems defines the particle systems to export
  54072. * @returns the created particle system set
  54073. */
  54074. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54075. }
  54076. }
  54077. declare module "babylonjs/Particles/particleSystemComponent" {
  54078. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54079. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54080. import "babylonjs/Shaders/particles.vertex";
  54081. module "babylonjs/Engines/engine" {
  54082. interface Engine {
  54083. /**
  54084. * Create an effect to use with particle systems.
  54085. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54086. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54087. * @param uniformsNames defines a list of attribute names
  54088. * @param samplers defines an array of string used to represent textures
  54089. * @param defines defines the string containing the defines to use to compile the shaders
  54090. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54091. * @param onCompiled defines a function to call when the effect creation is successful
  54092. * @param onError defines a function to call when the effect creation has failed
  54093. * @returns the new Effect
  54094. */
  54095. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54096. }
  54097. }
  54098. module "babylonjs/Meshes/mesh" {
  54099. interface Mesh {
  54100. /**
  54101. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54102. * @returns an array of IParticleSystem
  54103. */
  54104. getEmittedParticleSystems(): IParticleSystem[];
  54105. /**
  54106. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54107. * @returns an array of IParticleSystem
  54108. */
  54109. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54110. }
  54111. }
  54112. /**
  54113. * @hidden
  54114. */
  54115. export var _IDoNeedToBeInTheBuild: number;
  54116. }
  54117. declare module "babylonjs/Particles/index" {
  54118. export * from "babylonjs/Particles/baseParticleSystem";
  54119. export * from "babylonjs/Particles/EmitterTypes/index";
  54120. export * from "babylonjs/Particles/gpuParticleSystem";
  54121. export * from "babylonjs/Particles/IParticleSystem";
  54122. export * from "babylonjs/Particles/particle";
  54123. export * from "babylonjs/Particles/particleHelper";
  54124. export * from "babylonjs/Particles/particleSystem";
  54125. export * from "babylonjs/Particles/particleSystemComponent";
  54126. export * from "babylonjs/Particles/particleSystemSet";
  54127. export * from "babylonjs/Particles/solidParticle";
  54128. export * from "babylonjs/Particles/solidParticleSystem";
  54129. export * from "babylonjs/Particles/subEmitter";
  54130. }
  54131. declare module "babylonjs/Physics/physicsEngineComponent" {
  54132. import { Nullable } from "babylonjs/types";
  54133. import { Observable, Observer } from "babylonjs/Misc/observable";
  54134. import { Vector3 } from "babylonjs/Maths/math";
  54135. import { Mesh } from "babylonjs/Meshes/mesh";
  54136. import { ISceneComponent } from "babylonjs/sceneComponent";
  54137. import { Scene } from "babylonjs/scene";
  54138. import { Node } from "babylonjs/node";
  54139. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54140. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54141. module "babylonjs/scene" {
  54142. interface Scene {
  54143. /** @hidden (Backing field) */
  54144. _physicsEngine: Nullable<IPhysicsEngine>;
  54145. /**
  54146. * Gets the current physics engine
  54147. * @returns a IPhysicsEngine or null if none attached
  54148. */
  54149. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54150. /**
  54151. * Enables physics to the current scene
  54152. * @param gravity defines the scene's gravity for the physics engine
  54153. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54154. * @return a boolean indicating if the physics engine was initialized
  54155. */
  54156. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54157. /**
  54158. * Disables and disposes the physics engine associated with the scene
  54159. */
  54160. disablePhysicsEngine(): void;
  54161. /**
  54162. * Gets a boolean indicating if there is an active physics engine
  54163. * @returns a boolean indicating if there is an active physics engine
  54164. */
  54165. isPhysicsEnabled(): boolean;
  54166. /**
  54167. * Deletes a physics compound impostor
  54168. * @param compound defines the compound to delete
  54169. */
  54170. deleteCompoundImpostor(compound: any): void;
  54171. /**
  54172. * An event triggered when physic simulation is about to be run
  54173. */
  54174. onBeforePhysicsObservable: Observable<Scene>;
  54175. /**
  54176. * An event triggered when physic simulation has been done
  54177. */
  54178. onAfterPhysicsObservable: Observable<Scene>;
  54179. }
  54180. }
  54181. module "babylonjs/Meshes/abstractMesh" {
  54182. interface AbstractMesh {
  54183. /** @hidden */
  54184. _physicsImpostor: Nullable<PhysicsImpostor>;
  54185. /**
  54186. * Gets or sets impostor used for physic simulation
  54187. * @see http://doc.babylonjs.com/features/physics_engine
  54188. */
  54189. physicsImpostor: Nullable<PhysicsImpostor>;
  54190. /**
  54191. * Gets the current physics impostor
  54192. * @see http://doc.babylonjs.com/features/physics_engine
  54193. * @returns a physics impostor or null
  54194. */
  54195. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54196. /** Apply a physic impulse to the mesh
  54197. * @param force defines the force to apply
  54198. * @param contactPoint defines where to apply the force
  54199. * @returns the current mesh
  54200. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54201. */
  54202. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54203. /**
  54204. * Creates a physic joint between two meshes
  54205. * @param otherMesh defines the other mesh to use
  54206. * @param pivot1 defines the pivot to use on this mesh
  54207. * @param pivot2 defines the pivot to use on the other mesh
  54208. * @param options defines additional options (can be plugin dependent)
  54209. * @returns the current mesh
  54210. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54211. */
  54212. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54213. /** @hidden */
  54214. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54215. }
  54216. }
  54217. /**
  54218. * Defines the physics engine scene component responsible to manage a physics engine
  54219. */
  54220. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54221. /**
  54222. * The component name helpful to identify the component in the list of scene components.
  54223. */
  54224. readonly name: string;
  54225. /**
  54226. * The scene the component belongs to.
  54227. */
  54228. scene: Scene;
  54229. /**
  54230. * Creates a new instance of the component for the given scene
  54231. * @param scene Defines the scene to register the component in
  54232. */
  54233. constructor(scene: Scene);
  54234. /**
  54235. * Registers the component in a given scene
  54236. */
  54237. register(): void;
  54238. /**
  54239. * Rebuilds the elements related to this component in case of
  54240. * context lost for instance.
  54241. */
  54242. rebuild(): void;
  54243. /**
  54244. * Disposes the component and the associated ressources
  54245. */
  54246. dispose(): void;
  54247. }
  54248. }
  54249. declare module "babylonjs/Physics/physicsHelper" {
  54250. import { Nullable } from "babylonjs/types";
  54251. import { Vector3 } from "babylonjs/Maths/math";
  54252. import { Mesh } from "babylonjs/Meshes/mesh";
  54253. import { Scene } from "babylonjs/scene";
  54254. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54255. /**
  54256. * A helper for physics simulations
  54257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54258. */
  54259. export class PhysicsHelper {
  54260. private _scene;
  54261. private _physicsEngine;
  54262. /**
  54263. * Initializes the Physics helper
  54264. * @param scene Babylon.js scene
  54265. */
  54266. constructor(scene: Scene);
  54267. /**
  54268. * Applies a radial explosion impulse
  54269. * @param origin the origin of the explosion
  54270. * @param radiusOrEventOptions the radius or the options of radial explosion
  54271. * @param strength the explosion strength
  54272. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54273. * @returns A physics radial explosion event, or null
  54274. */
  54275. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54276. /**
  54277. * Applies a radial explosion force
  54278. * @param origin the origin of the explosion
  54279. * @param radiusOrEventOptions the radius or the options of radial explosion
  54280. * @param strength the explosion strength
  54281. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54282. * @returns A physics radial explosion event, or null
  54283. */
  54284. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54285. /**
  54286. * Creates a gravitational field
  54287. * @param origin the origin of the explosion
  54288. * @param radiusOrEventOptions the radius or the options of radial explosion
  54289. * @param strength the explosion strength
  54290. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54291. * @returns A physics gravitational field event, or null
  54292. */
  54293. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54294. /**
  54295. * Creates a physics updraft event
  54296. * @param origin the origin of the updraft
  54297. * @param radiusOrEventOptions the radius or the options of the updraft
  54298. * @param strength the strength of the updraft
  54299. * @param height the height of the updraft
  54300. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54301. * @returns A physics updraft event, or null
  54302. */
  54303. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54304. /**
  54305. * Creates a physics vortex event
  54306. * @param origin the of the vortex
  54307. * @param radiusOrEventOptions the radius or the options of the vortex
  54308. * @param strength the strength of the vortex
  54309. * @param height the height of the vortex
  54310. * @returns a Physics vortex event, or null
  54311. * A physics vortex event or null
  54312. */
  54313. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54314. }
  54315. /**
  54316. * Represents a physics radial explosion event
  54317. */
  54318. class PhysicsRadialExplosionEvent {
  54319. private _scene;
  54320. private _options;
  54321. private _sphere;
  54322. private _dataFetched;
  54323. /**
  54324. * Initializes a radial explosioin event
  54325. * @param _scene BabylonJS scene
  54326. * @param _options The options for the vortex event
  54327. */
  54328. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54329. /**
  54330. * Returns the data related to the radial explosion event (sphere).
  54331. * @returns The radial explosion event data
  54332. */
  54333. getData(): PhysicsRadialExplosionEventData;
  54334. /**
  54335. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54336. * @param impostor A physics imposter
  54337. * @param origin the origin of the explosion
  54338. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54339. */
  54340. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54341. /**
  54342. * Triggers affecterd impostors callbacks
  54343. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54344. */
  54345. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54346. /**
  54347. * Disposes the sphere.
  54348. * @param force Specifies if the sphere should be disposed by force
  54349. */
  54350. dispose(force?: boolean): void;
  54351. /*** Helpers ***/
  54352. private _prepareSphere;
  54353. private _intersectsWithSphere;
  54354. }
  54355. /**
  54356. * Represents a gravitational field event
  54357. */
  54358. class PhysicsGravitationalFieldEvent {
  54359. private _physicsHelper;
  54360. private _scene;
  54361. private _origin;
  54362. private _options;
  54363. private _tickCallback;
  54364. private _sphere;
  54365. private _dataFetched;
  54366. /**
  54367. * Initializes the physics gravitational field event
  54368. * @param _physicsHelper A physics helper
  54369. * @param _scene BabylonJS scene
  54370. * @param _origin The origin position of the gravitational field event
  54371. * @param _options The options for the vortex event
  54372. */
  54373. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54374. /**
  54375. * Returns the data related to the gravitational field event (sphere).
  54376. * @returns A gravitational field event
  54377. */
  54378. getData(): PhysicsGravitationalFieldEventData;
  54379. /**
  54380. * Enables the gravitational field.
  54381. */
  54382. enable(): void;
  54383. /**
  54384. * Disables the gravitational field.
  54385. */
  54386. disable(): void;
  54387. /**
  54388. * Disposes the sphere.
  54389. * @param force The force to dispose from the gravitational field event
  54390. */
  54391. dispose(force?: boolean): void;
  54392. private _tick;
  54393. }
  54394. /**
  54395. * Represents a physics updraft event
  54396. */
  54397. class PhysicsUpdraftEvent {
  54398. private _scene;
  54399. private _origin;
  54400. private _options;
  54401. private _physicsEngine;
  54402. private _originTop;
  54403. private _originDirection;
  54404. private _tickCallback;
  54405. private _cylinder;
  54406. private _cylinderPosition;
  54407. private _dataFetched;
  54408. /**
  54409. * Initializes the physics updraft event
  54410. * @param _scene BabylonJS scene
  54411. * @param _origin The origin position of the updraft
  54412. * @param _options The options for the updraft event
  54413. */
  54414. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54415. /**
  54416. * Returns the data related to the updraft event (cylinder).
  54417. * @returns A physics updraft event
  54418. */
  54419. getData(): PhysicsUpdraftEventData;
  54420. /**
  54421. * Enables the updraft.
  54422. */
  54423. enable(): void;
  54424. /**
  54425. * Disables the updraft.
  54426. */
  54427. disable(): void;
  54428. /**
  54429. * Disposes the cylinder.
  54430. * @param force Specifies if the updraft should be disposed by force
  54431. */
  54432. dispose(force?: boolean): void;
  54433. private getImpostorHitData;
  54434. private _tick;
  54435. /*** Helpers ***/
  54436. private _prepareCylinder;
  54437. private _intersectsWithCylinder;
  54438. }
  54439. /**
  54440. * Represents a physics vortex event
  54441. */
  54442. class PhysicsVortexEvent {
  54443. private _scene;
  54444. private _origin;
  54445. private _options;
  54446. private _physicsEngine;
  54447. private _originTop;
  54448. private _tickCallback;
  54449. private _cylinder;
  54450. private _cylinderPosition;
  54451. private _dataFetched;
  54452. /**
  54453. * Initializes the physics vortex event
  54454. * @param _scene The BabylonJS scene
  54455. * @param _origin The origin position of the vortex
  54456. * @param _options The options for the vortex event
  54457. */
  54458. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54459. /**
  54460. * Returns the data related to the vortex event (cylinder).
  54461. * @returns The physics vortex event data
  54462. */
  54463. getData(): PhysicsVortexEventData;
  54464. /**
  54465. * Enables the vortex.
  54466. */
  54467. enable(): void;
  54468. /**
  54469. * Disables the cortex.
  54470. */
  54471. disable(): void;
  54472. /**
  54473. * Disposes the sphere.
  54474. * @param force
  54475. */
  54476. dispose(force?: boolean): void;
  54477. private getImpostorHitData;
  54478. private _tick;
  54479. /*** Helpers ***/
  54480. private _prepareCylinder;
  54481. private _intersectsWithCylinder;
  54482. }
  54483. /**
  54484. * Options fot the radial explosion event
  54485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54486. */
  54487. export class PhysicsRadialExplosionEventOptions {
  54488. /**
  54489. * The radius of the sphere for the radial explosion.
  54490. */
  54491. radius: number;
  54492. /**
  54493. * The strenth of the explosion.
  54494. */
  54495. strength: number;
  54496. /**
  54497. * The strenght of the force in correspondence to the distance of the affected object
  54498. */
  54499. falloff: PhysicsRadialImpulseFalloff;
  54500. /**
  54501. * Sphere options for the radial explosion.
  54502. */
  54503. sphere: {
  54504. segments: number;
  54505. diameter: number;
  54506. };
  54507. /**
  54508. * Sphere options for the radial explosion.
  54509. */
  54510. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54511. }
  54512. /**
  54513. * Options fot the updraft event
  54514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54515. */
  54516. export class PhysicsUpdraftEventOptions {
  54517. /**
  54518. * The radius of the cylinder for the vortex
  54519. */
  54520. radius: number;
  54521. /**
  54522. * The strenth of the updraft.
  54523. */
  54524. strength: number;
  54525. /**
  54526. * The height of the cylinder for the updraft.
  54527. */
  54528. height: number;
  54529. /**
  54530. * The mode for the the updraft.
  54531. */
  54532. updraftMode: PhysicsUpdraftMode;
  54533. }
  54534. /**
  54535. * Options fot the vortex event
  54536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54537. */
  54538. export class PhysicsVortexEventOptions {
  54539. /**
  54540. * The radius of the cylinder for the vortex
  54541. */
  54542. radius: number;
  54543. /**
  54544. * The strenth of the vortex.
  54545. */
  54546. strength: number;
  54547. /**
  54548. * The height of the cylinder for the vortex.
  54549. */
  54550. height: number;
  54551. /**
  54552. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54553. */
  54554. centripetalForceThreshold: number;
  54555. /**
  54556. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54557. */
  54558. centripetalForceMultiplier: number;
  54559. /**
  54560. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54561. */
  54562. centrifugalForceMultiplier: number;
  54563. /**
  54564. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54565. */
  54566. updraftForceMultiplier: number;
  54567. }
  54568. /**
  54569. * The strenght of the force in correspondence to the distance of the affected object
  54570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54571. */
  54572. export enum PhysicsRadialImpulseFalloff {
  54573. /** Defines that impulse is constant in strength across it's whole radius */
  54574. Constant = 0,
  54575. /** Defines that impulse gets weaker if it's further from the origin */
  54576. Linear = 1
  54577. }
  54578. /**
  54579. * The strength of the force in correspondence to the distance of the affected object
  54580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54581. */
  54582. export enum PhysicsUpdraftMode {
  54583. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54584. Center = 0,
  54585. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54586. Perpendicular = 1
  54587. }
  54588. /**
  54589. * Interface for a physics hit data
  54590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54591. */
  54592. export interface PhysicsHitData {
  54593. /**
  54594. * The force applied at the contact point
  54595. */
  54596. force: Vector3;
  54597. /**
  54598. * The contact point
  54599. */
  54600. contactPoint: Vector3;
  54601. /**
  54602. * The distance from the origin to the contact point
  54603. */
  54604. distanceFromOrigin: number;
  54605. }
  54606. /**
  54607. * Interface for radial explosion event data
  54608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54609. */
  54610. export interface PhysicsRadialExplosionEventData {
  54611. /**
  54612. * A sphere used for the radial explosion event
  54613. */
  54614. sphere: Mesh;
  54615. }
  54616. /**
  54617. * Interface for gravitational field event data
  54618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54619. */
  54620. export interface PhysicsGravitationalFieldEventData {
  54621. /**
  54622. * A sphere mesh used for the gravitational field event
  54623. */
  54624. sphere: Mesh;
  54625. }
  54626. /**
  54627. * Interface for updraft event data
  54628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54629. */
  54630. export interface PhysicsUpdraftEventData {
  54631. /**
  54632. * A cylinder used for the updraft event
  54633. */
  54634. cylinder: Mesh;
  54635. }
  54636. /**
  54637. * Interface for vortex event data
  54638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54639. */
  54640. export interface PhysicsVortexEventData {
  54641. /**
  54642. * A cylinder used for the vortex event
  54643. */
  54644. cylinder: Mesh;
  54645. }
  54646. /**
  54647. * Interface for an affected physics impostor
  54648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54649. */
  54650. export interface PhysicsAffectedImpostorWithData {
  54651. /**
  54652. * The impostor affected by the effect
  54653. */
  54654. impostor: PhysicsImpostor;
  54655. /**
  54656. * The data about the hit/horce from the explosion
  54657. */
  54658. hitData: PhysicsHitData;
  54659. }
  54660. }
  54661. declare module "babylonjs/Physics/Plugins/index" {
  54662. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54663. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54664. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54665. }
  54666. declare module "babylonjs/Physics/index" {
  54667. export * from "babylonjs/Physics/IPhysicsEngine";
  54668. export * from "babylonjs/Physics/physicsEngine";
  54669. export * from "babylonjs/Physics/physicsEngineComponent";
  54670. export * from "babylonjs/Physics/physicsHelper";
  54671. export * from "babylonjs/Physics/physicsImpostor";
  54672. export * from "babylonjs/Physics/physicsJoint";
  54673. export * from "babylonjs/Physics/Plugins/index";
  54674. }
  54675. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54676. /** @hidden */
  54677. export var blackAndWhitePixelShader: {
  54678. name: string;
  54679. shader: string;
  54680. };
  54681. }
  54682. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54683. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54684. import { Camera } from "babylonjs/Cameras/camera";
  54685. import { Engine } from "babylonjs/Engines/engine";
  54686. import "babylonjs/Shaders/blackAndWhite.fragment";
  54687. /**
  54688. * Post process used to render in black and white
  54689. */
  54690. export class BlackAndWhitePostProcess extends PostProcess {
  54691. /**
  54692. * Linear about to convert he result to black and white (default: 1)
  54693. */
  54694. degree: number;
  54695. /**
  54696. * Creates a black and white post process
  54697. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54698. * @param name The name of the effect.
  54699. * @param options The required width/height ratio to downsize to before computing the render pass.
  54700. * @param camera The camera to apply the render pass to.
  54701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54702. * @param engine The engine which the post process will be applied. (default: current engine)
  54703. * @param reusable If the post process can be reused on the same frame. (default: false)
  54704. */
  54705. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54706. }
  54707. }
  54708. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54709. import { Nullable } from "babylonjs/types";
  54710. import { Camera } from "babylonjs/Cameras/camera";
  54711. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54712. import { Engine } from "babylonjs/Engines/engine";
  54713. /**
  54714. * This represents a set of one or more post processes in Babylon.
  54715. * A post process can be used to apply a shader to a texture after it is rendered.
  54716. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54717. */
  54718. export class PostProcessRenderEffect {
  54719. private _postProcesses;
  54720. private _getPostProcesses;
  54721. private _singleInstance;
  54722. private _cameras;
  54723. private _indicesForCamera;
  54724. /**
  54725. * Name of the effect
  54726. * @hidden
  54727. */
  54728. _name: string;
  54729. /**
  54730. * Instantiates a post process render effect.
  54731. * A post process can be used to apply a shader to a texture after it is rendered.
  54732. * @param engine The engine the effect is tied to
  54733. * @param name The name of the effect
  54734. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54735. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54736. */
  54737. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54738. /**
  54739. * Checks if all the post processes in the effect are supported.
  54740. */
  54741. readonly isSupported: boolean;
  54742. /**
  54743. * Updates the current state of the effect
  54744. * @hidden
  54745. */
  54746. _update(): void;
  54747. /**
  54748. * Attaches the effect on cameras
  54749. * @param cameras The camera to attach to.
  54750. * @hidden
  54751. */
  54752. _attachCameras(cameras: Camera): void;
  54753. /**
  54754. * Attaches the effect on cameras
  54755. * @param cameras The camera to attach to.
  54756. * @hidden
  54757. */
  54758. _attachCameras(cameras: Camera[]): void;
  54759. /**
  54760. * Detaches the effect on cameras
  54761. * @param cameras The camera to detatch from.
  54762. * @hidden
  54763. */
  54764. _detachCameras(cameras: Camera): void;
  54765. /**
  54766. * Detatches the effect on cameras
  54767. * @param cameras The camera to detatch from.
  54768. * @hidden
  54769. */
  54770. _detachCameras(cameras: Camera[]): void;
  54771. /**
  54772. * Enables the effect on given cameras
  54773. * @param cameras The camera to enable.
  54774. * @hidden
  54775. */
  54776. _enable(cameras: Camera): void;
  54777. /**
  54778. * Enables the effect on given cameras
  54779. * @param cameras The camera to enable.
  54780. * @hidden
  54781. */
  54782. _enable(cameras: Nullable<Camera[]>): void;
  54783. /**
  54784. * Disables the effect on the given cameras
  54785. * @param cameras The camera to disable.
  54786. * @hidden
  54787. */
  54788. _disable(cameras: Camera): void;
  54789. /**
  54790. * Disables the effect on the given cameras
  54791. * @param cameras The camera to disable.
  54792. * @hidden
  54793. */
  54794. _disable(cameras: Nullable<Camera[]>): void;
  54795. /**
  54796. * Gets a list of the post processes contained in the effect.
  54797. * @param camera The camera to get the post processes on.
  54798. * @returns The list of the post processes in the effect.
  54799. */
  54800. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54801. }
  54802. }
  54803. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54804. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54805. /** @hidden */
  54806. export var extractHighlightsPixelShader: {
  54807. name: string;
  54808. shader: string;
  54809. };
  54810. }
  54811. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54812. import { Nullable } from "babylonjs/types";
  54813. import { Camera } from "babylonjs/Cameras/camera";
  54814. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54815. import { Engine } from "babylonjs/Engines/engine";
  54816. import "babylonjs/Shaders/extractHighlights.fragment";
  54817. /**
  54818. * 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.
  54819. */
  54820. export class ExtractHighlightsPostProcess extends PostProcess {
  54821. /**
  54822. * The luminance threshold, pixels below this value will be set to black.
  54823. */
  54824. threshold: number;
  54825. /** @hidden */
  54826. _exposure: number;
  54827. /**
  54828. * Post process which has the input texture to be used when performing highlight extraction
  54829. * @hidden
  54830. */
  54831. _inputPostProcess: Nullable<PostProcess>;
  54832. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54833. }
  54834. }
  54835. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54836. /** @hidden */
  54837. export var bloomMergePixelShader: {
  54838. name: string;
  54839. shader: string;
  54840. };
  54841. }
  54842. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54843. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54844. import { Nullable } from "babylonjs/types";
  54845. import { Engine } from "babylonjs/Engines/engine";
  54846. import { Camera } from "babylonjs/Cameras/camera";
  54847. import "babylonjs/Shaders/bloomMerge.fragment";
  54848. /**
  54849. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54850. */
  54851. export class BloomMergePostProcess extends PostProcess {
  54852. /** Weight of the bloom to be added to the original input. */
  54853. weight: number;
  54854. /**
  54855. * Creates a new instance of @see BloomMergePostProcess
  54856. * @param name The name of the effect.
  54857. * @param originalFromInput Post process which's input will be used for the merge.
  54858. * @param blurred Blurred highlights post process which's output will be used.
  54859. * @param weight Weight of the bloom to be added to the original input.
  54860. * @param options The required width/height ratio to downsize to before computing the render pass.
  54861. * @param camera The camera to apply the render pass to.
  54862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54863. * @param engine The engine which the post process will be applied. (default: current engine)
  54864. * @param reusable If the post process can be reused on the same frame. (default: false)
  54865. * @param textureType Type of textures used when performing the post process. (default: 0)
  54866. * @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)
  54867. */
  54868. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54869. /** Weight of the bloom to be added to the original input. */
  54870. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54871. }
  54872. }
  54873. declare module "babylonjs/PostProcesses/bloomEffect" {
  54874. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54875. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54876. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54877. import { Camera } from "babylonjs/Cameras/camera";
  54878. import { Scene } from "babylonjs/scene";
  54879. /**
  54880. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54881. */
  54882. export class BloomEffect extends PostProcessRenderEffect {
  54883. private bloomScale;
  54884. /**
  54885. * @hidden Internal
  54886. */
  54887. _effects: Array<PostProcess>;
  54888. /**
  54889. * @hidden Internal
  54890. */
  54891. _downscale: ExtractHighlightsPostProcess;
  54892. private _blurX;
  54893. private _blurY;
  54894. private _merge;
  54895. /**
  54896. * The luminance threshold to find bright areas of the image to bloom.
  54897. */
  54898. threshold: number;
  54899. /**
  54900. * The strength of the bloom.
  54901. */
  54902. weight: number;
  54903. /**
  54904. * Specifies the size of the bloom blur kernel, relative to the final output size
  54905. */
  54906. kernel: number;
  54907. /**
  54908. * Creates a new instance of @see BloomEffect
  54909. * @param scene The scene the effect belongs to.
  54910. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54911. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54912. * @param bloomWeight The the strength of bloom.
  54913. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54914. * @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)
  54915. */
  54916. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54917. /**
  54918. * Disposes each of the internal effects for a given camera.
  54919. * @param camera The camera to dispose the effect on.
  54920. */
  54921. disposeEffects(camera: Camera): void;
  54922. /**
  54923. * @hidden Internal
  54924. */
  54925. _updateEffects(): void;
  54926. /**
  54927. * Internal
  54928. * @returns if all the contained post processes are ready.
  54929. * @hidden
  54930. */
  54931. _isReady(): boolean;
  54932. }
  54933. }
  54934. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54935. /** @hidden */
  54936. export var chromaticAberrationPixelShader: {
  54937. name: string;
  54938. shader: string;
  54939. };
  54940. }
  54941. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54942. import { Vector2 } from "babylonjs/Maths/math";
  54943. import { Nullable } from "babylonjs/types";
  54944. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54945. import { Camera } from "babylonjs/Cameras/camera";
  54946. import { Engine } from "babylonjs/Engines/engine";
  54947. import "babylonjs/Shaders/chromaticAberration.fragment";
  54948. /**
  54949. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54950. */
  54951. export class ChromaticAberrationPostProcess extends PostProcess {
  54952. /**
  54953. * The amount of seperation of rgb channels (default: 30)
  54954. */
  54955. aberrationAmount: number;
  54956. /**
  54957. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54958. */
  54959. radialIntensity: number;
  54960. /**
  54961. * 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))
  54962. */
  54963. direction: Vector2;
  54964. /**
  54965. * 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))
  54966. */
  54967. centerPosition: Vector2;
  54968. /**
  54969. * Creates a new instance ChromaticAberrationPostProcess
  54970. * @param name The name of the effect.
  54971. * @param screenWidth The width of the screen to apply the effect on.
  54972. * @param screenHeight The height of the screen to apply the effect on.
  54973. * @param options The required width/height ratio to downsize to before computing the render pass.
  54974. * @param camera The camera to apply the render pass to.
  54975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54976. * @param engine The engine which the post process will be applied. (default: current engine)
  54977. * @param reusable If the post process can be reused on the same frame. (default: false)
  54978. * @param textureType Type of textures used when performing the post process. (default: 0)
  54979. * @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)
  54980. */
  54981. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54982. }
  54983. }
  54984. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54985. /** @hidden */
  54986. export var circleOfConfusionPixelShader: {
  54987. name: string;
  54988. shader: string;
  54989. };
  54990. }
  54991. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54992. import { Nullable } from "babylonjs/types";
  54993. import { Engine } from "babylonjs/Engines/engine";
  54994. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54995. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54996. import { Camera } from "babylonjs/Cameras/camera";
  54997. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54998. /**
  54999. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55000. */
  55001. export class CircleOfConfusionPostProcess extends PostProcess {
  55002. /**
  55003. * 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.
  55004. */
  55005. lensSize: number;
  55006. /**
  55007. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55008. */
  55009. fStop: number;
  55010. /**
  55011. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55012. */
  55013. focusDistance: number;
  55014. /**
  55015. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55016. */
  55017. focalLength: number;
  55018. private _depthTexture;
  55019. /**
  55020. * Creates a new instance CircleOfConfusionPostProcess
  55021. * @param name The name of the effect.
  55022. * @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.
  55023. * @param options The required width/height ratio to downsize to before computing the render pass.
  55024. * @param camera The camera to apply the render pass to.
  55025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55026. * @param engine The engine which the post process will be applied. (default: current engine)
  55027. * @param reusable If the post process can be reused on the same frame. (default: false)
  55028. * @param textureType Type of textures used when performing the post process. (default: 0)
  55029. * @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)
  55030. */
  55031. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55032. /**
  55033. * 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.
  55034. */
  55035. depthTexture: RenderTargetTexture;
  55036. }
  55037. }
  55038. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  55039. /** @hidden */
  55040. export var colorCorrectionPixelShader: {
  55041. name: string;
  55042. shader: string;
  55043. };
  55044. }
  55045. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  55046. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55047. import { Engine } from "babylonjs/Engines/engine";
  55048. import { Camera } from "babylonjs/Cameras/camera";
  55049. import "babylonjs/Shaders/colorCorrection.fragment";
  55050. /**
  55051. *
  55052. * This post-process allows the modification of rendered colors by using
  55053. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55054. *
  55055. * The object needs to be provided an url to a texture containing the color
  55056. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55057. * Use an image editing software to tweak the LUT to match your needs.
  55058. *
  55059. * For an example of a color LUT, see here:
  55060. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55061. * For explanations on color grading, see here:
  55062. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55063. *
  55064. */
  55065. export class ColorCorrectionPostProcess extends PostProcess {
  55066. private _colorTableTexture;
  55067. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55068. }
  55069. }
  55070. declare module "babylonjs/Shaders/convolution.fragment" {
  55071. /** @hidden */
  55072. export var convolutionPixelShader: {
  55073. name: string;
  55074. shader: string;
  55075. };
  55076. }
  55077. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  55078. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55079. import { Nullable } from "babylonjs/types";
  55080. import { Camera } from "babylonjs/Cameras/camera";
  55081. import { Engine } from "babylonjs/Engines/engine";
  55082. import "babylonjs/Shaders/convolution.fragment";
  55083. /**
  55084. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55085. * input texture to perform effects such as edge detection or sharpening
  55086. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55087. */
  55088. export class ConvolutionPostProcess extends PostProcess {
  55089. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55090. kernel: number[];
  55091. /**
  55092. * Creates a new instance ConvolutionPostProcess
  55093. * @param name The name of the effect.
  55094. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  55095. * @param options The required width/height ratio to downsize to before computing the render pass.
  55096. * @param camera The camera to apply the render pass to.
  55097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55098. * @param engine The engine which the post process will be applied. (default: current engine)
  55099. * @param reusable If the post process can be reused on the same frame. (default: false)
  55100. * @param textureType Type of textures used when performing the post process. (default: 0)
  55101. */
  55102. constructor(name: string,
  55103. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55104. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55105. /**
  55106. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55107. */
  55108. static EdgeDetect0Kernel: number[];
  55109. /**
  55110. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55111. */
  55112. static EdgeDetect1Kernel: number[];
  55113. /**
  55114. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55115. */
  55116. static EdgeDetect2Kernel: number[];
  55117. /**
  55118. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55119. */
  55120. static SharpenKernel: number[];
  55121. /**
  55122. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55123. */
  55124. static EmbossKernel: number[];
  55125. /**
  55126. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55127. */
  55128. static GaussianKernel: number[];
  55129. }
  55130. }
  55131. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  55132. import { Nullable } from "babylonjs/types";
  55133. import { Vector2 } from "babylonjs/Maths/math";
  55134. import { Camera } from "babylonjs/Cameras/camera";
  55135. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55136. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55137. import { Engine } from "babylonjs/Engines/engine";
  55138. import { Scene } from "babylonjs/scene";
  55139. /**
  55140. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55141. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55142. * based on samples that have a large difference in distance than the center pixel.
  55143. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55144. */
  55145. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55146. direction: Vector2;
  55147. /**
  55148. * Creates a new instance CircleOfConfusionPostProcess
  55149. * @param name The name of the effect.
  55150. * @param scene The scene the effect belongs to.
  55151. * @param direction The direction the blur should be applied.
  55152. * @param kernel The size of the kernel used to blur.
  55153. * @param options The required width/height ratio to downsize to before computing the render pass.
  55154. * @param camera The camera to apply the render pass to.
  55155. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55156. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55158. * @param engine The engine which the post process will be applied. (default: current engine)
  55159. * @param reusable If the post process can be reused on the same frame. (default: false)
  55160. * @param textureType Type of textures used when performing the post process. (default: 0)
  55161. * @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)
  55162. */
  55163. 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);
  55164. }
  55165. }
  55166. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  55167. /** @hidden */
  55168. export var depthOfFieldMergePixelShader: {
  55169. name: string;
  55170. shader: string;
  55171. };
  55172. }
  55173. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  55174. import { Nullable } from "babylonjs/types";
  55175. import { Camera } from "babylonjs/Cameras/camera";
  55176. import { Effect } from "babylonjs/Materials/effect";
  55177. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55178. import { Engine } from "babylonjs/Engines/engine";
  55179. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  55180. /**
  55181. * Options to be set when merging outputs from the default pipeline.
  55182. */
  55183. export class DepthOfFieldMergePostProcessOptions {
  55184. /**
  55185. * The original image to merge on top of
  55186. */
  55187. originalFromInput: PostProcess;
  55188. /**
  55189. * Parameters to perform the merge of the depth of field effect
  55190. */
  55191. depthOfField?: {
  55192. circleOfConfusion: PostProcess;
  55193. blurSteps: Array<PostProcess>;
  55194. };
  55195. /**
  55196. * Parameters to perform the merge of bloom effect
  55197. */
  55198. bloom?: {
  55199. blurred: PostProcess;
  55200. weight: number;
  55201. };
  55202. }
  55203. /**
  55204. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55205. */
  55206. export class DepthOfFieldMergePostProcess extends PostProcess {
  55207. private blurSteps;
  55208. /**
  55209. * Creates a new instance of DepthOfFieldMergePostProcess
  55210. * @param name The name of the effect.
  55211. * @param originalFromInput Post process which's input will be used for the merge.
  55212. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55213. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55214. * @param options The required width/height ratio to downsize to before computing the render pass.
  55215. * @param camera The camera to apply the render pass to.
  55216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55217. * @param engine The engine which the post process will be applied. (default: current engine)
  55218. * @param reusable If the post process can be reused on the same frame. (default: false)
  55219. * @param textureType Type of textures used when performing the post process. (default: 0)
  55220. * @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)
  55221. */
  55222. 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);
  55223. /**
  55224. * Updates the effect with the current post process compile time values and recompiles the shader.
  55225. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55226. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55227. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55228. * @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
  55229. * @param onCompiled Called when the shader has been compiled.
  55230. * @param onError Called if there is an error when compiling a shader.
  55231. */
  55232. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55233. }
  55234. }
  55235. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  55236. import { Nullable } from "babylonjs/types";
  55237. import { Camera } from "babylonjs/Cameras/camera";
  55238. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55239. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55240. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55241. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55242. import { Scene } from "babylonjs/scene";
  55243. /**
  55244. * Specifies the level of max blur that should be applied when using the depth of field effect
  55245. */
  55246. export enum DepthOfFieldEffectBlurLevel {
  55247. /**
  55248. * Subtle blur
  55249. */
  55250. Low = 0,
  55251. /**
  55252. * Medium blur
  55253. */
  55254. Medium = 1,
  55255. /**
  55256. * Large blur
  55257. */
  55258. High = 2
  55259. }
  55260. /**
  55261. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55262. */
  55263. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55264. private _circleOfConfusion;
  55265. /**
  55266. * @hidden Internal, blurs from high to low
  55267. */
  55268. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55269. private _depthOfFieldBlurY;
  55270. private _dofMerge;
  55271. /**
  55272. * @hidden Internal post processes in depth of field effect
  55273. */
  55274. _effects: Array<PostProcess>;
  55275. /**
  55276. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55277. */
  55278. focalLength: number;
  55279. /**
  55280. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55281. */
  55282. fStop: number;
  55283. /**
  55284. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55285. */
  55286. focusDistance: number;
  55287. /**
  55288. * 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.
  55289. */
  55290. lensSize: number;
  55291. /**
  55292. * Creates a new instance DepthOfFieldEffect
  55293. * @param scene The scene the effect belongs to.
  55294. * @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.
  55295. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55296. * @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)
  55297. */
  55298. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55299. /**
  55300. * Get the current class name of the current effet
  55301. * @returns "DepthOfFieldEffect"
  55302. */
  55303. getClassName(): string;
  55304. /**
  55305. * 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.
  55306. */
  55307. depthTexture: RenderTargetTexture;
  55308. /**
  55309. * Disposes each of the internal effects for a given camera.
  55310. * @param camera The camera to dispose the effect on.
  55311. */
  55312. disposeEffects(camera: Camera): void;
  55313. /**
  55314. * @hidden Internal
  55315. */
  55316. _updateEffects(): void;
  55317. /**
  55318. * Internal
  55319. * @returns if all the contained post processes are ready.
  55320. * @hidden
  55321. */
  55322. _isReady(): boolean;
  55323. }
  55324. }
  55325. declare module "babylonjs/Shaders/displayPass.fragment" {
  55326. /** @hidden */
  55327. export var displayPassPixelShader: {
  55328. name: string;
  55329. shader: string;
  55330. };
  55331. }
  55332. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55333. import { Nullable } from "babylonjs/types";
  55334. import { Camera } from "babylonjs/Cameras/camera";
  55335. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55336. import { Engine } from "babylonjs/Engines/engine";
  55337. import "babylonjs/Shaders/displayPass.fragment";
  55338. /**
  55339. * DisplayPassPostProcess which produces an output the same as it's input
  55340. */
  55341. export class DisplayPassPostProcess extends PostProcess {
  55342. /**
  55343. * Creates the DisplayPassPostProcess
  55344. * @param name The name of the effect.
  55345. * @param options The required width/height ratio to downsize to before computing the render pass.
  55346. * @param camera The camera to apply the render pass to.
  55347. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55348. * @param engine The engine which the post process will be applied. (default: current engine)
  55349. * @param reusable If the post process can be reused on the same frame. (default: false)
  55350. */
  55351. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55352. }
  55353. }
  55354. declare module "babylonjs/Shaders/filter.fragment" {
  55355. /** @hidden */
  55356. export var filterPixelShader: {
  55357. name: string;
  55358. shader: string;
  55359. };
  55360. }
  55361. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55362. import { Nullable } from "babylonjs/types";
  55363. import { Matrix } from "babylonjs/Maths/math";
  55364. import { Camera } from "babylonjs/Cameras/camera";
  55365. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55366. import { Engine } from "babylonjs/Engines/engine";
  55367. import "babylonjs/Shaders/filter.fragment";
  55368. /**
  55369. * Applies a kernel filter to the image
  55370. */
  55371. export class FilterPostProcess extends PostProcess {
  55372. /** The matrix to be applied to the image */
  55373. kernelMatrix: Matrix;
  55374. /**
  55375. *
  55376. * @param name The name of the effect.
  55377. * @param kernelMatrix The matrix to be applied to the image
  55378. * @param options The required width/height ratio to downsize to before computing the render pass.
  55379. * @param camera The camera to apply the render pass to.
  55380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55381. * @param engine The engine which the post process will be applied. (default: current engine)
  55382. * @param reusable If the post process can be reused on the same frame. (default: false)
  55383. */
  55384. constructor(name: string,
  55385. /** The matrix to be applied to the image */
  55386. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55387. }
  55388. }
  55389. declare module "babylonjs/Shaders/fxaa.fragment" {
  55390. /** @hidden */
  55391. export var fxaaPixelShader: {
  55392. name: string;
  55393. shader: string;
  55394. };
  55395. }
  55396. declare module "babylonjs/Shaders/fxaa.vertex" {
  55397. /** @hidden */
  55398. export var fxaaVertexShader: {
  55399. name: string;
  55400. shader: string;
  55401. };
  55402. }
  55403. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55404. import { Nullable } from "babylonjs/types";
  55405. import { Camera } from "babylonjs/Cameras/camera";
  55406. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55407. import { Engine } from "babylonjs/Engines/engine";
  55408. import "babylonjs/Shaders/fxaa.fragment";
  55409. import "babylonjs/Shaders/fxaa.vertex";
  55410. /**
  55411. * Fxaa post process
  55412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55413. */
  55414. export class FxaaPostProcess extends PostProcess {
  55415. /** @hidden */
  55416. texelWidth: number;
  55417. /** @hidden */
  55418. texelHeight: number;
  55419. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55420. private _getDefines;
  55421. }
  55422. }
  55423. declare module "babylonjs/Shaders/grain.fragment" {
  55424. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55425. /** @hidden */
  55426. export var grainPixelShader: {
  55427. name: string;
  55428. shader: string;
  55429. };
  55430. }
  55431. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55432. import { Nullable } from "babylonjs/types";
  55433. import { Camera } from "babylonjs/Cameras/camera";
  55434. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55435. import { Engine } from "babylonjs/Engines/engine";
  55436. import "babylonjs/Shaders/grain.fragment";
  55437. /**
  55438. * The GrainPostProcess adds noise to the image at mid luminance levels
  55439. */
  55440. export class GrainPostProcess extends PostProcess {
  55441. /**
  55442. * The intensity of the grain added (default: 30)
  55443. */
  55444. intensity: number;
  55445. /**
  55446. * If the grain should be randomized on every frame
  55447. */
  55448. animated: boolean;
  55449. /**
  55450. * Creates a new instance of @see GrainPostProcess
  55451. * @param name The name of the effect.
  55452. * @param options The required width/height ratio to downsize to before computing the render pass.
  55453. * @param camera The camera to apply the render pass to.
  55454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55455. * @param engine The engine which the post process will be applied. (default: current engine)
  55456. * @param reusable If the post process can be reused on the same frame. (default: false)
  55457. * @param textureType Type of textures used when performing the post process. (default: 0)
  55458. * @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)
  55459. */
  55460. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55461. }
  55462. }
  55463. declare module "babylonjs/Shaders/highlights.fragment" {
  55464. /** @hidden */
  55465. export var highlightsPixelShader: {
  55466. name: string;
  55467. shader: string;
  55468. };
  55469. }
  55470. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55471. import { Nullable } from "babylonjs/types";
  55472. import { Camera } from "babylonjs/Cameras/camera";
  55473. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55474. import { Engine } from "babylonjs/Engines/engine";
  55475. import "babylonjs/Shaders/highlights.fragment";
  55476. /**
  55477. * Extracts highlights from the image
  55478. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55479. */
  55480. export class HighlightsPostProcess extends PostProcess {
  55481. /**
  55482. * Extracts highlights from the image
  55483. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55484. * @param name The name of the effect.
  55485. * @param options The required width/height ratio to downsize to before computing the render pass.
  55486. * @param camera The camera to apply the render pass to.
  55487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55488. * @param engine The engine which the post process will be applied. (default: current engine)
  55489. * @param reusable If the post process can be reused on the same frame. (default: false)
  55490. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55491. */
  55492. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55493. }
  55494. }
  55495. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55496. /** @hidden */
  55497. export var mrtFragmentDeclaration: {
  55498. name: string;
  55499. shader: string;
  55500. };
  55501. }
  55502. declare module "babylonjs/Shaders/geometry.fragment" {
  55503. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55504. /** @hidden */
  55505. export var geometryPixelShader: {
  55506. name: string;
  55507. shader: string;
  55508. };
  55509. }
  55510. declare module "babylonjs/Shaders/geometry.vertex" {
  55511. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55512. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55513. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55514. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55515. /** @hidden */
  55516. export var geometryVertexShader: {
  55517. name: string;
  55518. shader: string;
  55519. };
  55520. }
  55521. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55522. import { Matrix } from "babylonjs/Maths/math";
  55523. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55524. import { Mesh } from "babylonjs/Meshes/mesh";
  55525. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55526. import { Effect } from "babylonjs/Materials/effect";
  55527. import { Scene } from "babylonjs/scene";
  55528. import "babylonjs/Shaders/geometry.fragment";
  55529. import "babylonjs/Shaders/geometry.vertex";
  55530. /**
  55531. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55532. */
  55533. export class GeometryBufferRenderer {
  55534. /**
  55535. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55536. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55537. */
  55538. static readonly POSITION_TEXTURE_TYPE: number;
  55539. /**
  55540. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55541. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55542. */
  55543. static readonly VELOCITY_TEXTURE_TYPE: number;
  55544. /**
  55545. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55546. * in order to compute objects velocities when enableVelocity is set to "true"
  55547. * @hidden
  55548. */
  55549. _previousTransformationMatrices: {
  55550. [index: number]: Matrix;
  55551. };
  55552. private _scene;
  55553. private _multiRenderTarget;
  55554. private _ratio;
  55555. private _enablePosition;
  55556. private _enableVelocity;
  55557. private _positionIndex;
  55558. private _velocityIndex;
  55559. protected _effect: Effect;
  55560. protected _cachedDefines: string;
  55561. /**
  55562. * Set the render list (meshes to be rendered) used in the G buffer.
  55563. */
  55564. renderList: Mesh[];
  55565. /**
  55566. * Gets wether or not G buffer are supported by the running hardware.
  55567. * This requires draw buffer supports
  55568. */
  55569. readonly isSupported: boolean;
  55570. /**
  55571. * Returns the index of the given texture type in the G-Buffer textures array
  55572. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55573. * @returns the index of the given texture type in the G-Buffer textures array
  55574. */
  55575. getTextureIndex(textureType: number): number;
  55576. /**
  55577. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55578. */
  55579. /**
  55580. * Sets whether or not objects positions are enabled for the G buffer.
  55581. */
  55582. enablePosition: boolean;
  55583. /**
  55584. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55585. */
  55586. /**
  55587. * Sets wether or not objects velocities are enabled for the G buffer.
  55588. */
  55589. enableVelocity: boolean;
  55590. /**
  55591. * Gets the scene associated with the buffer.
  55592. */
  55593. readonly scene: Scene;
  55594. /**
  55595. * Gets the ratio used by the buffer during its creation.
  55596. * How big is the buffer related to the main canvas.
  55597. */
  55598. readonly ratio: number;
  55599. /** @hidden */
  55600. static _SceneComponentInitialization: (scene: Scene) => void;
  55601. /**
  55602. * Creates a new G Buffer for the scene
  55603. * @param scene The scene the buffer belongs to
  55604. * @param ratio How big is the buffer related to the main canvas.
  55605. */
  55606. constructor(scene: Scene, ratio?: number);
  55607. /**
  55608. * Checks wether everything is ready to render a submesh to the G buffer.
  55609. * @param subMesh the submesh to check readiness for
  55610. * @param useInstances is the mesh drawn using instance or not
  55611. * @returns true if ready otherwise false
  55612. */
  55613. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55614. /**
  55615. * Gets the current underlying G Buffer.
  55616. * @returns the buffer
  55617. */
  55618. getGBuffer(): MultiRenderTarget;
  55619. /**
  55620. * Gets the number of samples used to render the buffer (anti aliasing).
  55621. */
  55622. /**
  55623. * Sets the number of samples used to render the buffer (anti aliasing).
  55624. */
  55625. samples: number;
  55626. /**
  55627. * Disposes the renderer and frees up associated resources.
  55628. */
  55629. dispose(): void;
  55630. protected _createRenderTargets(): void;
  55631. }
  55632. }
  55633. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55634. import { Nullable } from "babylonjs/types";
  55635. import { Scene } from "babylonjs/scene";
  55636. import { ISceneComponent } from "babylonjs/sceneComponent";
  55637. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55638. module "babylonjs/scene" {
  55639. interface Scene {
  55640. /** @hidden (Backing field) */
  55641. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55642. /**
  55643. * Gets or Sets the current geometry buffer associated to the scene.
  55644. */
  55645. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55646. /**
  55647. * Enables a GeometryBufferRender and associates it with the scene
  55648. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55649. * @returns the GeometryBufferRenderer
  55650. */
  55651. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55652. /**
  55653. * Disables the GeometryBufferRender associated with the scene
  55654. */
  55655. disableGeometryBufferRenderer(): void;
  55656. }
  55657. }
  55658. /**
  55659. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55660. * in several rendering techniques.
  55661. */
  55662. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55663. /**
  55664. * The component name helpful to identify the component in the list of scene components.
  55665. */
  55666. readonly name: string;
  55667. /**
  55668. * The scene the component belongs to.
  55669. */
  55670. scene: Scene;
  55671. /**
  55672. * Creates a new instance of the component for the given scene
  55673. * @param scene Defines the scene to register the component in
  55674. */
  55675. constructor(scene: Scene);
  55676. /**
  55677. * Registers the component in a given scene
  55678. */
  55679. register(): void;
  55680. /**
  55681. * Rebuilds the elements related to this component in case of
  55682. * context lost for instance.
  55683. */
  55684. rebuild(): void;
  55685. /**
  55686. * Disposes the component and the associated ressources
  55687. */
  55688. dispose(): void;
  55689. private _gatherRenderTargets;
  55690. }
  55691. }
  55692. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55693. /** @hidden */
  55694. export var motionBlurPixelShader: {
  55695. name: string;
  55696. shader: string;
  55697. };
  55698. }
  55699. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55700. import { Nullable } from "babylonjs/types";
  55701. import { Camera } from "babylonjs/Cameras/camera";
  55702. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55703. import { Scene } from "babylonjs/scene";
  55704. import "babylonjs/Animations/animatable";
  55705. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55706. import "babylonjs/Shaders/motionBlur.fragment";
  55707. import { Engine } from "babylonjs/Engines/engine";
  55708. /**
  55709. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55710. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55711. * As an example, all you have to do is to create the post-process:
  55712. * var mb = new BABYLON.MotionBlurPostProcess(
  55713. * 'mb', // The name of the effect.
  55714. * scene, // The scene containing the objects to blur according to their velocity.
  55715. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55716. * camera // The camera to apply the render pass to.
  55717. * );
  55718. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55719. */
  55720. export class MotionBlurPostProcess extends PostProcess {
  55721. /**
  55722. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55723. */
  55724. motionStrength: number;
  55725. /**
  55726. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55727. */
  55728. /**
  55729. * Sets the number of iterations to be used for motion blur quality
  55730. */
  55731. motionBlurSamples: number;
  55732. private _motionBlurSamples;
  55733. private _geometryBufferRenderer;
  55734. /**
  55735. * Creates a new instance MotionBlurPostProcess
  55736. * @param name The name of the effect.
  55737. * @param scene The scene containing the objects to blur according to their velocity.
  55738. * @param options The required width/height ratio to downsize to before computing the render pass.
  55739. * @param camera The camera to apply the render pass to.
  55740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55741. * @param engine The engine which the post process will be applied. (default: current engine)
  55742. * @param reusable If the post process can be reused on the same frame. (default: false)
  55743. * @param textureType Type of textures used when performing the post process. (default: 0)
  55744. * @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)
  55745. */
  55746. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55747. /**
  55748. * Disposes the post process.
  55749. * @param camera The camera to dispose the post process on.
  55750. */
  55751. dispose(camera?: Camera): void;
  55752. }
  55753. }
  55754. declare module "babylonjs/Shaders/refraction.fragment" {
  55755. /** @hidden */
  55756. export var refractionPixelShader: {
  55757. name: string;
  55758. shader: string;
  55759. };
  55760. }
  55761. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55762. import { Color3 } from "babylonjs/Maths/math";
  55763. import { Camera } from "babylonjs/Cameras/camera";
  55764. import { Texture } from "babylonjs/Materials/Textures/texture";
  55765. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55766. import { Engine } from "babylonjs/Engines/engine";
  55767. import "babylonjs/Shaders/refraction.fragment";
  55768. /**
  55769. * Post process which applies a refractin texture
  55770. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55771. */
  55772. export class RefractionPostProcess extends PostProcess {
  55773. /** the base color of the refraction (used to taint the rendering) */
  55774. color: Color3;
  55775. /** simulated refraction depth */
  55776. depth: number;
  55777. /** the coefficient of the base color (0 to remove base color tainting) */
  55778. colorLevel: number;
  55779. private _refTexture;
  55780. private _ownRefractionTexture;
  55781. /**
  55782. * Gets or sets the refraction texture
  55783. * Please note that you are responsible for disposing the texture if you set it manually
  55784. */
  55785. refractionTexture: Texture;
  55786. /**
  55787. * Initializes the RefractionPostProcess
  55788. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55789. * @param name The name of the effect.
  55790. * @param refractionTextureUrl Url of the refraction texture to use
  55791. * @param color the base color of the refraction (used to taint the rendering)
  55792. * @param depth simulated refraction depth
  55793. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55794. * @param camera The camera to apply the render pass to.
  55795. * @param options The required width/height ratio to downsize to before computing the render pass.
  55796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55797. * @param engine The engine which the post process will be applied. (default: current engine)
  55798. * @param reusable If the post process can be reused on the same frame. (default: false)
  55799. */
  55800. constructor(name: string, refractionTextureUrl: string,
  55801. /** the base color of the refraction (used to taint the rendering) */
  55802. color: Color3,
  55803. /** simulated refraction depth */
  55804. depth: number,
  55805. /** the coefficient of the base color (0 to remove base color tainting) */
  55806. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55807. /**
  55808. * Disposes of the post process
  55809. * @param camera Camera to dispose post process on
  55810. */
  55811. dispose(camera: Camera): void;
  55812. }
  55813. }
  55814. declare module "babylonjs/Shaders/sharpen.fragment" {
  55815. /** @hidden */
  55816. export var sharpenPixelShader: {
  55817. name: string;
  55818. shader: string;
  55819. };
  55820. }
  55821. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55822. import { Nullable } from "babylonjs/types";
  55823. import { Camera } from "babylonjs/Cameras/camera";
  55824. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55825. import "babylonjs/Shaders/sharpen.fragment";
  55826. import { Engine } from "babylonjs/Engines/engine";
  55827. /**
  55828. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55829. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55830. */
  55831. export class SharpenPostProcess extends PostProcess {
  55832. /**
  55833. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55834. */
  55835. colorAmount: number;
  55836. /**
  55837. * How much sharpness should be applied (default: 0.3)
  55838. */
  55839. edgeAmount: number;
  55840. /**
  55841. * Creates a new instance ConvolutionPostProcess
  55842. * @param name The name of the effect.
  55843. * @param options The required width/height ratio to downsize to before computing the render pass.
  55844. * @param camera The camera to apply the render pass to.
  55845. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55846. * @param engine The engine which the post process will be applied. (default: current engine)
  55847. * @param reusable If the post process can be reused on the same frame. (default: false)
  55848. * @param textureType Type of textures used when performing the post process. (default: 0)
  55849. * @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)
  55850. */
  55851. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55852. }
  55853. }
  55854. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55855. import { Nullable } from "babylonjs/types";
  55856. import { Camera } from "babylonjs/Cameras/camera";
  55857. import { Engine } from "babylonjs/Engines/engine";
  55858. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55859. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55860. /**
  55861. * PostProcessRenderPipeline
  55862. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55863. */
  55864. export class PostProcessRenderPipeline {
  55865. private engine;
  55866. private _renderEffects;
  55867. private _renderEffectsForIsolatedPass;
  55868. /**
  55869. * List of inspectable custom properties (used by the Inspector)
  55870. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55871. */
  55872. inspectableCustomProperties: IInspectable[];
  55873. /**
  55874. * @hidden
  55875. */
  55876. protected _cameras: Camera[];
  55877. /** @hidden */
  55878. _name: string;
  55879. /**
  55880. * Gets pipeline name
  55881. */
  55882. readonly name: string;
  55883. /**
  55884. * Initializes a PostProcessRenderPipeline
  55885. * @param engine engine to add the pipeline to
  55886. * @param name name of the pipeline
  55887. */
  55888. constructor(engine: Engine, name: string);
  55889. /**
  55890. * Gets the class name
  55891. * @returns "PostProcessRenderPipeline"
  55892. */
  55893. getClassName(): string;
  55894. /**
  55895. * If all the render effects in the pipeline are supported
  55896. */
  55897. readonly isSupported: boolean;
  55898. /**
  55899. * Adds an effect to the pipeline
  55900. * @param renderEffect the effect to add
  55901. */
  55902. addEffect(renderEffect: PostProcessRenderEffect): void;
  55903. /** @hidden */
  55904. _rebuild(): void;
  55905. /** @hidden */
  55906. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55907. /** @hidden */
  55908. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55909. /** @hidden */
  55910. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55911. /** @hidden */
  55912. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55913. /** @hidden */
  55914. _attachCameras(cameras: Camera, unique: boolean): void;
  55915. /** @hidden */
  55916. _attachCameras(cameras: Camera[], unique: boolean): void;
  55917. /** @hidden */
  55918. _detachCameras(cameras: Camera): void;
  55919. /** @hidden */
  55920. _detachCameras(cameras: Nullable<Camera[]>): void;
  55921. /** @hidden */
  55922. _update(): void;
  55923. /** @hidden */
  55924. _reset(): void;
  55925. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55926. /**
  55927. * Disposes of the pipeline
  55928. */
  55929. dispose(): void;
  55930. }
  55931. }
  55932. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55933. import { Camera } from "babylonjs/Cameras/camera";
  55934. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55935. /**
  55936. * PostProcessRenderPipelineManager class
  55937. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55938. */
  55939. export class PostProcessRenderPipelineManager {
  55940. private _renderPipelines;
  55941. /**
  55942. * Initializes a PostProcessRenderPipelineManager
  55943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55944. */
  55945. constructor();
  55946. /**
  55947. * Gets the list of supported render pipelines
  55948. */
  55949. readonly supportedPipelines: PostProcessRenderPipeline[];
  55950. /**
  55951. * Adds a pipeline to the manager
  55952. * @param renderPipeline The pipeline to add
  55953. */
  55954. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55955. /**
  55956. * Attaches a camera to the pipeline
  55957. * @param renderPipelineName The name of the pipeline to attach to
  55958. * @param cameras the camera to attach
  55959. * @param unique if the camera can be attached multiple times to the pipeline
  55960. */
  55961. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55962. /**
  55963. * Detaches a camera from the pipeline
  55964. * @param renderPipelineName The name of the pipeline to detach from
  55965. * @param cameras the camera to detach
  55966. */
  55967. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55968. /**
  55969. * Enables an effect by name on a pipeline
  55970. * @param renderPipelineName the name of the pipeline to enable the effect in
  55971. * @param renderEffectName the name of the effect to enable
  55972. * @param cameras the cameras that the effect should be enabled on
  55973. */
  55974. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55975. /**
  55976. * Disables an effect by name on a pipeline
  55977. * @param renderPipelineName the name of the pipeline to disable the effect in
  55978. * @param renderEffectName the name of the effect to disable
  55979. * @param cameras the cameras that the effect should be disabled on
  55980. */
  55981. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55982. /**
  55983. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55984. */
  55985. update(): void;
  55986. /** @hidden */
  55987. _rebuild(): void;
  55988. /**
  55989. * Disposes of the manager and pipelines
  55990. */
  55991. dispose(): void;
  55992. }
  55993. }
  55994. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55995. import { ISceneComponent } from "babylonjs/sceneComponent";
  55996. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55997. import { Scene } from "babylonjs/scene";
  55998. module "babylonjs/scene" {
  55999. interface Scene {
  56000. /** @hidden (Backing field) */
  56001. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56002. /**
  56003. * Gets the postprocess render pipeline manager
  56004. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56005. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56006. */
  56007. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56008. }
  56009. }
  56010. /**
  56011. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56012. */
  56013. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56014. /**
  56015. * The component name helpfull to identify the component in the list of scene components.
  56016. */
  56017. readonly name: string;
  56018. /**
  56019. * The scene the component belongs to.
  56020. */
  56021. scene: Scene;
  56022. /**
  56023. * Creates a new instance of the component for the given scene
  56024. * @param scene Defines the scene to register the component in
  56025. */
  56026. constructor(scene: Scene);
  56027. /**
  56028. * Registers the component in a given scene
  56029. */
  56030. register(): void;
  56031. /**
  56032. * Rebuilds the elements related to this component in case of
  56033. * context lost for instance.
  56034. */
  56035. rebuild(): void;
  56036. /**
  56037. * Disposes the component and the associated ressources
  56038. */
  56039. dispose(): void;
  56040. private _gatherRenderTargets;
  56041. }
  56042. }
  56043. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  56044. import { IAnimatable } from "babylonjs/Misc/tools";
  56045. import { Camera } from "babylonjs/Cameras/camera";
  56046. import { IDisposable } from "babylonjs/scene";
  56047. import { Scene } from "babylonjs/scene";
  56048. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  56049. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56050. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56051. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  56052. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56053. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56054. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  56055. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56056. import { Animation } from "babylonjs/Animations/animation";
  56057. /**
  56058. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56059. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56060. */
  56061. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56062. private _scene;
  56063. private _camerasToBeAttached;
  56064. /**
  56065. * ID of the sharpen post process,
  56066. */
  56067. private readonly SharpenPostProcessId;
  56068. /**
  56069. * @ignore
  56070. * ID of the image processing post process;
  56071. */
  56072. readonly ImageProcessingPostProcessId: string;
  56073. /**
  56074. * @ignore
  56075. * ID of the Fast Approximate Anti-Aliasing post process;
  56076. */
  56077. readonly FxaaPostProcessId: string;
  56078. /**
  56079. * ID of the chromatic aberration post process,
  56080. */
  56081. private readonly ChromaticAberrationPostProcessId;
  56082. /**
  56083. * ID of the grain post process
  56084. */
  56085. private readonly GrainPostProcessId;
  56086. /**
  56087. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56088. */
  56089. sharpen: SharpenPostProcess;
  56090. private _sharpenEffect;
  56091. private bloom;
  56092. /**
  56093. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56094. */
  56095. depthOfField: DepthOfFieldEffect;
  56096. /**
  56097. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56098. */
  56099. fxaa: FxaaPostProcess;
  56100. /**
  56101. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56102. */
  56103. imageProcessing: ImageProcessingPostProcess;
  56104. /**
  56105. * Chromatic aberration post process which will shift rgb colors in the image
  56106. */
  56107. chromaticAberration: ChromaticAberrationPostProcess;
  56108. private _chromaticAberrationEffect;
  56109. /**
  56110. * Grain post process which add noise to the image
  56111. */
  56112. grain: GrainPostProcess;
  56113. private _grainEffect;
  56114. /**
  56115. * Glow post process which adds a glow to emissive areas of the image
  56116. */
  56117. private _glowLayer;
  56118. /**
  56119. * Animations which can be used to tweak settings over a period of time
  56120. */
  56121. animations: Animation[];
  56122. private _imageProcessingConfigurationObserver;
  56123. private _sharpenEnabled;
  56124. private _bloomEnabled;
  56125. private _depthOfFieldEnabled;
  56126. private _depthOfFieldBlurLevel;
  56127. private _fxaaEnabled;
  56128. private _imageProcessingEnabled;
  56129. private _defaultPipelineTextureType;
  56130. private _bloomScale;
  56131. private _chromaticAberrationEnabled;
  56132. private _grainEnabled;
  56133. private _buildAllowed;
  56134. /**
  56135. * Gets active scene
  56136. */
  56137. readonly scene: Scene;
  56138. /**
  56139. * Enable or disable the sharpen process from the pipeline
  56140. */
  56141. sharpenEnabled: boolean;
  56142. private _resizeObserver;
  56143. private _hardwareScaleLevel;
  56144. private _bloomKernel;
  56145. /**
  56146. * Specifies the size of the bloom blur kernel, relative to the final output size
  56147. */
  56148. bloomKernel: number;
  56149. /**
  56150. * Specifies the weight of the bloom in the final rendering
  56151. */
  56152. private _bloomWeight;
  56153. /**
  56154. * Specifies the luma threshold for the area that will be blurred by the bloom
  56155. */
  56156. private _bloomThreshold;
  56157. private _hdr;
  56158. /**
  56159. * The strength of the bloom.
  56160. */
  56161. bloomWeight: number;
  56162. /**
  56163. * The strength of the bloom.
  56164. */
  56165. bloomThreshold: number;
  56166. /**
  56167. * The scale of the bloom, lower value will provide better performance.
  56168. */
  56169. bloomScale: number;
  56170. /**
  56171. * Enable or disable the bloom from the pipeline
  56172. */
  56173. bloomEnabled: boolean;
  56174. private _rebuildBloom;
  56175. /**
  56176. * If the depth of field is enabled.
  56177. */
  56178. depthOfFieldEnabled: boolean;
  56179. /**
  56180. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56181. */
  56182. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56183. /**
  56184. * If the anti aliasing is enabled.
  56185. */
  56186. fxaaEnabled: boolean;
  56187. private _samples;
  56188. /**
  56189. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56190. */
  56191. samples: number;
  56192. /**
  56193. * If image processing is enabled.
  56194. */
  56195. imageProcessingEnabled: boolean;
  56196. /**
  56197. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56198. */
  56199. glowLayerEnabled: boolean;
  56200. /**
  56201. * Enable or disable the chromaticAberration process from the pipeline
  56202. */
  56203. chromaticAberrationEnabled: boolean;
  56204. /**
  56205. * Enable or disable the grain process from the pipeline
  56206. */
  56207. grainEnabled: boolean;
  56208. /**
  56209. * @constructor
  56210. * @param name - The rendering pipeline name (default: "")
  56211. * @param hdr - If high dynamic range textures should be used (default: true)
  56212. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56213. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56214. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56215. */
  56216. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56217. /**
  56218. * Get the class name
  56219. * @returns "DefaultRenderingPipeline"
  56220. */
  56221. getClassName(): string;
  56222. /**
  56223. * Force the compilation of the entire pipeline.
  56224. */
  56225. prepare(): void;
  56226. private _hasCleared;
  56227. private _prevPostProcess;
  56228. private _prevPrevPostProcess;
  56229. private _setAutoClearAndTextureSharing;
  56230. private _depthOfFieldSceneObserver;
  56231. private _buildPipeline;
  56232. private _disposePostProcesses;
  56233. /**
  56234. * Adds a camera to the pipeline
  56235. * @param camera the camera to be added
  56236. */
  56237. addCamera(camera: Camera): void;
  56238. /**
  56239. * Removes a camera from the pipeline
  56240. * @param camera the camera to remove
  56241. */
  56242. removeCamera(camera: Camera): void;
  56243. /**
  56244. * Dispose of the pipeline and stop all post processes
  56245. */
  56246. dispose(): void;
  56247. /**
  56248. * Serialize the rendering pipeline (Used when exporting)
  56249. * @returns the serialized object
  56250. */
  56251. serialize(): any;
  56252. /**
  56253. * Parse the serialized pipeline
  56254. * @param source Source pipeline.
  56255. * @param scene The scene to load the pipeline to.
  56256. * @param rootUrl The URL of the serialized pipeline.
  56257. * @returns An instantiated pipeline from the serialized object.
  56258. */
  56259. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56260. }
  56261. }
  56262. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  56263. /** @hidden */
  56264. export var lensHighlightsPixelShader: {
  56265. name: string;
  56266. shader: string;
  56267. };
  56268. }
  56269. declare module "babylonjs/Shaders/depthOfField.fragment" {
  56270. /** @hidden */
  56271. export var depthOfFieldPixelShader: {
  56272. name: string;
  56273. shader: string;
  56274. };
  56275. }
  56276. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  56277. import { Camera } from "babylonjs/Cameras/camera";
  56278. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56279. import { Scene } from "babylonjs/scene";
  56280. import "babylonjs/Shaders/chromaticAberration.fragment";
  56281. import "babylonjs/Shaders/lensHighlights.fragment";
  56282. import "babylonjs/Shaders/depthOfField.fragment";
  56283. /**
  56284. * BABYLON.JS Chromatic Aberration GLSL Shader
  56285. * Author: Olivier Guyot
  56286. * Separates very slightly R, G and B colors on the edges of the screen
  56287. * Inspired by Francois Tarlier & Martins Upitis
  56288. */
  56289. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56290. /**
  56291. * @ignore
  56292. * The chromatic aberration PostProcess id in the pipeline
  56293. */
  56294. LensChromaticAberrationEffect: string;
  56295. /**
  56296. * @ignore
  56297. * The highlights enhancing PostProcess id in the pipeline
  56298. */
  56299. HighlightsEnhancingEffect: string;
  56300. /**
  56301. * @ignore
  56302. * The depth-of-field PostProcess id in the pipeline
  56303. */
  56304. LensDepthOfFieldEffect: string;
  56305. private _scene;
  56306. private _depthTexture;
  56307. private _grainTexture;
  56308. private _chromaticAberrationPostProcess;
  56309. private _highlightsPostProcess;
  56310. private _depthOfFieldPostProcess;
  56311. private _edgeBlur;
  56312. private _grainAmount;
  56313. private _chromaticAberration;
  56314. private _distortion;
  56315. private _highlightsGain;
  56316. private _highlightsThreshold;
  56317. private _dofDistance;
  56318. private _dofAperture;
  56319. private _dofDarken;
  56320. private _dofPentagon;
  56321. private _blurNoise;
  56322. /**
  56323. * @constructor
  56324. *
  56325. * Effect parameters are as follow:
  56326. * {
  56327. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56328. * edge_blur: number; // from 0 to x (1 for realism)
  56329. * distortion: number; // from 0 to x (1 for realism)
  56330. * grain_amount: number; // from 0 to 1
  56331. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56332. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56333. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56334. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56335. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56336. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56337. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56338. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56339. * }
  56340. * Note: if an effect parameter is unset, effect is disabled
  56341. *
  56342. * @param name The rendering pipeline name
  56343. * @param parameters - An object containing all parameters (see above)
  56344. * @param scene The scene linked to this pipeline
  56345. * @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)
  56346. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56347. */
  56348. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56349. /**
  56350. * Get the class name
  56351. * @returns "LensRenderingPipeline"
  56352. */
  56353. getClassName(): string;
  56354. /**
  56355. * Gets associated scene
  56356. */
  56357. readonly scene: Scene;
  56358. /**
  56359. * Gets or sets the edge blur
  56360. */
  56361. edgeBlur: number;
  56362. /**
  56363. * Gets or sets the grain amount
  56364. */
  56365. grainAmount: number;
  56366. /**
  56367. * Gets or sets the chromatic aberration amount
  56368. */
  56369. chromaticAberration: number;
  56370. /**
  56371. * Gets or sets the depth of field aperture
  56372. */
  56373. dofAperture: number;
  56374. /**
  56375. * Gets or sets the edge distortion
  56376. */
  56377. edgeDistortion: number;
  56378. /**
  56379. * Gets or sets the depth of field distortion
  56380. */
  56381. dofDistortion: number;
  56382. /**
  56383. * Gets or sets the darken out of focus amount
  56384. */
  56385. darkenOutOfFocus: number;
  56386. /**
  56387. * Gets or sets a boolean indicating if blur noise is enabled
  56388. */
  56389. blurNoise: boolean;
  56390. /**
  56391. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56392. */
  56393. pentagonBokeh: boolean;
  56394. /**
  56395. * Gets or sets the highlight grain amount
  56396. */
  56397. highlightsGain: number;
  56398. /**
  56399. * Gets or sets the highlight threshold
  56400. */
  56401. highlightsThreshold: number;
  56402. /**
  56403. * Sets the amount of blur at the edges
  56404. * @param amount blur amount
  56405. */
  56406. setEdgeBlur(amount: number): void;
  56407. /**
  56408. * Sets edge blur to 0
  56409. */
  56410. disableEdgeBlur(): void;
  56411. /**
  56412. * Sets the amout of grain
  56413. * @param amount Amount of grain
  56414. */
  56415. setGrainAmount(amount: number): void;
  56416. /**
  56417. * Set grain amount to 0
  56418. */
  56419. disableGrain(): void;
  56420. /**
  56421. * Sets the chromatic aberration amount
  56422. * @param amount amount of chromatic aberration
  56423. */
  56424. setChromaticAberration(amount: number): void;
  56425. /**
  56426. * Sets chromatic aberration amount to 0
  56427. */
  56428. disableChromaticAberration(): void;
  56429. /**
  56430. * Sets the EdgeDistortion amount
  56431. * @param amount amount of EdgeDistortion
  56432. */
  56433. setEdgeDistortion(amount: number): void;
  56434. /**
  56435. * Sets edge distortion to 0
  56436. */
  56437. disableEdgeDistortion(): void;
  56438. /**
  56439. * Sets the FocusDistance amount
  56440. * @param amount amount of FocusDistance
  56441. */
  56442. setFocusDistance(amount: number): void;
  56443. /**
  56444. * Disables depth of field
  56445. */
  56446. disableDepthOfField(): void;
  56447. /**
  56448. * Sets the Aperture amount
  56449. * @param amount amount of Aperture
  56450. */
  56451. setAperture(amount: number): void;
  56452. /**
  56453. * Sets the DarkenOutOfFocus amount
  56454. * @param amount amount of DarkenOutOfFocus
  56455. */
  56456. setDarkenOutOfFocus(amount: number): void;
  56457. private _pentagonBokehIsEnabled;
  56458. /**
  56459. * Creates a pentagon bokeh effect
  56460. */
  56461. enablePentagonBokeh(): void;
  56462. /**
  56463. * Disables the pentagon bokeh effect
  56464. */
  56465. disablePentagonBokeh(): void;
  56466. /**
  56467. * Enables noise blur
  56468. */
  56469. enableNoiseBlur(): void;
  56470. /**
  56471. * Disables noise blur
  56472. */
  56473. disableNoiseBlur(): void;
  56474. /**
  56475. * Sets the HighlightsGain amount
  56476. * @param amount amount of HighlightsGain
  56477. */
  56478. setHighlightsGain(amount: number): void;
  56479. /**
  56480. * Sets the HighlightsThreshold amount
  56481. * @param amount amount of HighlightsThreshold
  56482. */
  56483. setHighlightsThreshold(amount: number): void;
  56484. /**
  56485. * Disables highlights
  56486. */
  56487. disableHighlights(): void;
  56488. /**
  56489. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56490. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56491. */
  56492. dispose(disableDepthRender?: boolean): void;
  56493. private _createChromaticAberrationPostProcess;
  56494. private _createHighlightsPostProcess;
  56495. private _createDepthOfFieldPostProcess;
  56496. private _createGrainTexture;
  56497. }
  56498. }
  56499. declare module "babylonjs/Shaders/ssao2.fragment" {
  56500. /** @hidden */
  56501. export var ssao2PixelShader: {
  56502. name: string;
  56503. shader: string;
  56504. };
  56505. }
  56506. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56507. /** @hidden */
  56508. export var ssaoCombinePixelShader: {
  56509. name: string;
  56510. shader: string;
  56511. };
  56512. }
  56513. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56514. import { Camera } from "babylonjs/Cameras/camera";
  56515. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56516. import { Scene } from "babylonjs/scene";
  56517. import "babylonjs/Shaders/ssao2.fragment";
  56518. import "babylonjs/Shaders/ssaoCombine.fragment";
  56519. /**
  56520. * Render pipeline to produce ssao effect
  56521. */
  56522. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56523. /**
  56524. * @ignore
  56525. * The PassPostProcess id in the pipeline that contains the original scene color
  56526. */
  56527. SSAOOriginalSceneColorEffect: string;
  56528. /**
  56529. * @ignore
  56530. * The SSAO PostProcess id in the pipeline
  56531. */
  56532. SSAORenderEffect: string;
  56533. /**
  56534. * @ignore
  56535. * The horizontal blur PostProcess id in the pipeline
  56536. */
  56537. SSAOBlurHRenderEffect: string;
  56538. /**
  56539. * @ignore
  56540. * The vertical blur PostProcess id in the pipeline
  56541. */
  56542. SSAOBlurVRenderEffect: string;
  56543. /**
  56544. * @ignore
  56545. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56546. */
  56547. SSAOCombineRenderEffect: string;
  56548. /**
  56549. * The output strength of the SSAO post-process. Default value is 1.0.
  56550. */
  56551. totalStrength: number;
  56552. /**
  56553. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56554. */
  56555. maxZ: number;
  56556. /**
  56557. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56558. */
  56559. minZAspect: number;
  56560. private _samples;
  56561. /**
  56562. * Number of samples used for the SSAO calculations. Default value is 8
  56563. */
  56564. samples: number;
  56565. private _textureSamples;
  56566. /**
  56567. * Number of samples to use for antialiasing
  56568. */
  56569. textureSamples: number;
  56570. /**
  56571. * Ratio object used for SSAO ratio and blur ratio
  56572. */
  56573. private _ratio;
  56574. /**
  56575. * Dynamically generated sphere sampler.
  56576. */
  56577. private _sampleSphere;
  56578. /**
  56579. * Blur filter offsets
  56580. */
  56581. private _samplerOffsets;
  56582. private _expensiveBlur;
  56583. /**
  56584. * If bilateral blur should be used
  56585. */
  56586. expensiveBlur: boolean;
  56587. /**
  56588. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56589. */
  56590. radius: number;
  56591. /**
  56592. * The base color of the SSAO post-process
  56593. * The final result is "base + ssao" between [0, 1]
  56594. */
  56595. base: number;
  56596. /**
  56597. * Support test.
  56598. */
  56599. static readonly IsSupported: boolean;
  56600. private _scene;
  56601. private _depthTexture;
  56602. private _normalTexture;
  56603. private _randomTexture;
  56604. private _originalColorPostProcess;
  56605. private _ssaoPostProcess;
  56606. private _blurHPostProcess;
  56607. private _blurVPostProcess;
  56608. private _ssaoCombinePostProcess;
  56609. private _firstUpdate;
  56610. /**
  56611. * Gets active scene
  56612. */
  56613. readonly scene: Scene;
  56614. /**
  56615. * @constructor
  56616. * @param name The rendering pipeline name
  56617. * @param scene The scene linked to this pipeline
  56618. * @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 }
  56619. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56620. */
  56621. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56622. /**
  56623. * Get the class name
  56624. * @returns "SSAO2RenderingPipeline"
  56625. */
  56626. getClassName(): string;
  56627. /**
  56628. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56629. */
  56630. dispose(disableGeometryBufferRenderer?: boolean): void;
  56631. private _createBlurPostProcess;
  56632. /** @hidden */
  56633. _rebuild(): void;
  56634. private _bits;
  56635. private _radicalInverse_VdC;
  56636. private _hammersley;
  56637. private _hemisphereSample_uniform;
  56638. private _generateHemisphere;
  56639. private _createSSAOPostProcess;
  56640. private _createSSAOCombinePostProcess;
  56641. private _createRandomTexture;
  56642. /**
  56643. * Serialize the rendering pipeline (Used when exporting)
  56644. * @returns the serialized object
  56645. */
  56646. serialize(): any;
  56647. /**
  56648. * Parse the serialized pipeline
  56649. * @param source Source pipeline.
  56650. * @param scene The scene to load the pipeline to.
  56651. * @param rootUrl The URL of the serialized pipeline.
  56652. * @returns An instantiated pipeline from the serialized object.
  56653. */
  56654. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56655. }
  56656. }
  56657. declare module "babylonjs/Shaders/ssao.fragment" {
  56658. /** @hidden */
  56659. export var ssaoPixelShader: {
  56660. name: string;
  56661. shader: string;
  56662. };
  56663. }
  56664. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56665. import { Camera } from "babylonjs/Cameras/camera";
  56666. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56667. import { Scene } from "babylonjs/scene";
  56668. import "babylonjs/Shaders/ssao.fragment";
  56669. import "babylonjs/Shaders/ssaoCombine.fragment";
  56670. /**
  56671. * Render pipeline to produce ssao effect
  56672. */
  56673. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56674. /**
  56675. * @ignore
  56676. * The PassPostProcess id in the pipeline that contains the original scene color
  56677. */
  56678. SSAOOriginalSceneColorEffect: string;
  56679. /**
  56680. * @ignore
  56681. * The SSAO PostProcess id in the pipeline
  56682. */
  56683. SSAORenderEffect: string;
  56684. /**
  56685. * @ignore
  56686. * The horizontal blur PostProcess id in the pipeline
  56687. */
  56688. SSAOBlurHRenderEffect: string;
  56689. /**
  56690. * @ignore
  56691. * The vertical blur PostProcess id in the pipeline
  56692. */
  56693. SSAOBlurVRenderEffect: string;
  56694. /**
  56695. * @ignore
  56696. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56697. */
  56698. SSAOCombineRenderEffect: string;
  56699. /**
  56700. * The output strength of the SSAO post-process. Default value is 1.0.
  56701. */
  56702. totalStrength: number;
  56703. /**
  56704. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56705. */
  56706. radius: number;
  56707. /**
  56708. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56709. * Must not be equal to fallOff and superior to fallOff.
  56710. * Default value is 0.0075
  56711. */
  56712. area: number;
  56713. /**
  56714. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56715. * Must not be equal to area and inferior to area.
  56716. * Default value is 0.000001
  56717. */
  56718. fallOff: number;
  56719. /**
  56720. * The base color of the SSAO post-process
  56721. * The final result is "base + ssao" between [0, 1]
  56722. */
  56723. base: number;
  56724. private _scene;
  56725. private _depthTexture;
  56726. private _randomTexture;
  56727. private _originalColorPostProcess;
  56728. private _ssaoPostProcess;
  56729. private _blurHPostProcess;
  56730. private _blurVPostProcess;
  56731. private _ssaoCombinePostProcess;
  56732. private _firstUpdate;
  56733. /**
  56734. * Gets active scene
  56735. */
  56736. readonly scene: Scene;
  56737. /**
  56738. * @constructor
  56739. * @param name - The rendering pipeline name
  56740. * @param scene - The scene linked to this pipeline
  56741. * @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 }
  56742. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56743. */
  56744. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56745. /**
  56746. * Get the class name
  56747. * @returns "SSAORenderingPipeline"
  56748. */
  56749. getClassName(): string;
  56750. /**
  56751. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56752. */
  56753. dispose(disableDepthRender?: boolean): void;
  56754. private _createBlurPostProcess;
  56755. /** @hidden */
  56756. _rebuild(): void;
  56757. private _createSSAOPostProcess;
  56758. private _createSSAOCombinePostProcess;
  56759. private _createRandomTexture;
  56760. }
  56761. }
  56762. declare module "babylonjs/Shaders/standard.fragment" {
  56763. /** @hidden */
  56764. export var standardPixelShader: {
  56765. name: string;
  56766. shader: string;
  56767. };
  56768. }
  56769. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56770. import { Nullable } from "babylonjs/types";
  56771. import { IAnimatable } from "babylonjs/Misc/tools";
  56772. import { Camera } from "babylonjs/Cameras/camera";
  56773. import { Texture } from "babylonjs/Materials/Textures/texture";
  56774. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56775. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56776. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56777. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56778. import { IDisposable } from "babylonjs/scene";
  56779. import { SpotLight } from "babylonjs/Lights/spotLight";
  56780. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56781. import { Scene } from "babylonjs/scene";
  56782. import { Animation } from "babylonjs/Animations/animation";
  56783. import "babylonjs/Shaders/standard.fragment";
  56784. /**
  56785. * Standard rendering pipeline
  56786. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56787. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56788. */
  56789. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56790. /**
  56791. * Public members
  56792. */
  56793. /**
  56794. * Post-process which contains the original scene color before the pipeline applies all the effects
  56795. */
  56796. originalPostProcess: Nullable<PostProcess>;
  56797. /**
  56798. * Post-process used to down scale an image x4
  56799. */
  56800. downSampleX4PostProcess: Nullable<PostProcess>;
  56801. /**
  56802. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56803. */
  56804. brightPassPostProcess: Nullable<PostProcess>;
  56805. /**
  56806. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56807. */
  56808. blurHPostProcesses: PostProcess[];
  56809. /**
  56810. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56811. */
  56812. blurVPostProcesses: PostProcess[];
  56813. /**
  56814. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56815. */
  56816. textureAdderPostProcess: Nullable<PostProcess>;
  56817. /**
  56818. * Post-process used to create volumetric lighting effect
  56819. */
  56820. volumetricLightPostProcess: Nullable<PostProcess>;
  56821. /**
  56822. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56823. */
  56824. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56825. /**
  56826. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56827. */
  56828. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56829. /**
  56830. * Post-process used to merge the volumetric light effect and the real scene color
  56831. */
  56832. volumetricLightMergePostProces: Nullable<PostProcess>;
  56833. /**
  56834. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56835. */
  56836. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56837. /**
  56838. * Base post-process used to calculate the average luminance of the final image for HDR
  56839. */
  56840. luminancePostProcess: Nullable<PostProcess>;
  56841. /**
  56842. * Post-processes used to create down sample post-processes in order to get
  56843. * the average luminance of the final image for HDR
  56844. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56845. */
  56846. luminanceDownSamplePostProcesses: PostProcess[];
  56847. /**
  56848. * Post-process used to create a HDR effect (light adaptation)
  56849. */
  56850. hdrPostProcess: Nullable<PostProcess>;
  56851. /**
  56852. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56853. */
  56854. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56855. /**
  56856. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56857. */
  56858. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56859. /**
  56860. * Post-process used to merge the final HDR post-process and the real scene color
  56861. */
  56862. hdrFinalPostProcess: Nullable<PostProcess>;
  56863. /**
  56864. * Post-process used to create a lens flare effect
  56865. */
  56866. lensFlarePostProcess: Nullable<PostProcess>;
  56867. /**
  56868. * Post-process that merges the result of the lens flare post-process and the real scene color
  56869. */
  56870. lensFlareComposePostProcess: Nullable<PostProcess>;
  56871. /**
  56872. * Post-process used to create a motion blur effect
  56873. */
  56874. motionBlurPostProcess: Nullable<PostProcess>;
  56875. /**
  56876. * Post-process used to create a depth of field effect
  56877. */
  56878. depthOfFieldPostProcess: Nullable<PostProcess>;
  56879. /**
  56880. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56881. */
  56882. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56883. /**
  56884. * Represents the brightness threshold in order to configure the illuminated surfaces
  56885. */
  56886. brightThreshold: number;
  56887. /**
  56888. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56889. */
  56890. blurWidth: number;
  56891. /**
  56892. * Sets if the blur for highlighted surfaces must be only horizontal
  56893. */
  56894. horizontalBlur: boolean;
  56895. /**
  56896. * Gets the overall exposure used by the pipeline
  56897. */
  56898. /**
  56899. * Sets the overall exposure used by the pipeline
  56900. */
  56901. exposure: number;
  56902. /**
  56903. * Texture used typically to simulate "dirty" on camera lens
  56904. */
  56905. lensTexture: Nullable<Texture>;
  56906. /**
  56907. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56908. */
  56909. volumetricLightCoefficient: number;
  56910. /**
  56911. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56912. */
  56913. volumetricLightPower: number;
  56914. /**
  56915. * Used the set the blur intensity to smooth the volumetric lights
  56916. */
  56917. volumetricLightBlurScale: number;
  56918. /**
  56919. * Light (spot or directional) used to generate the volumetric lights rays
  56920. * The source light must have a shadow generate so the pipeline can get its
  56921. * depth map
  56922. */
  56923. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56924. /**
  56925. * For eye adaptation, represents the minimum luminance the eye can see
  56926. */
  56927. hdrMinimumLuminance: number;
  56928. /**
  56929. * For eye adaptation, represents the decrease luminance speed
  56930. */
  56931. hdrDecreaseRate: number;
  56932. /**
  56933. * For eye adaptation, represents the increase luminance speed
  56934. */
  56935. hdrIncreaseRate: number;
  56936. /**
  56937. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56938. */
  56939. /**
  56940. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56941. */
  56942. hdrAutoExposure: boolean;
  56943. /**
  56944. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56945. */
  56946. lensColorTexture: Nullable<Texture>;
  56947. /**
  56948. * The overall strengh for the lens flare effect
  56949. */
  56950. lensFlareStrength: number;
  56951. /**
  56952. * Dispersion coefficient for lens flare ghosts
  56953. */
  56954. lensFlareGhostDispersal: number;
  56955. /**
  56956. * Main lens flare halo width
  56957. */
  56958. lensFlareHaloWidth: number;
  56959. /**
  56960. * Based on the lens distortion effect, defines how much the lens flare result
  56961. * is distorted
  56962. */
  56963. lensFlareDistortionStrength: number;
  56964. /**
  56965. * Lens star texture must be used to simulate rays on the flares and is available
  56966. * in the documentation
  56967. */
  56968. lensStarTexture: Nullable<Texture>;
  56969. /**
  56970. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56971. * flare effect by taking account of the dirt texture
  56972. */
  56973. lensFlareDirtTexture: Nullable<Texture>;
  56974. /**
  56975. * Represents the focal length for the depth of field effect
  56976. */
  56977. depthOfFieldDistance: number;
  56978. /**
  56979. * Represents the blur intensity for the blurred part of the depth of field effect
  56980. */
  56981. depthOfFieldBlurWidth: number;
  56982. /**
  56983. * For motion blur, defines how much the image is blurred by the movement
  56984. */
  56985. motionStrength: number;
  56986. /**
  56987. * List of animations for the pipeline (IAnimatable implementation)
  56988. */
  56989. animations: Animation[];
  56990. /**
  56991. * Private members
  56992. */
  56993. private _scene;
  56994. private _currentDepthOfFieldSource;
  56995. private _basePostProcess;
  56996. private _fixedExposure;
  56997. private _currentExposure;
  56998. private _hdrAutoExposure;
  56999. private _hdrCurrentLuminance;
  57000. private _floatTextureType;
  57001. private _ratio;
  57002. private _bloomEnabled;
  57003. private _depthOfFieldEnabled;
  57004. private _vlsEnabled;
  57005. private _lensFlareEnabled;
  57006. private _hdrEnabled;
  57007. private _motionBlurEnabled;
  57008. private _fxaaEnabled;
  57009. private _motionBlurSamples;
  57010. private _volumetricLightStepsCount;
  57011. private _samples;
  57012. /**
  57013. * @ignore
  57014. * Specifies if the bloom pipeline is enabled
  57015. */
  57016. BloomEnabled: boolean;
  57017. /**
  57018. * @ignore
  57019. * Specifies if the depth of field pipeline is enabed
  57020. */
  57021. DepthOfFieldEnabled: boolean;
  57022. /**
  57023. * @ignore
  57024. * Specifies if the lens flare pipeline is enabed
  57025. */
  57026. LensFlareEnabled: boolean;
  57027. /**
  57028. * @ignore
  57029. * Specifies if the HDR pipeline is enabled
  57030. */
  57031. HDREnabled: boolean;
  57032. /**
  57033. * @ignore
  57034. * Specifies if the volumetric lights scattering effect is enabled
  57035. */
  57036. VLSEnabled: boolean;
  57037. /**
  57038. * @ignore
  57039. * Specifies if the motion blur effect is enabled
  57040. */
  57041. MotionBlurEnabled: boolean;
  57042. /**
  57043. * Specifies if anti-aliasing is enabled
  57044. */
  57045. fxaaEnabled: boolean;
  57046. /**
  57047. * Specifies the number of steps used to calculate the volumetric lights
  57048. * Typically in interval [50, 200]
  57049. */
  57050. volumetricLightStepsCount: number;
  57051. /**
  57052. * Specifies the number of samples used for the motion blur effect
  57053. * Typically in interval [16, 64]
  57054. */
  57055. motionBlurSamples: number;
  57056. /**
  57057. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57058. */
  57059. samples: number;
  57060. /**
  57061. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57062. * @constructor
  57063. * @param name The rendering pipeline name
  57064. * @param scene The scene linked to this pipeline
  57065. * @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)
  57066. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57067. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57068. */
  57069. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57070. private _buildPipeline;
  57071. private _createDownSampleX4PostProcess;
  57072. private _createBrightPassPostProcess;
  57073. private _createBlurPostProcesses;
  57074. private _createTextureAdderPostProcess;
  57075. private _createVolumetricLightPostProcess;
  57076. private _createLuminancePostProcesses;
  57077. private _createHdrPostProcess;
  57078. private _createLensFlarePostProcess;
  57079. private _createDepthOfFieldPostProcess;
  57080. private _createMotionBlurPostProcess;
  57081. private _getDepthTexture;
  57082. private _disposePostProcesses;
  57083. /**
  57084. * Dispose of the pipeline and stop all post processes
  57085. */
  57086. dispose(): void;
  57087. /**
  57088. * Serialize the rendering pipeline (Used when exporting)
  57089. * @returns the serialized object
  57090. */
  57091. serialize(): any;
  57092. /**
  57093. * Parse the serialized pipeline
  57094. * @param source Source pipeline.
  57095. * @param scene The scene to load the pipeline to.
  57096. * @param rootUrl The URL of the serialized pipeline.
  57097. * @returns An instantiated pipeline from the serialized object.
  57098. */
  57099. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57100. /**
  57101. * Luminance steps
  57102. */
  57103. static LuminanceSteps: number;
  57104. }
  57105. }
  57106. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  57107. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  57108. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  57109. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  57110. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  57111. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  57112. }
  57113. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  57114. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  57115. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57116. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  57117. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  57118. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  57119. }
  57120. declare module "babylonjs/Shaders/tonemap.fragment" {
  57121. /** @hidden */
  57122. export var tonemapPixelShader: {
  57123. name: string;
  57124. shader: string;
  57125. };
  57126. }
  57127. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  57128. import { Camera } from "babylonjs/Cameras/camera";
  57129. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57130. import "babylonjs/Shaders/tonemap.fragment";
  57131. import { Engine } from "babylonjs/Engines/engine";
  57132. /** Defines operator used for tonemapping */
  57133. export enum TonemappingOperator {
  57134. /** Hable */
  57135. Hable = 0,
  57136. /** Reinhard */
  57137. Reinhard = 1,
  57138. /** HejiDawson */
  57139. HejiDawson = 2,
  57140. /** Photographic */
  57141. Photographic = 3
  57142. }
  57143. /**
  57144. * Defines a post process to apply tone mapping
  57145. */
  57146. export class TonemapPostProcess extends PostProcess {
  57147. private _operator;
  57148. /** Defines the required exposure adjustement */
  57149. exposureAdjustment: number;
  57150. /**
  57151. * Creates a new TonemapPostProcess
  57152. * @param name defines the name of the postprocess
  57153. * @param _operator defines the operator to use
  57154. * @param exposureAdjustment defines the required exposure adjustement
  57155. * @param camera defines the camera to use (can be null)
  57156. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57157. * @param engine defines the hosting engine (can be ignore if camera is set)
  57158. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57159. */
  57160. constructor(name: string, _operator: TonemappingOperator,
  57161. /** Defines the required exposure adjustement */
  57162. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57163. }
  57164. }
  57165. declare module "babylonjs/Shaders/depth.vertex" {
  57166. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57167. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57168. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57169. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57170. /** @hidden */
  57171. export var depthVertexShader: {
  57172. name: string;
  57173. shader: string;
  57174. };
  57175. }
  57176. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  57177. /** @hidden */
  57178. export var volumetricLightScatteringPixelShader: {
  57179. name: string;
  57180. shader: string;
  57181. };
  57182. }
  57183. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  57184. /** @hidden */
  57185. export var volumetricLightScatteringPassPixelShader: {
  57186. name: string;
  57187. shader: string;
  57188. };
  57189. }
  57190. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  57191. import { Vector3 } from "babylonjs/Maths/math";
  57192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57193. import { Mesh } from "babylonjs/Meshes/mesh";
  57194. import { Camera } from "babylonjs/Cameras/camera";
  57195. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57196. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57197. import { Scene } from "babylonjs/scene";
  57198. import "babylonjs/Meshes/Builders/planeBuilder";
  57199. import "babylonjs/Shaders/depth.vertex";
  57200. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  57201. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  57202. import { Engine } from "babylonjs/Engines/engine";
  57203. /**
  57204. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57205. */
  57206. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57207. private _volumetricLightScatteringPass;
  57208. private _volumetricLightScatteringRTT;
  57209. private _viewPort;
  57210. private _screenCoordinates;
  57211. private _cachedDefines;
  57212. /**
  57213. * If not undefined, the mesh position is computed from the attached node position
  57214. */
  57215. attachedNode: {
  57216. position: Vector3;
  57217. };
  57218. /**
  57219. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57220. */
  57221. customMeshPosition: Vector3;
  57222. /**
  57223. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57224. */
  57225. useCustomMeshPosition: boolean;
  57226. /**
  57227. * If the post-process should inverse the light scattering direction
  57228. */
  57229. invert: boolean;
  57230. /**
  57231. * The internal mesh used by the post-process
  57232. */
  57233. mesh: Mesh;
  57234. /**
  57235. * @hidden
  57236. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57237. */
  57238. useDiffuseColor: boolean;
  57239. /**
  57240. * Array containing the excluded meshes not rendered in the internal pass
  57241. */
  57242. excludedMeshes: AbstractMesh[];
  57243. /**
  57244. * Controls the overall intensity of the post-process
  57245. */
  57246. exposure: number;
  57247. /**
  57248. * Dissipates each sample's contribution in range [0, 1]
  57249. */
  57250. decay: number;
  57251. /**
  57252. * Controls the overall intensity of each sample
  57253. */
  57254. weight: number;
  57255. /**
  57256. * Controls the density of each sample
  57257. */
  57258. density: number;
  57259. /**
  57260. * @constructor
  57261. * @param name The post-process name
  57262. * @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)
  57263. * @param camera The camera that the post-process will be attached to
  57264. * @param mesh The mesh used to create the light scattering
  57265. * @param samples The post-process quality, default 100
  57266. * @param samplingModeThe post-process filtering mode
  57267. * @param engine The babylon engine
  57268. * @param reusable If the post-process is reusable
  57269. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57270. */
  57271. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57272. /**
  57273. * Returns the string "VolumetricLightScatteringPostProcess"
  57274. * @returns "VolumetricLightScatteringPostProcess"
  57275. */
  57276. getClassName(): string;
  57277. private _isReady;
  57278. /**
  57279. * Sets the new light position for light scattering effect
  57280. * @param position The new custom light position
  57281. */
  57282. setCustomMeshPosition(position: Vector3): void;
  57283. /**
  57284. * Returns the light position for light scattering effect
  57285. * @return Vector3 The custom light position
  57286. */
  57287. getCustomMeshPosition(): Vector3;
  57288. /**
  57289. * Disposes the internal assets and detaches the post-process from the camera
  57290. */
  57291. dispose(camera: Camera): void;
  57292. /**
  57293. * Returns the render target texture used by the post-process
  57294. * @return the render target texture used by the post-process
  57295. */
  57296. getPass(): RenderTargetTexture;
  57297. private _meshExcluded;
  57298. private _createPass;
  57299. private _updateMeshScreenCoordinates;
  57300. /**
  57301. * Creates a default mesh for the Volumeric Light Scattering post-process
  57302. * @param name The mesh name
  57303. * @param scene The scene where to create the mesh
  57304. * @return the default mesh
  57305. */
  57306. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57307. }
  57308. }
  57309. declare module "babylonjs/PostProcesses/index" {
  57310. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57311. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57312. export * from "babylonjs/PostProcesses/bloomEffect";
  57313. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57314. export * from "babylonjs/PostProcesses/blurPostProcess";
  57315. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57316. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57317. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57318. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57319. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57320. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57321. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57322. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57323. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57324. export * from "babylonjs/PostProcesses/filterPostProcess";
  57325. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57326. export * from "babylonjs/PostProcesses/grainPostProcess";
  57327. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57328. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57329. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57330. export * from "babylonjs/PostProcesses/passPostProcess";
  57331. export * from "babylonjs/PostProcesses/postProcess";
  57332. export * from "babylonjs/PostProcesses/postProcessManager";
  57333. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57334. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57335. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57336. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57337. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57338. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57339. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57340. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57341. }
  57342. declare module "babylonjs/Probes/index" {
  57343. export * from "babylonjs/Probes/reflectionProbe";
  57344. }
  57345. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57346. import { Scene } from "babylonjs/scene";
  57347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57348. import { Color3 } from "babylonjs/Maths/math";
  57349. import { SmartArray } from "babylonjs/Misc/smartArray";
  57350. import { ISceneComponent } from "babylonjs/sceneComponent";
  57351. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57352. import "babylonjs/Meshes/Builders/boxBuilder";
  57353. import "babylonjs/Shaders/color.fragment";
  57354. import "babylonjs/Shaders/color.vertex";
  57355. module "babylonjs/scene" {
  57356. interface Scene {
  57357. /** @hidden (Backing field) */
  57358. _boundingBoxRenderer: BoundingBoxRenderer;
  57359. /** @hidden (Backing field) */
  57360. _forceShowBoundingBoxes: boolean;
  57361. /**
  57362. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57363. */
  57364. forceShowBoundingBoxes: boolean;
  57365. /**
  57366. * Gets the bounding box renderer associated with the scene
  57367. * @returns a BoundingBoxRenderer
  57368. */
  57369. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57370. }
  57371. }
  57372. module "babylonjs/Meshes/abstractMesh" {
  57373. interface AbstractMesh {
  57374. /** @hidden (Backing field) */
  57375. _showBoundingBox: boolean;
  57376. /**
  57377. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57378. */
  57379. showBoundingBox: boolean;
  57380. }
  57381. }
  57382. /**
  57383. * Component responsible of rendering the bounding box of the meshes in a scene.
  57384. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57385. */
  57386. export class BoundingBoxRenderer implements ISceneComponent {
  57387. /**
  57388. * The component name helpfull to identify the component in the list of scene components.
  57389. */
  57390. readonly name: string;
  57391. /**
  57392. * The scene the component belongs to.
  57393. */
  57394. scene: Scene;
  57395. /**
  57396. * Color of the bounding box lines placed in front of an object
  57397. */
  57398. frontColor: Color3;
  57399. /**
  57400. * Color of the bounding box lines placed behind an object
  57401. */
  57402. backColor: Color3;
  57403. /**
  57404. * Defines if the renderer should show the back lines or not
  57405. */
  57406. showBackLines: boolean;
  57407. /**
  57408. * @hidden
  57409. */
  57410. renderList: SmartArray<BoundingBox>;
  57411. private _colorShader;
  57412. private _vertexBuffers;
  57413. private _indexBuffer;
  57414. /**
  57415. * Instantiates a new bounding box renderer in a scene.
  57416. * @param scene the scene the renderer renders in
  57417. */
  57418. constructor(scene: Scene);
  57419. /**
  57420. * Registers the component in a given scene
  57421. */
  57422. register(): void;
  57423. private _evaluateSubMesh;
  57424. private _activeMesh;
  57425. private _prepareRessources;
  57426. private _createIndexBuffer;
  57427. /**
  57428. * Rebuilds the elements related to this component in case of
  57429. * context lost for instance.
  57430. */
  57431. rebuild(): void;
  57432. /**
  57433. * @hidden
  57434. */
  57435. reset(): void;
  57436. /**
  57437. * Render the bounding boxes of a specific rendering group
  57438. * @param renderingGroupId defines the rendering group to render
  57439. */
  57440. render(renderingGroupId: number): void;
  57441. /**
  57442. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57443. * @param mesh Define the mesh to render the occlusion bounding box for
  57444. */
  57445. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57446. /**
  57447. * Dispose and release the resources attached to this renderer.
  57448. */
  57449. dispose(): void;
  57450. }
  57451. }
  57452. declare module "babylonjs/Shaders/depth.fragment" {
  57453. /** @hidden */
  57454. export var depthPixelShader: {
  57455. name: string;
  57456. shader: string;
  57457. };
  57458. }
  57459. declare module "babylonjs/Rendering/depthRenderer" {
  57460. import { Nullable } from "babylonjs/types";
  57461. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57462. import { Scene } from "babylonjs/scene";
  57463. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57464. import { Camera } from "babylonjs/Cameras/camera";
  57465. import "babylonjs/Shaders/depth.fragment";
  57466. import "babylonjs/Shaders/depth.vertex";
  57467. /**
  57468. * This represents a depth renderer in Babylon.
  57469. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57470. */
  57471. export class DepthRenderer {
  57472. private _scene;
  57473. private _depthMap;
  57474. private _effect;
  57475. private _cachedDefines;
  57476. private _camera;
  57477. /**
  57478. * Specifiess that the depth renderer will only be used within
  57479. * the camera it is created for.
  57480. * This can help forcing its rendering during the camera processing.
  57481. */
  57482. useOnlyInActiveCamera: boolean;
  57483. /** @hidden */
  57484. static _SceneComponentInitialization: (scene: Scene) => void;
  57485. /**
  57486. * Instantiates a depth renderer
  57487. * @param scene The scene the renderer belongs to
  57488. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57489. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57490. */
  57491. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57492. /**
  57493. * Creates the depth rendering effect and checks if the effect is ready.
  57494. * @param subMesh The submesh to be used to render the depth map of
  57495. * @param useInstances If multiple world instances should be used
  57496. * @returns if the depth renderer is ready to render the depth map
  57497. */
  57498. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57499. /**
  57500. * Gets the texture which the depth map will be written to.
  57501. * @returns The depth map texture
  57502. */
  57503. getDepthMap(): RenderTargetTexture;
  57504. /**
  57505. * Disposes of the depth renderer.
  57506. */
  57507. dispose(): void;
  57508. }
  57509. }
  57510. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57511. import { Nullable } from "babylonjs/types";
  57512. import { Scene } from "babylonjs/scene";
  57513. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57514. import { Camera } from "babylonjs/Cameras/camera";
  57515. import { ISceneComponent } from "babylonjs/sceneComponent";
  57516. module "babylonjs/scene" {
  57517. interface Scene {
  57518. /** @hidden (Backing field) */
  57519. _depthRenderer: {
  57520. [id: string]: DepthRenderer;
  57521. };
  57522. /**
  57523. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57524. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57525. * @returns the created depth renderer
  57526. */
  57527. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57528. /**
  57529. * Disables a depth renderer for a given camera
  57530. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57531. */
  57532. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57533. }
  57534. }
  57535. /**
  57536. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57537. * in several rendering techniques.
  57538. */
  57539. export class DepthRendererSceneComponent implements ISceneComponent {
  57540. /**
  57541. * The component name helpfull to identify the component in the list of scene components.
  57542. */
  57543. readonly name: string;
  57544. /**
  57545. * The scene the component belongs to.
  57546. */
  57547. scene: Scene;
  57548. /**
  57549. * Creates a new instance of the component for the given scene
  57550. * @param scene Defines the scene to register the component in
  57551. */
  57552. constructor(scene: Scene);
  57553. /**
  57554. * Registers the component in a given scene
  57555. */
  57556. register(): void;
  57557. /**
  57558. * Rebuilds the elements related to this component in case of
  57559. * context lost for instance.
  57560. */
  57561. rebuild(): void;
  57562. /**
  57563. * Disposes the component and the associated ressources
  57564. */
  57565. dispose(): void;
  57566. private _gatherRenderTargets;
  57567. private _gatherActiveCameraRenderTargets;
  57568. }
  57569. }
  57570. declare module "babylonjs/Shaders/outline.fragment" {
  57571. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57572. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57573. /** @hidden */
  57574. export var outlinePixelShader: {
  57575. name: string;
  57576. shader: string;
  57577. };
  57578. }
  57579. declare module "babylonjs/Shaders/outline.vertex" {
  57580. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57581. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57582. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57583. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57584. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57585. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57586. /** @hidden */
  57587. export var outlineVertexShader: {
  57588. name: string;
  57589. shader: string;
  57590. };
  57591. }
  57592. declare module "babylonjs/Rendering/outlineRenderer" {
  57593. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57594. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57595. import { Scene } from "babylonjs/scene";
  57596. import { ISceneComponent } from "babylonjs/sceneComponent";
  57597. import "babylonjs/Shaders/outline.fragment";
  57598. import "babylonjs/Shaders/outline.vertex";
  57599. module "babylonjs/scene" {
  57600. interface Scene {
  57601. /** @hidden */
  57602. _outlineRenderer: OutlineRenderer;
  57603. /**
  57604. * Gets the outline renderer associated with the scene
  57605. * @returns a OutlineRenderer
  57606. */
  57607. getOutlineRenderer(): OutlineRenderer;
  57608. }
  57609. }
  57610. module "babylonjs/Meshes/abstractMesh" {
  57611. interface AbstractMesh {
  57612. /** @hidden (Backing field) */
  57613. _renderOutline: boolean;
  57614. /**
  57615. * Gets or sets a boolean indicating if the outline must be rendered as well
  57616. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57617. */
  57618. renderOutline: boolean;
  57619. /** @hidden (Backing field) */
  57620. _renderOverlay: boolean;
  57621. /**
  57622. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57623. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57624. */
  57625. renderOverlay: boolean;
  57626. }
  57627. }
  57628. /**
  57629. * This class is responsible to draw bothe outline/overlay of meshes.
  57630. * It should not be used directly but through the available method on mesh.
  57631. */
  57632. export class OutlineRenderer implements ISceneComponent {
  57633. /**
  57634. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57635. */
  57636. private static _StencilReference;
  57637. /**
  57638. * The name of the component. Each component must have a unique name.
  57639. */
  57640. name: string;
  57641. /**
  57642. * The scene the component belongs to.
  57643. */
  57644. scene: Scene;
  57645. /**
  57646. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57647. */
  57648. zOffset: number;
  57649. private _engine;
  57650. private _effect;
  57651. private _cachedDefines;
  57652. private _savedDepthWrite;
  57653. /**
  57654. * Instantiates a new outline renderer. (There could be only one per scene).
  57655. * @param scene Defines the scene it belongs to
  57656. */
  57657. constructor(scene: Scene);
  57658. /**
  57659. * Register the component to one instance of a scene.
  57660. */
  57661. register(): void;
  57662. /**
  57663. * Rebuilds the elements related to this component in case of
  57664. * context lost for instance.
  57665. */
  57666. rebuild(): void;
  57667. /**
  57668. * Disposes the component and the associated ressources.
  57669. */
  57670. dispose(): void;
  57671. /**
  57672. * Renders the outline in the canvas.
  57673. * @param subMesh Defines the sumesh to render
  57674. * @param batch Defines the batch of meshes in case of instances
  57675. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57676. */
  57677. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57678. /**
  57679. * Returns whether or not the outline renderer is ready for a given submesh.
  57680. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57681. * @param subMesh Defines the submesh to check readyness for
  57682. * @param useInstances Defines wheter wee are trying to render instances or not
  57683. * @returns true if ready otherwise false
  57684. */
  57685. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57686. private _beforeRenderingMesh;
  57687. private _afterRenderingMesh;
  57688. }
  57689. }
  57690. declare module "babylonjs/Rendering/index" {
  57691. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57692. export * from "babylonjs/Rendering/depthRenderer";
  57693. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57694. export * from "babylonjs/Rendering/edgesRenderer";
  57695. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57696. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57697. export * from "babylonjs/Rendering/outlineRenderer";
  57698. export * from "babylonjs/Rendering/renderingGroup";
  57699. export * from "babylonjs/Rendering/renderingManager";
  57700. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57701. }
  57702. declare module "babylonjs/Sprites/index" {
  57703. export * from "babylonjs/Sprites/sprite";
  57704. export * from "babylonjs/Sprites/spriteManager";
  57705. export * from "babylonjs/Sprites/spriteSceneComponent";
  57706. }
  57707. declare module "babylonjs/Misc/assetsManager" {
  57708. import { Scene } from "babylonjs/scene";
  57709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57710. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57711. import { Skeleton } from "babylonjs/Bones/skeleton";
  57712. import { Observable } from "babylonjs/Misc/observable";
  57713. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57714. import { Texture } from "babylonjs/Materials/Textures/texture";
  57715. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57716. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57717. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57718. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57719. /**
  57720. * Defines the list of states available for a task inside a AssetsManager
  57721. */
  57722. export enum AssetTaskState {
  57723. /**
  57724. * Initialization
  57725. */
  57726. INIT = 0,
  57727. /**
  57728. * Running
  57729. */
  57730. RUNNING = 1,
  57731. /**
  57732. * Done
  57733. */
  57734. DONE = 2,
  57735. /**
  57736. * Error
  57737. */
  57738. ERROR = 3
  57739. }
  57740. /**
  57741. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57742. */
  57743. export abstract class AbstractAssetTask {
  57744. /**
  57745. * Task name
  57746. */ name: string;
  57747. /**
  57748. * Callback called when the task is successful
  57749. */
  57750. onSuccess: (task: any) => void;
  57751. /**
  57752. * Callback called when the task is not successful
  57753. */
  57754. onError: (task: any, message?: string, exception?: any) => void;
  57755. /**
  57756. * Creates a new AssetsManager
  57757. * @param name defines the name of the task
  57758. */
  57759. constructor(
  57760. /**
  57761. * Task name
  57762. */ name: string);
  57763. private _isCompleted;
  57764. private _taskState;
  57765. private _errorObject;
  57766. /**
  57767. * Get if the task is completed
  57768. */
  57769. readonly isCompleted: boolean;
  57770. /**
  57771. * Gets the current state of the task
  57772. */
  57773. readonly taskState: AssetTaskState;
  57774. /**
  57775. * Gets the current error object (if task is in error)
  57776. */
  57777. readonly errorObject: {
  57778. message?: string;
  57779. exception?: any;
  57780. };
  57781. /**
  57782. * Internal only
  57783. * @hidden
  57784. */
  57785. _setErrorObject(message?: string, exception?: any): void;
  57786. /**
  57787. * Execute the current task
  57788. * @param scene defines the scene where you want your assets to be loaded
  57789. * @param onSuccess is a callback called when the task is successfully executed
  57790. * @param onError is a callback called if an error occurs
  57791. */
  57792. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57793. /**
  57794. * Execute the current task
  57795. * @param scene defines the scene where you want your assets to be loaded
  57796. * @param onSuccess is a callback called when the task is successfully executed
  57797. * @param onError is a callback called if an error occurs
  57798. */
  57799. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57800. /**
  57801. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57802. * This can be used with failed tasks that have the reason for failure fixed.
  57803. */
  57804. reset(): void;
  57805. private onErrorCallback;
  57806. private onDoneCallback;
  57807. }
  57808. /**
  57809. * Define the interface used by progress events raised during assets loading
  57810. */
  57811. export interface IAssetsProgressEvent {
  57812. /**
  57813. * Defines the number of remaining tasks to process
  57814. */
  57815. remainingCount: number;
  57816. /**
  57817. * Defines the total number of tasks
  57818. */
  57819. totalCount: number;
  57820. /**
  57821. * Defines the task that was just processed
  57822. */
  57823. task: AbstractAssetTask;
  57824. }
  57825. /**
  57826. * Class used to share progress information about assets loading
  57827. */
  57828. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57829. /**
  57830. * Defines the number of remaining tasks to process
  57831. */
  57832. remainingCount: number;
  57833. /**
  57834. * Defines the total number of tasks
  57835. */
  57836. totalCount: number;
  57837. /**
  57838. * Defines the task that was just processed
  57839. */
  57840. task: AbstractAssetTask;
  57841. /**
  57842. * Creates a AssetsProgressEvent
  57843. * @param remainingCount defines the number of remaining tasks to process
  57844. * @param totalCount defines the total number of tasks
  57845. * @param task defines the task that was just processed
  57846. */
  57847. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57848. }
  57849. /**
  57850. * Define a task used by AssetsManager to load meshes
  57851. */
  57852. export class MeshAssetTask extends AbstractAssetTask {
  57853. /**
  57854. * Defines the name of the task
  57855. */
  57856. name: string;
  57857. /**
  57858. * Defines the list of mesh's names you want to load
  57859. */
  57860. meshesNames: any;
  57861. /**
  57862. * Defines the root url to use as a base to load your meshes and associated resources
  57863. */
  57864. rootUrl: string;
  57865. /**
  57866. * Defines the filename of the scene to load from
  57867. */
  57868. sceneFilename: string;
  57869. /**
  57870. * Gets the list of loaded meshes
  57871. */
  57872. loadedMeshes: Array<AbstractMesh>;
  57873. /**
  57874. * Gets the list of loaded particle systems
  57875. */
  57876. loadedParticleSystems: Array<IParticleSystem>;
  57877. /**
  57878. * Gets the list of loaded skeletons
  57879. */
  57880. loadedSkeletons: Array<Skeleton>;
  57881. /**
  57882. * Gets the list of loaded animation groups
  57883. */
  57884. loadedAnimationGroups: Array<AnimationGroup>;
  57885. /**
  57886. * Callback called when the task is successful
  57887. */
  57888. onSuccess: (task: MeshAssetTask) => void;
  57889. /**
  57890. * Callback called when the task is successful
  57891. */
  57892. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57893. /**
  57894. * Creates a new MeshAssetTask
  57895. * @param name defines the name of the task
  57896. * @param meshesNames defines the list of mesh's names you want to load
  57897. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57898. * @param sceneFilename defines the filename of the scene to load from
  57899. */
  57900. constructor(
  57901. /**
  57902. * Defines the name of the task
  57903. */
  57904. name: string,
  57905. /**
  57906. * Defines the list of mesh's names you want to load
  57907. */
  57908. meshesNames: any,
  57909. /**
  57910. * Defines the root url to use as a base to load your meshes and associated resources
  57911. */
  57912. rootUrl: string,
  57913. /**
  57914. * Defines the filename of the scene to load from
  57915. */
  57916. sceneFilename: string);
  57917. /**
  57918. * Execute the current task
  57919. * @param scene defines the scene where you want your assets to be loaded
  57920. * @param onSuccess is a callback called when the task is successfully executed
  57921. * @param onError is a callback called if an error occurs
  57922. */
  57923. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57924. }
  57925. /**
  57926. * Define a task used by AssetsManager to load text content
  57927. */
  57928. export class TextFileAssetTask extends AbstractAssetTask {
  57929. /**
  57930. * Defines the name of the task
  57931. */
  57932. name: string;
  57933. /**
  57934. * Defines the location of the file to load
  57935. */
  57936. url: string;
  57937. /**
  57938. * Gets the loaded text string
  57939. */
  57940. text: string;
  57941. /**
  57942. * Callback called when the task is successful
  57943. */
  57944. onSuccess: (task: TextFileAssetTask) => void;
  57945. /**
  57946. * Callback called when the task is successful
  57947. */
  57948. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57949. /**
  57950. * Creates a new TextFileAssetTask object
  57951. * @param name defines the name of the task
  57952. * @param url defines the location of the file to load
  57953. */
  57954. constructor(
  57955. /**
  57956. * Defines the name of the task
  57957. */
  57958. name: string,
  57959. /**
  57960. * Defines the location of the file to load
  57961. */
  57962. url: string);
  57963. /**
  57964. * Execute the current task
  57965. * @param scene defines the scene where you want your assets to be loaded
  57966. * @param onSuccess is a callback called when the task is successfully executed
  57967. * @param onError is a callback called if an error occurs
  57968. */
  57969. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57970. }
  57971. /**
  57972. * Define a task used by AssetsManager to load binary data
  57973. */
  57974. export class BinaryFileAssetTask extends AbstractAssetTask {
  57975. /**
  57976. * Defines the name of the task
  57977. */
  57978. name: string;
  57979. /**
  57980. * Defines the location of the file to load
  57981. */
  57982. url: string;
  57983. /**
  57984. * Gets the lodaded data (as an array buffer)
  57985. */
  57986. data: ArrayBuffer;
  57987. /**
  57988. * Callback called when the task is successful
  57989. */
  57990. onSuccess: (task: BinaryFileAssetTask) => void;
  57991. /**
  57992. * Callback called when the task is successful
  57993. */
  57994. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57995. /**
  57996. * Creates a new BinaryFileAssetTask object
  57997. * @param name defines the name of the new task
  57998. * @param url defines the location of the file to load
  57999. */
  58000. constructor(
  58001. /**
  58002. * Defines the name of the task
  58003. */
  58004. name: string,
  58005. /**
  58006. * Defines the location of the file to load
  58007. */
  58008. url: string);
  58009. /**
  58010. * Execute the current task
  58011. * @param scene defines the scene where you want your assets to be loaded
  58012. * @param onSuccess is a callback called when the task is successfully executed
  58013. * @param onError is a callback called if an error occurs
  58014. */
  58015. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58016. }
  58017. /**
  58018. * Define a task used by AssetsManager to load images
  58019. */
  58020. export class ImageAssetTask extends AbstractAssetTask {
  58021. /**
  58022. * Defines the name of the task
  58023. */
  58024. name: string;
  58025. /**
  58026. * Defines the location of the image to load
  58027. */
  58028. url: string;
  58029. /**
  58030. * Gets the loaded images
  58031. */
  58032. image: HTMLImageElement;
  58033. /**
  58034. * Callback called when the task is successful
  58035. */
  58036. onSuccess: (task: ImageAssetTask) => void;
  58037. /**
  58038. * Callback called when the task is successful
  58039. */
  58040. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58041. /**
  58042. * Creates a new ImageAssetTask
  58043. * @param name defines the name of the task
  58044. * @param url defines the location of the image to load
  58045. */
  58046. constructor(
  58047. /**
  58048. * Defines the name of the task
  58049. */
  58050. name: string,
  58051. /**
  58052. * Defines the location of the image to load
  58053. */
  58054. url: string);
  58055. /**
  58056. * Execute the current task
  58057. * @param scene defines the scene where you want your assets to be loaded
  58058. * @param onSuccess is a callback called when the task is successfully executed
  58059. * @param onError is a callback called if an error occurs
  58060. */
  58061. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58062. }
  58063. /**
  58064. * Defines the interface used by texture loading tasks
  58065. */
  58066. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58067. /**
  58068. * Gets the loaded texture
  58069. */
  58070. texture: TEX;
  58071. }
  58072. /**
  58073. * Define a task used by AssetsManager to load 2D textures
  58074. */
  58075. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58076. /**
  58077. * Defines the name of the task
  58078. */
  58079. name: string;
  58080. /**
  58081. * Defines the location of the file to load
  58082. */
  58083. url: string;
  58084. /**
  58085. * Defines if mipmap should not be generated (default is false)
  58086. */
  58087. noMipmap?: boolean | undefined;
  58088. /**
  58089. * Defines if texture must be inverted on Y axis (default is false)
  58090. */
  58091. invertY?: boolean | undefined;
  58092. /**
  58093. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58094. */
  58095. samplingMode: number;
  58096. /**
  58097. * Gets the loaded texture
  58098. */
  58099. texture: Texture;
  58100. /**
  58101. * Callback called when the task is successful
  58102. */
  58103. onSuccess: (task: TextureAssetTask) => void;
  58104. /**
  58105. * Callback called when the task is successful
  58106. */
  58107. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58108. /**
  58109. * Creates a new TextureAssetTask object
  58110. * @param name defines the name of the task
  58111. * @param url defines the location of the file to load
  58112. * @param noMipmap defines if mipmap should not be generated (default is false)
  58113. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58114. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58115. */
  58116. constructor(
  58117. /**
  58118. * Defines the name of the task
  58119. */
  58120. name: string,
  58121. /**
  58122. * Defines the location of the file to load
  58123. */
  58124. url: string,
  58125. /**
  58126. * Defines if mipmap should not be generated (default is false)
  58127. */
  58128. noMipmap?: boolean | undefined,
  58129. /**
  58130. * Defines if texture must be inverted on Y axis (default is false)
  58131. */
  58132. invertY?: boolean | undefined,
  58133. /**
  58134. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58135. */
  58136. samplingMode?: number);
  58137. /**
  58138. * Execute the current task
  58139. * @param scene defines the scene where you want your assets to be loaded
  58140. * @param onSuccess is a callback called when the task is successfully executed
  58141. * @param onError is a callback called if an error occurs
  58142. */
  58143. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58144. }
  58145. /**
  58146. * Define a task used by AssetsManager to load cube textures
  58147. */
  58148. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58149. /**
  58150. * Defines the name of the task
  58151. */
  58152. name: string;
  58153. /**
  58154. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58155. */
  58156. url: string;
  58157. /**
  58158. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58159. */
  58160. extensions?: string[] | undefined;
  58161. /**
  58162. * Defines if mipmaps should not be generated (default is false)
  58163. */
  58164. noMipmap?: boolean | undefined;
  58165. /**
  58166. * Defines the explicit list of files (undefined by default)
  58167. */
  58168. files?: string[] | undefined;
  58169. /**
  58170. * Gets the loaded texture
  58171. */
  58172. texture: CubeTexture;
  58173. /**
  58174. * Callback called when the task is successful
  58175. */
  58176. onSuccess: (task: CubeTextureAssetTask) => void;
  58177. /**
  58178. * Callback called when the task is successful
  58179. */
  58180. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58181. /**
  58182. * Creates a new CubeTextureAssetTask
  58183. * @param name defines the name of the task
  58184. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58185. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58186. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58187. * @param files defines the explicit list of files (undefined by default)
  58188. */
  58189. constructor(
  58190. /**
  58191. * Defines the name of the task
  58192. */
  58193. name: string,
  58194. /**
  58195. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58196. */
  58197. url: string,
  58198. /**
  58199. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58200. */
  58201. extensions?: string[] | undefined,
  58202. /**
  58203. * Defines if mipmaps should not be generated (default is false)
  58204. */
  58205. noMipmap?: boolean | undefined,
  58206. /**
  58207. * Defines the explicit list of files (undefined by default)
  58208. */
  58209. files?: string[] | undefined);
  58210. /**
  58211. * Execute the current task
  58212. * @param scene defines the scene where you want your assets to be loaded
  58213. * @param onSuccess is a callback called when the task is successfully executed
  58214. * @param onError is a callback called if an error occurs
  58215. */
  58216. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58217. }
  58218. /**
  58219. * Define a task used by AssetsManager to load HDR cube textures
  58220. */
  58221. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58222. /**
  58223. * Defines the name of the task
  58224. */
  58225. name: string;
  58226. /**
  58227. * Defines the location of the file to load
  58228. */
  58229. url: string;
  58230. /**
  58231. * Defines the desired size (the more it increases the longer the generation will be)
  58232. */
  58233. size: number;
  58234. /**
  58235. * Defines if mipmaps should not be generated (default is false)
  58236. */
  58237. noMipmap: boolean;
  58238. /**
  58239. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58240. */
  58241. generateHarmonics: boolean;
  58242. /**
  58243. * 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)
  58244. */
  58245. gammaSpace: boolean;
  58246. /**
  58247. * Internal Use Only
  58248. */
  58249. reserved: boolean;
  58250. /**
  58251. * Gets the loaded texture
  58252. */
  58253. texture: HDRCubeTexture;
  58254. /**
  58255. * Callback called when the task is successful
  58256. */
  58257. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58258. /**
  58259. * Callback called when the task is successful
  58260. */
  58261. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58262. /**
  58263. * Creates a new HDRCubeTextureAssetTask object
  58264. * @param name defines the name of the task
  58265. * @param url defines the location of the file to load
  58266. * @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.
  58267. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58268. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58269. * @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)
  58270. * @param reserved Internal use only
  58271. */
  58272. constructor(
  58273. /**
  58274. * Defines the name of the task
  58275. */
  58276. name: string,
  58277. /**
  58278. * Defines the location of the file to load
  58279. */
  58280. url: string,
  58281. /**
  58282. * Defines the desired size (the more it increases the longer the generation will be)
  58283. */
  58284. size: number,
  58285. /**
  58286. * Defines if mipmaps should not be generated (default is false)
  58287. */
  58288. noMipmap?: boolean,
  58289. /**
  58290. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58291. */
  58292. generateHarmonics?: boolean,
  58293. /**
  58294. * 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)
  58295. */
  58296. gammaSpace?: boolean,
  58297. /**
  58298. * Internal Use Only
  58299. */
  58300. reserved?: boolean);
  58301. /**
  58302. * Execute the current task
  58303. * @param scene defines the scene where you want your assets to be loaded
  58304. * @param onSuccess is a callback called when the task is successfully executed
  58305. * @param onError is a callback called if an error occurs
  58306. */
  58307. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58308. }
  58309. /**
  58310. * Define a task used by AssetsManager to load Equirectangular cube textures
  58311. */
  58312. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58313. /**
  58314. * Defines the name of the task
  58315. */
  58316. name: string;
  58317. /**
  58318. * Defines the location of the file to load
  58319. */
  58320. url: string;
  58321. /**
  58322. * Defines the desired size (the more it increases the longer the generation will be)
  58323. */
  58324. size: number;
  58325. /**
  58326. * Defines if mipmaps should not be generated (default is false)
  58327. */
  58328. noMipmap: boolean;
  58329. /**
  58330. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58331. * but the standard material would require them in Gamma space) (default is true)
  58332. */
  58333. gammaSpace: boolean;
  58334. /**
  58335. * Gets the loaded texture
  58336. */
  58337. texture: EquiRectangularCubeTexture;
  58338. /**
  58339. * Callback called when the task is successful
  58340. */
  58341. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58342. /**
  58343. * Callback called when the task is successful
  58344. */
  58345. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58346. /**
  58347. * Creates a new EquiRectangularCubeTextureAssetTask object
  58348. * @param name defines the name of the task
  58349. * @param url defines the location of the file to load
  58350. * @param size defines the desired size (the more it increases the longer the generation will be)
  58351. * If the size is omitted this implies you are using a preprocessed cubemap.
  58352. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58353. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58354. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58355. * (default is true)
  58356. */
  58357. constructor(
  58358. /**
  58359. * Defines the name of the task
  58360. */
  58361. name: string,
  58362. /**
  58363. * Defines the location of the file to load
  58364. */
  58365. url: string,
  58366. /**
  58367. * Defines the desired size (the more it increases the longer the generation will be)
  58368. */
  58369. size: number,
  58370. /**
  58371. * Defines if mipmaps should not be generated (default is false)
  58372. */
  58373. noMipmap?: boolean,
  58374. /**
  58375. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58376. * but the standard material would require them in Gamma space) (default is true)
  58377. */
  58378. gammaSpace?: boolean);
  58379. /**
  58380. * Execute the current task
  58381. * @param scene defines the scene where you want your assets to be loaded
  58382. * @param onSuccess is a callback called when the task is successfully executed
  58383. * @param onError is a callback called if an error occurs
  58384. */
  58385. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58386. }
  58387. /**
  58388. * This class can be used to easily import assets into a scene
  58389. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58390. */
  58391. export class AssetsManager {
  58392. private _scene;
  58393. private _isLoading;
  58394. protected _tasks: AbstractAssetTask[];
  58395. protected _waitingTasksCount: number;
  58396. protected _totalTasksCount: number;
  58397. /**
  58398. * Callback called when all tasks are processed
  58399. */
  58400. onFinish: (tasks: AbstractAssetTask[]) => void;
  58401. /**
  58402. * Callback called when a task is successful
  58403. */
  58404. onTaskSuccess: (task: AbstractAssetTask) => void;
  58405. /**
  58406. * Callback called when a task had an error
  58407. */
  58408. onTaskError: (task: AbstractAssetTask) => void;
  58409. /**
  58410. * Callback called when a task is done (whatever the result is)
  58411. */
  58412. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58413. /**
  58414. * Observable called when all tasks are processed
  58415. */
  58416. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58417. /**
  58418. * Observable called when a task had an error
  58419. */
  58420. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58421. /**
  58422. * Observable called when all tasks were executed
  58423. */
  58424. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58425. /**
  58426. * Observable called when a task is done (whatever the result is)
  58427. */
  58428. onProgressObservable: Observable<IAssetsProgressEvent>;
  58429. /**
  58430. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58431. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58432. */
  58433. useDefaultLoadingScreen: boolean;
  58434. /**
  58435. * Creates a new AssetsManager
  58436. * @param scene defines the scene to work on
  58437. */
  58438. constructor(scene: Scene);
  58439. /**
  58440. * Add a MeshAssetTask to the list of active tasks
  58441. * @param taskName defines the name of the new task
  58442. * @param meshesNames defines the name of meshes to load
  58443. * @param rootUrl defines the root url to use to locate files
  58444. * @param sceneFilename defines the filename of the scene file
  58445. * @returns a new MeshAssetTask object
  58446. */
  58447. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58448. /**
  58449. * Add a TextFileAssetTask to the list of active tasks
  58450. * @param taskName defines the name of the new task
  58451. * @param url defines the url of the file to load
  58452. * @returns a new TextFileAssetTask object
  58453. */
  58454. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58455. /**
  58456. * Add a BinaryFileAssetTask to the list of active tasks
  58457. * @param taskName defines the name of the new task
  58458. * @param url defines the url of the file to load
  58459. * @returns a new BinaryFileAssetTask object
  58460. */
  58461. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58462. /**
  58463. * Add a ImageAssetTask to the list of active tasks
  58464. * @param taskName defines the name of the new task
  58465. * @param url defines the url of the file to load
  58466. * @returns a new ImageAssetTask object
  58467. */
  58468. addImageTask(taskName: string, url: string): ImageAssetTask;
  58469. /**
  58470. * Add a TextureAssetTask to the list of active tasks
  58471. * @param taskName defines the name of the new task
  58472. * @param url defines the url of the file to load
  58473. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58474. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58475. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58476. * @returns a new TextureAssetTask object
  58477. */
  58478. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58479. /**
  58480. * Add a CubeTextureAssetTask to the list of active tasks
  58481. * @param taskName defines the name of the new task
  58482. * @param url defines the url of the file to load
  58483. * @param extensions defines the extension to use to load the cube map (can be null)
  58484. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58485. * @param files defines the list of files to load (can be null)
  58486. * @returns a new CubeTextureAssetTask object
  58487. */
  58488. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58489. /**
  58490. *
  58491. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58492. * @param taskName defines the name of the new task
  58493. * @param url defines the url of the file to load
  58494. * @param size defines the size you want for the cubemap (can be null)
  58495. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58496. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58497. * @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)
  58498. * @param reserved Internal use only
  58499. * @returns a new HDRCubeTextureAssetTask object
  58500. */
  58501. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58502. /**
  58503. *
  58504. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58505. * @param taskName defines the name of the new task
  58506. * @param url defines the url of the file to load
  58507. * @param size defines the size you want for the cubemap (can be null)
  58508. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58509. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58510. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58511. * @returns a new EquiRectangularCubeTextureAssetTask object
  58512. */
  58513. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58514. /**
  58515. * Remove a task from the assets manager.
  58516. * @param task the task to remove
  58517. */
  58518. removeTask(task: AbstractAssetTask): void;
  58519. private _decreaseWaitingTasksCount;
  58520. private _runTask;
  58521. /**
  58522. * Reset the AssetsManager and remove all tasks
  58523. * @return the current instance of the AssetsManager
  58524. */
  58525. reset(): AssetsManager;
  58526. /**
  58527. * Start the loading process
  58528. * @return the current instance of the AssetsManager
  58529. */
  58530. load(): AssetsManager;
  58531. /**
  58532. * Start the loading process as an async operation
  58533. * @return a promise returning the list of failed tasks
  58534. */
  58535. loadAsync(): Promise<void>;
  58536. }
  58537. }
  58538. declare module "babylonjs/Misc/deferred" {
  58539. /**
  58540. * Wrapper class for promise with external resolve and reject.
  58541. */
  58542. export class Deferred<T> {
  58543. /**
  58544. * The promise associated with this deferred object.
  58545. */
  58546. readonly promise: Promise<T>;
  58547. private _resolve;
  58548. private _reject;
  58549. /**
  58550. * The resolve method of the promise associated with this deferred object.
  58551. */
  58552. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58553. /**
  58554. * The reject method of the promise associated with this deferred object.
  58555. */
  58556. readonly reject: (reason?: any) => void;
  58557. /**
  58558. * Constructor for this deferred object.
  58559. */
  58560. constructor();
  58561. }
  58562. }
  58563. declare module "babylonjs/Misc/meshExploder" {
  58564. import { Mesh } from "babylonjs/Meshes/mesh";
  58565. /**
  58566. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58567. */
  58568. export class MeshExploder {
  58569. private _centerMesh;
  58570. private _meshes;
  58571. private _meshesOrigins;
  58572. private _toCenterVectors;
  58573. private _scaledDirection;
  58574. private _newPosition;
  58575. private _centerPosition;
  58576. /**
  58577. * Explodes meshes from a center mesh.
  58578. * @param meshes The meshes to explode.
  58579. * @param centerMesh The mesh to be center of explosion.
  58580. */
  58581. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58582. private _setCenterMesh;
  58583. /**
  58584. * Get class name
  58585. * @returns "MeshExploder"
  58586. */
  58587. getClassName(): string;
  58588. /**
  58589. * "Exploded meshes"
  58590. * @returns Array of meshes with the centerMesh at index 0.
  58591. */
  58592. getMeshes(): Array<Mesh>;
  58593. /**
  58594. * Explodes meshes giving a specific direction
  58595. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58596. */
  58597. explode(direction?: number): void;
  58598. }
  58599. }
  58600. declare module "babylonjs/Misc/filesInput" {
  58601. import { Engine } from "babylonjs/Engines/engine";
  58602. import { Scene } from "babylonjs/scene";
  58603. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58604. /**
  58605. * Class used to help managing file picking and drag'n'drop
  58606. */
  58607. export class FilesInput {
  58608. /**
  58609. * List of files ready to be loaded
  58610. */
  58611. static readonly FilesToLoad: {
  58612. [key: string]: File;
  58613. };
  58614. /**
  58615. * Callback called when a file is processed
  58616. */
  58617. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58618. private _engine;
  58619. private _currentScene;
  58620. private _sceneLoadedCallback;
  58621. private _progressCallback;
  58622. private _additionalRenderLoopLogicCallback;
  58623. private _textureLoadingCallback;
  58624. private _startingProcessingFilesCallback;
  58625. private _onReloadCallback;
  58626. private _errorCallback;
  58627. private _elementToMonitor;
  58628. private _sceneFileToLoad;
  58629. private _filesToLoad;
  58630. /**
  58631. * Creates a new FilesInput
  58632. * @param engine defines the rendering engine
  58633. * @param scene defines the hosting scene
  58634. * @param sceneLoadedCallback callback called when scene is loaded
  58635. * @param progressCallback callback called to track progress
  58636. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58637. * @param textureLoadingCallback callback called when a texture is loading
  58638. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58639. * @param onReloadCallback callback called when a reload is requested
  58640. * @param errorCallback callback call if an error occurs
  58641. */
  58642. 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);
  58643. private _dragEnterHandler;
  58644. private _dragOverHandler;
  58645. private _dropHandler;
  58646. /**
  58647. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58648. * @param elementToMonitor defines the DOM element to track
  58649. */
  58650. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58651. /**
  58652. * Release all associated resources
  58653. */
  58654. dispose(): void;
  58655. private renderFunction;
  58656. private drag;
  58657. private drop;
  58658. private _traverseFolder;
  58659. private _processFiles;
  58660. /**
  58661. * Load files from a drop event
  58662. * @param event defines the drop event to use as source
  58663. */
  58664. loadFiles(event: any): void;
  58665. private _processReload;
  58666. /**
  58667. * Reload the current scene from the loaded files
  58668. */
  58669. reload(): void;
  58670. }
  58671. }
  58672. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58673. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58674. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58675. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58676. }
  58677. declare module "babylonjs/Misc/sceneOptimizer" {
  58678. import { Scene, IDisposable } from "babylonjs/scene";
  58679. import { Observable } from "babylonjs/Misc/observable";
  58680. /**
  58681. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58682. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58683. */
  58684. export class SceneOptimization {
  58685. /**
  58686. * Defines the priority of this optimization (0 by default which means first in the list)
  58687. */
  58688. priority: number;
  58689. /**
  58690. * Gets a string describing the action executed by the current optimization
  58691. * @returns description string
  58692. */
  58693. getDescription(): string;
  58694. /**
  58695. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58696. * @param scene defines the current scene where to apply this optimization
  58697. * @param optimizer defines the current optimizer
  58698. * @returns true if everything that can be done was applied
  58699. */
  58700. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58701. /**
  58702. * Creates the SceneOptimization object
  58703. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58704. * @param desc defines the description associated with the optimization
  58705. */
  58706. constructor(
  58707. /**
  58708. * Defines the priority of this optimization (0 by default which means first in the list)
  58709. */
  58710. priority?: number);
  58711. }
  58712. /**
  58713. * Defines an optimization used to reduce the size of render target textures
  58714. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58715. */
  58716. export class TextureOptimization extends SceneOptimization {
  58717. /**
  58718. * Defines the priority of this optimization (0 by default which means first in the list)
  58719. */
  58720. priority: number;
  58721. /**
  58722. * 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
  58723. */
  58724. maximumSize: number;
  58725. /**
  58726. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58727. */
  58728. step: number;
  58729. /**
  58730. * Gets a string describing the action executed by the current optimization
  58731. * @returns description string
  58732. */
  58733. getDescription(): string;
  58734. /**
  58735. * Creates the TextureOptimization object
  58736. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58737. * @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
  58738. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58739. */
  58740. constructor(
  58741. /**
  58742. * Defines the priority of this optimization (0 by default which means first in the list)
  58743. */
  58744. priority?: number,
  58745. /**
  58746. * 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
  58747. */
  58748. maximumSize?: number,
  58749. /**
  58750. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58751. */
  58752. step?: number);
  58753. /**
  58754. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58755. * @param scene defines the current scene where to apply this optimization
  58756. * @param optimizer defines the current optimizer
  58757. * @returns true if everything that can be done was applied
  58758. */
  58759. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58760. }
  58761. /**
  58762. * Defines an optimization used to increase or decrease the rendering resolution
  58763. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58764. */
  58765. export class HardwareScalingOptimization extends SceneOptimization {
  58766. /**
  58767. * Defines the priority of this optimization (0 by default which means first in the list)
  58768. */
  58769. priority: number;
  58770. /**
  58771. * Defines the maximum scale to use (2 by default)
  58772. */
  58773. maximumScale: number;
  58774. /**
  58775. * Defines the step to use between two passes (0.5 by default)
  58776. */
  58777. step: number;
  58778. private _currentScale;
  58779. private _directionOffset;
  58780. /**
  58781. * Gets a string describing the action executed by the current optimization
  58782. * @return description string
  58783. */
  58784. getDescription(): string;
  58785. /**
  58786. * Creates the HardwareScalingOptimization object
  58787. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58788. * @param maximumScale defines the maximum scale to use (2 by default)
  58789. * @param step defines the step to use between two passes (0.5 by default)
  58790. */
  58791. constructor(
  58792. /**
  58793. * Defines the priority of this optimization (0 by default which means first in the list)
  58794. */
  58795. priority?: number,
  58796. /**
  58797. * Defines the maximum scale to use (2 by default)
  58798. */
  58799. maximumScale?: number,
  58800. /**
  58801. * Defines the step to use between two passes (0.5 by default)
  58802. */
  58803. step?: number);
  58804. /**
  58805. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58806. * @param scene defines the current scene where to apply this optimization
  58807. * @param optimizer defines the current optimizer
  58808. * @returns true if everything that can be done was applied
  58809. */
  58810. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58811. }
  58812. /**
  58813. * Defines an optimization used to remove shadows
  58814. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58815. */
  58816. export class ShadowsOptimization extends SceneOptimization {
  58817. /**
  58818. * Gets a string describing the action executed by the current optimization
  58819. * @return description string
  58820. */
  58821. getDescription(): string;
  58822. /**
  58823. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58824. * @param scene defines the current scene where to apply this optimization
  58825. * @param optimizer defines the current optimizer
  58826. * @returns true if everything that can be done was applied
  58827. */
  58828. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58829. }
  58830. /**
  58831. * Defines an optimization used to turn post-processes off
  58832. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58833. */
  58834. export class PostProcessesOptimization extends SceneOptimization {
  58835. /**
  58836. * Gets a string describing the action executed by the current optimization
  58837. * @return description string
  58838. */
  58839. getDescription(): string;
  58840. /**
  58841. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58842. * @param scene defines the current scene where to apply this optimization
  58843. * @param optimizer defines the current optimizer
  58844. * @returns true if everything that can be done was applied
  58845. */
  58846. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58847. }
  58848. /**
  58849. * Defines an optimization used to turn lens flares off
  58850. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58851. */
  58852. export class LensFlaresOptimization extends SceneOptimization {
  58853. /**
  58854. * Gets a string describing the action executed by the current optimization
  58855. * @return description string
  58856. */
  58857. getDescription(): string;
  58858. /**
  58859. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58860. * @param scene defines the current scene where to apply this optimization
  58861. * @param optimizer defines the current optimizer
  58862. * @returns true if everything that can be done was applied
  58863. */
  58864. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58865. }
  58866. /**
  58867. * Defines an optimization based on user defined callback.
  58868. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58869. */
  58870. export class CustomOptimization extends SceneOptimization {
  58871. /**
  58872. * Callback called to apply the custom optimization.
  58873. */
  58874. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58875. /**
  58876. * Callback called to get custom description
  58877. */
  58878. onGetDescription: () => string;
  58879. /**
  58880. * Gets a string describing the action executed by the current optimization
  58881. * @returns description string
  58882. */
  58883. getDescription(): string;
  58884. /**
  58885. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58886. * @param scene defines the current scene where to apply this optimization
  58887. * @param optimizer defines the current optimizer
  58888. * @returns true if everything that can be done was applied
  58889. */
  58890. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58891. }
  58892. /**
  58893. * Defines an optimization used to turn particles off
  58894. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58895. */
  58896. export class ParticlesOptimization extends SceneOptimization {
  58897. /**
  58898. * Gets a string describing the action executed by the current optimization
  58899. * @return description string
  58900. */
  58901. getDescription(): string;
  58902. /**
  58903. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58904. * @param scene defines the current scene where to apply this optimization
  58905. * @param optimizer defines the current optimizer
  58906. * @returns true if everything that can be done was applied
  58907. */
  58908. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58909. }
  58910. /**
  58911. * Defines an optimization used to turn render targets off
  58912. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58913. */
  58914. export class RenderTargetsOptimization extends SceneOptimization {
  58915. /**
  58916. * Gets a string describing the action executed by the current optimization
  58917. * @return description string
  58918. */
  58919. getDescription(): string;
  58920. /**
  58921. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58922. * @param scene defines the current scene where to apply this optimization
  58923. * @param optimizer defines the current optimizer
  58924. * @returns true if everything that can be done was applied
  58925. */
  58926. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58927. }
  58928. /**
  58929. * Defines an optimization used to merge meshes with compatible materials
  58930. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58931. */
  58932. export class MergeMeshesOptimization extends SceneOptimization {
  58933. private static _UpdateSelectionTree;
  58934. /**
  58935. * Gets or sets a boolean which defines if optimization octree has to be updated
  58936. */
  58937. /**
  58938. * Gets or sets a boolean which defines if optimization octree has to be updated
  58939. */
  58940. static UpdateSelectionTree: boolean;
  58941. /**
  58942. * Gets a string describing the action executed by the current optimization
  58943. * @return description string
  58944. */
  58945. getDescription(): string;
  58946. private _canBeMerged;
  58947. /**
  58948. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58949. * @param scene defines the current scene where to apply this optimization
  58950. * @param optimizer defines the current optimizer
  58951. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58952. * @returns true if everything that can be done was applied
  58953. */
  58954. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58955. }
  58956. /**
  58957. * Defines a list of options used by SceneOptimizer
  58958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58959. */
  58960. export class SceneOptimizerOptions {
  58961. /**
  58962. * Defines the target frame rate to reach (60 by default)
  58963. */
  58964. targetFrameRate: number;
  58965. /**
  58966. * Defines the interval between two checkes (2000ms by default)
  58967. */
  58968. trackerDuration: number;
  58969. /**
  58970. * Gets the list of optimizations to apply
  58971. */
  58972. optimizations: SceneOptimization[];
  58973. /**
  58974. * Creates a new list of options used by SceneOptimizer
  58975. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58976. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58977. */
  58978. constructor(
  58979. /**
  58980. * Defines the target frame rate to reach (60 by default)
  58981. */
  58982. targetFrameRate?: number,
  58983. /**
  58984. * Defines the interval between two checkes (2000ms by default)
  58985. */
  58986. trackerDuration?: number);
  58987. /**
  58988. * Add a new optimization
  58989. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58990. * @returns the current SceneOptimizerOptions
  58991. */
  58992. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58993. /**
  58994. * Add a new custom optimization
  58995. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58996. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58997. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58998. * @returns the current SceneOptimizerOptions
  58999. */
  59000. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59001. /**
  59002. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59003. * @param targetFrameRate defines the target frame rate (60 by default)
  59004. * @returns a SceneOptimizerOptions object
  59005. */
  59006. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59007. /**
  59008. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59009. * @param targetFrameRate defines the target frame rate (60 by default)
  59010. * @returns a SceneOptimizerOptions object
  59011. */
  59012. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59013. /**
  59014. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59015. * @param targetFrameRate defines the target frame rate (60 by default)
  59016. * @returns a SceneOptimizerOptions object
  59017. */
  59018. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59019. }
  59020. /**
  59021. * Class used to run optimizations in order to reach a target frame rate
  59022. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59023. */
  59024. export class SceneOptimizer implements IDisposable {
  59025. private _isRunning;
  59026. private _options;
  59027. private _scene;
  59028. private _currentPriorityLevel;
  59029. private _targetFrameRate;
  59030. private _trackerDuration;
  59031. private _currentFrameRate;
  59032. private _sceneDisposeObserver;
  59033. private _improvementMode;
  59034. /**
  59035. * Defines an observable called when the optimizer reaches the target frame rate
  59036. */
  59037. onSuccessObservable: Observable<SceneOptimizer>;
  59038. /**
  59039. * Defines an observable called when the optimizer enables an optimization
  59040. */
  59041. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59042. /**
  59043. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59044. */
  59045. onFailureObservable: Observable<SceneOptimizer>;
  59046. /**
  59047. * Gets a boolean indicating if the optimizer is in improvement mode
  59048. */
  59049. readonly isInImprovementMode: boolean;
  59050. /**
  59051. * Gets the current priority level (0 at start)
  59052. */
  59053. readonly currentPriorityLevel: number;
  59054. /**
  59055. * Gets the current frame rate checked by the SceneOptimizer
  59056. */
  59057. readonly currentFrameRate: number;
  59058. /**
  59059. * Gets or sets the current target frame rate (60 by default)
  59060. */
  59061. /**
  59062. * Gets or sets the current target frame rate (60 by default)
  59063. */
  59064. targetFrameRate: number;
  59065. /**
  59066. * Gets or sets the current interval between two checks (every 2000ms by default)
  59067. */
  59068. /**
  59069. * Gets or sets the current interval between two checks (every 2000ms by default)
  59070. */
  59071. trackerDuration: number;
  59072. /**
  59073. * Gets the list of active optimizations
  59074. */
  59075. readonly optimizations: SceneOptimization[];
  59076. /**
  59077. * Creates a new SceneOptimizer
  59078. * @param scene defines the scene to work on
  59079. * @param options defines the options to use with the SceneOptimizer
  59080. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59081. * @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)
  59082. */
  59083. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59084. /**
  59085. * Stops the current optimizer
  59086. */
  59087. stop(): void;
  59088. /**
  59089. * Reset the optimizer to initial step (current priority level = 0)
  59090. */
  59091. reset(): void;
  59092. /**
  59093. * Start the optimizer. By default it will try to reach a specific framerate
  59094. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59095. */
  59096. start(): void;
  59097. private _checkCurrentState;
  59098. /**
  59099. * Release all resources
  59100. */
  59101. dispose(): void;
  59102. /**
  59103. * Helper function to create a SceneOptimizer with one single line of code
  59104. * @param scene defines the scene to work on
  59105. * @param options defines the options to use with the SceneOptimizer
  59106. * @param onSuccess defines a callback to call on success
  59107. * @param onFailure defines a callback to call on failure
  59108. * @returns the new SceneOptimizer object
  59109. */
  59110. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59111. }
  59112. }
  59113. declare module "babylonjs/Misc/sceneSerializer" {
  59114. import { Scene } from "babylonjs/scene";
  59115. /**
  59116. * Class used to serialize a scene into a string
  59117. */
  59118. export class SceneSerializer {
  59119. /**
  59120. * Clear cache used by a previous serialization
  59121. */
  59122. static ClearCache(): void;
  59123. /**
  59124. * Serialize a scene into a JSON compatible object
  59125. * @param scene defines the scene to serialize
  59126. * @returns a JSON compatible object
  59127. */
  59128. static Serialize(scene: Scene): any;
  59129. /**
  59130. * Serialize a mesh into a JSON compatible object
  59131. * @param toSerialize defines the mesh to serialize
  59132. * @param withParents defines if parents must be serialized as well
  59133. * @param withChildren defines if children must be serialized as well
  59134. * @returns a JSON compatible object
  59135. */
  59136. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59137. }
  59138. }
  59139. declare module "babylonjs/Misc/textureTools" {
  59140. import { Texture } from "babylonjs/Materials/Textures/texture";
  59141. /**
  59142. * Class used to host texture specific utilities
  59143. */
  59144. export class TextureTools {
  59145. /**
  59146. * Uses the GPU to create a copy texture rescaled at a given size
  59147. * @param texture Texture to copy from
  59148. * @param width defines the desired width
  59149. * @param height defines the desired height
  59150. * @param useBilinearMode defines if bilinear mode has to be used
  59151. * @return the generated texture
  59152. */
  59153. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59154. }
  59155. }
  59156. declare module "babylonjs/Misc/videoRecorder" {
  59157. import { Nullable } from "babylonjs/types";
  59158. import { Engine } from "babylonjs/Engines/engine";
  59159. /**
  59160. * This represents the different options avilable for the video capture.
  59161. */
  59162. export interface VideoRecorderOptions {
  59163. /** Defines the mime type of the video */
  59164. mimeType: string;
  59165. /** Defines the video the video should be recorded at */
  59166. fps: number;
  59167. /** Defines the chunk size for the recording data */
  59168. recordChunckSize: number;
  59169. /** The audio tracks to attach to the record */
  59170. audioTracks?: MediaStreamTrack[];
  59171. }
  59172. /**
  59173. * This can helps recording videos from BabylonJS.
  59174. * This is based on the available WebRTC functionalities of the browser.
  59175. *
  59176. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59177. */
  59178. export class VideoRecorder {
  59179. private static readonly _defaultOptions;
  59180. /**
  59181. * Returns wehther or not the VideoRecorder is available in your browser.
  59182. * @param engine Defines the Babylon Engine to check the support for
  59183. * @returns true if supported otherwise false
  59184. */
  59185. static IsSupported(engine: Engine): boolean;
  59186. private readonly _options;
  59187. private _canvas;
  59188. private _mediaRecorder;
  59189. private _recordedChunks;
  59190. private _fileName;
  59191. private _resolve;
  59192. private _reject;
  59193. /**
  59194. * True wether a recording is already in progress.
  59195. */
  59196. readonly isRecording: boolean;
  59197. /**
  59198. * Create a new VideoCapture object which can help converting what you see in Babylon to
  59199. * a video file.
  59200. * @param engine Defines the BabylonJS Engine you wish to record
  59201. * @param options Defines options that can be used to customized the capture
  59202. */
  59203. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59204. /**
  59205. * Stops the current recording before the default capture timeout passed in the startRecording
  59206. * functions.
  59207. */
  59208. stopRecording(): void;
  59209. /**
  59210. * Starts recording the canvas for a max duration specified in parameters.
  59211. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  59212. * @param maxDuration Defines the maximum recording time in seconds.
  59213. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59214. * @return a promise callback at the end of the recording with the video data in Blob.
  59215. */
  59216. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59217. /**
  59218. * Releases internal resources used during the recording.
  59219. */
  59220. dispose(): void;
  59221. private _handleDataAvailable;
  59222. private _handleError;
  59223. private _handleStop;
  59224. }
  59225. }
  59226. declare module "babylonjs/Misc/screenshotTools" {
  59227. import { Camera } from "babylonjs/Cameras/camera";
  59228. import { Engine } from "babylonjs/Engines/engine";
  59229. /**
  59230. * Class containing a set of static utilities functions for screenshots
  59231. */
  59232. export class ScreenshotTools {
  59233. /**
  59234. * Captures a screenshot of the current rendering
  59235. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59236. * @param engine defines the rendering engine
  59237. * @param camera defines the source camera
  59238. * @param size This parameter can be set to a single number or to an object with the
  59239. * following (optional) properties: precision, width, height. If a single number is passed,
  59240. * it will be used for both width and height. If an object is passed, the screenshot size
  59241. * will be derived from the parameters. The precision property is a multiplier allowing
  59242. * rendering at a higher or lower resolution
  59243. * @param successCallback defines the callback receives a single parameter which contains the
  59244. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59245. * src parameter of an <img> to display it
  59246. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59247. * Check your browser for supported MIME types
  59248. */
  59249. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59250. /**
  59251. * Generates an image screenshot from the specified camera.
  59252. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59253. * @param engine The engine to use for rendering
  59254. * @param camera The camera to use for rendering
  59255. * @param size This parameter can be set to a single number or to an object with the
  59256. * following (optional) properties: precision, width, height. If a single number is passed,
  59257. * it will be used for both width and height. If an object is passed, the screenshot size
  59258. * will be derived from the parameters. The precision property is a multiplier allowing
  59259. * rendering at a higher or lower resolution
  59260. * @param successCallback The callback receives a single parameter which contains the
  59261. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59262. * src parameter of an <img> to display it
  59263. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59264. * Check your browser for supported MIME types
  59265. * @param samples Texture samples (default: 1)
  59266. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59267. * @param fileName A name for for the downloaded file.
  59268. */
  59269. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59270. }
  59271. }
  59272. declare module "babylonjs/Misc/index" {
  59273. export * from "babylonjs/Misc/andOrNotEvaluator";
  59274. export * from "babylonjs/Misc/assetsManager";
  59275. export * from "babylonjs/Misc/dds";
  59276. export * from "babylonjs/Misc/decorators";
  59277. export * from "babylonjs/Misc/deferred";
  59278. export * from "babylonjs/Misc/environmentTextureTools";
  59279. export * from "babylonjs/Misc/meshExploder";
  59280. export * from "babylonjs/Misc/filesInput";
  59281. export * from "babylonjs/Misc/HighDynamicRange/index";
  59282. export * from "babylonjs/Misc/khronosTextureContainer";
  59283. export * from "babylonjs/Misc/observable";
  59284. export * from "babylonjs/Misc/performanceMonitor";
  59285. export * from "babylonjs/Misc/promise";
  59286. export * from "babylonjs/Misc/sceneOptimizer";
  59287. export * from "babylonjs/Misc/sceneSerializer";
  59288. export * from "babylonjs/Misc/smartArray";
  59289. export * from "babylonjs/Misc/stringDictionary";
  59290. export * from "babylonjs/Misc/tags";
  59291. export * from "babylonjs/Misc/textureTools";
  59292. export * from "babylonjs/Misc/tga";
  59293. export * from "babylonjs/Misc/tools";
  59294. export * from "babylonjs/Misc/videoRecorder";
  59295. export * from "babylonjs/Misc/virtualJoystick";
  59296. export * from "babylonjs/Misc/workerPool";
  59297. export * from "babylonjs/Misc/logger";
  59298. export * from "babylonjs/Misc/typeStore";
  59299. export * from "babylonjs/Misc/filesInputStore";
  59300. export * from "babylonjs/Misc/deepCopier";
  59301. export * from "babylonjs/Misc/pivotTools";
  59302. export * from "babylonjs/Misc/precisionDate";
  59303. export * from "babylonjs/Misc/screenshotTools";
  59304. export * from "babylonjs/Misc/typeStore";
  59305. export * from "babylonjs/Misc/webRequest";
  59306. export * from "babylonjs/Misc/iInspectable";
  59307. }
  59308. declare module "babylonjs/index" {
  59309. export * from "babylonjs/abstractScene";
  59310. export * from "babylonjs/Actions/index";
  59311. export * from "babylonjs/Animations/index";
  59312. export * from "babylonjs/assetContainer";
  59313. export * from "babylonjs/Audio/index";
  59314. export * from "babylonjs/Behaviors/index";
  59315. export * from "babylonjs/Bones/index";
  59316. export * from "babylonjs/Cameras/index";
  59317. export * from "babylonjs/Collisions/index";
  59318. export * from "babylonjs/Culling/index";
  59319. export * from "babylonjs/Debug/index";
  59320. export * from "babylonjs/Engines/index";
  59321. export * from "babylonjs/Events/index";
  59322. export * from "babylonjs/Gamepads/index";
  59323. export * from "babylonjs/Gizmos/index";
  59324. export * from "babylonjs/Helpers/index";
  59325. export * from "babylonjs/Instrumentation/index";
  59326. export * from "babylonjs/Layers/index";
  59327. export * from "babylonjs/LensFlares/index";
  59328. export * from "babylonjs/Lights/index";
  59329. export * from "babylonjs/Loading/index";
  59330. export * from "babylonjs/Materials/index";
  59331. export * from "babylonjs/Maths/index";
  59332. export * from "babylonjs/Meshes/index";
  59333. export * from "babylonjs/Morph/index";
  59334. export * from "babylonjs/node";
  59335. export * from "babylonjs/Offline/index";
  59336. export * from "babylonjs/Particles/index";
  59337. export * from "babylonjs/Physics/index";
  59338. export * from "babylonjs/PostProcesses/index";
  59339. export * from "babylonjs/Probes/index";
  59340. export * from "babylonjs/Rendering/index";
  59341. export * from "babylonjs/scene";
  59342. export * from "babylonjs/sceneComponent";
  59343. export * from "babylonjs/Sprites/index";
  59344. export * from "babylonjs/States/index";
  59345. export * from "babylonjs/Misc/index";
  59346. export * from "babylonjs/types";
  59347. }
  59348. declare module "babylonjs/Animations/pathCursor" {
  59349. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59350. /**
  59351. * A cursor which tracks a point on a path
  59352. */
  59353. export class PathCursor {
  59354. private path;
  59355. /**
  59356. * Stores path cursor callbacks for when an onchange event is triggered
  59357. */
  59358. private _onchange;
  59359. /**
  59360. * The value of the path cursor
  59361. */
  59362. value: number;
  59363. /**
  59364. * The animation array of the path cursor
  59365. */
  59366. animations: Animation[];
  59367. /**
  59368. * Initializes the path cursor
  59369. * @param path The path to track
  59370. */
  59371. constructor(path: Path2);
  59372. /**
  59373. * Gets the cursor point on the path
  59374. * @returns A point on the path cursor at the cursor location
  59375. */
  59376. getPoint(): Vector3;
  59377. /**
  59378. * Moves the cursor ahead by the step amount
  59379. * @param step The amount to move the cursor forward
  59380. * @returns This path cursor
  59381. */
  59382. moveAhead(step?: number): PathCursor;
  59383. /**
  59384. * Moves the cursor behind by the step amount
  59385. * @param step The amount to move the cursor back
  59386. * @returns This path cursor
  59387. */
  59388. moveBack(step?: number): PathCursor;
  59389. /**
  59390. * Moves the cursor by the step amount
  59391. * If the step amount is greater than one, an exception is thrown
  59392. * @param step The amount to move the cursor
  59393. * @returns This path cursor
  59394. */
  59395. move(step: number): PathCursor;
  59396. /**
  59397. * Ensures that the value is limited between zero and one
  59398. * @returns This path cursor
  59399. */
  59400. private ensureLimits;
  59401. /**
  59402. * Runs onchange callbacks on change (used by the animation engine)
  59403. * @returns This path cursor
  59404. */
  59405. private raiseOnChange;
  59406. /**
  59407. * Executes a function on change
  59408. * @param f A path cursor onchange callback
  59409. * @returns This path cursor
  59410. */
  59411. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59412. }
  59413. }
  59414. declare module "babylonjs/Legacy/legacy" {
  59415. import * as Babylon from "babylonjs/index";
  59416. export * from "babylonjs/index";
  59417. }
  59418. declare module "babylonjs/Shaders/blur.fragment" {
  59419. /** @hidden */
  59420. export var blurPixelShader: {
  59421. name: string;
  59422. shader: string;
  59423. };
  59424. }
  59425. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59426. /** @hidden */
  59427. export var bones300Declaration: {
  59428. name: string;
  59429. shader: string;
  59430. };
  59431. }
  59432. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59433. /** @hidden */
  59434. export var instances300Declaration: {
  59435. name: string;
  59436. shader: string;
  59437. };
  59438. }
  59439. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59440. /** @hidden */
  59441. export var pointCloudVertexDeclaration: {
  59442. name: string;
  59443. shader: string;
  59444. };
  59445. }
  59446. // Mixins
  59447. interface Window {
  59448. mozIndexedDB: IDBFactory;
  59449. webkitIndexedDB: IDBFactory;
  59450. msIndexedDB: IDBFactory;
  59451. webkitURL: typeof URL;
  59452. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59453. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59454. WebGLRenderingContext: WebGLRenderingContext;
  59455. MSGesture: MSGesture;
  59456. CANNON: any;
  59457. AudioContext: AudioContext;
  59458. webkitAudioContext: AudioContext;
  59459. PointerEvent: any;
  59460. Math: Math;
  59461. Uint8Array: Uint8ArrayConstructor;
  59462. Float32Array: Float32ArrayConstructor;
  59463. mozURL: typeof URL;
  59464. msURL: typeof URL;
  59465. VRFrameData: any; // WebVR, from specs 1.1
  59466. DracoDecoderModule: any;
  59467. setImmediate(handler: (...args: any[]) => void): number;
  59468. }
  59469. interface HTMLCanvasElement {
  59470. requestPointerLock(): void;
  59471. msRequestPointerLock?(): void;
  59472. mozRequestPointerLock?(): void;
  59473. webkitRequestPointerLock?(): void;
  59474. /** Track wether a record is in progress */
  59475. isRecording: boolean;
  59476. /** Capture Stream method defined by some browsers */
  59477. captureStream(fps?: number): MediaStream;
  59478. }
  59479. interface CanvasRenderingContext2D {
  59480. msImageSmoothingEnabled: boolean;
  59481. }
  59482. interface MouseEvent {
  59483. mozMovementX: number;
  59484. mozMovementY: number;
  59485. webkitMovementX: number;
  59486. webkitMovementY: number;
  59487. msMovementX: number;
  59488. msMovementY: number;
  59489. }
  59490. interface Navigator {
  59491. mozGetVRDevices: (any: any) => any;
  59492. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59493. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59494. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59495. webkitGetGamepads(): Gamepad[];
  59496. msGetGamepads(): Gamepad[];
  59497. webkitGamepads(): Gamepad[];
  59498. }
  59499. interface HTMLVideoElement {
  59500. mozSrcObject: any;
  59501. }
  59502. interface Math {
  59503. fround(x: number): number;
  59504. imul(a: number, b: number): number;
  59505. }
  59506. interface WebGLRenderingContext {
  59507. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59508. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59509. vertexAttribDivisor(index: number, divisor: number): void;
  59510. createVertexArray(): any;
  59511. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59512. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59513. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59514. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59515. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59516. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59517. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59518. // Queries
  59519. createQuery(): WebGLQuery;
  59520. deleteQuery(query: WebGLQuery): void;
  59521. beginQuery(target: number, query: WebGLQuery): void;
  59522. endQuery(target: number): void;
  59523. getQueryParameter(query: WebGLQuery, pname: number): any;
  59524. getQuery(target: number, pname: number): any;
  59525. MAX_SAMPLES: number;
  59526. RGBA8: number;
  59527. READ_FRAMEBUFFER: number;
  59528. DRAW_FRAMEBUFFER: number;
  59529. UNIFORM_BUFFER: number;
  59530. HALF_FLOAT_OES: number;
  59531. RGBA16F: number;
  59532. RGBA32F: number;
  59533. R32F: number;
  59534. RG32F: number;
  59535. RGB32F: number;
  59536. R16F: number;
  59537. RG16F: number;
  59538. RGB16F: number;
  59539. RED: number;
  59540. RG: number;
  59541. R8: number;
  59542. RG8: number;
  59543. UNSIGNED_INT_24_8: number;
  59544. DEPTH24_STENCIL8: number;
  59545. /* Multiple Render Targets */
  59546. drawBuffers(buffers: number[]): void;
  59547. readBuffer(src: number): void;
  59548. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59549. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59550. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59551. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59552. // Occlusion Query
  59553. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59554. ANY_SAMPLES_PASSED: number;
  59555. QUERY_RESULT_AVAILABLE: number;
  59556. QUERY_RESULT: number;
  59557. }
  59558. interface WebGLProgram {
  59559. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59560. }
  59561. interface EXT_disjoint_timer_query {
  59562. QUERY_COUNTER_BITS_EXT: number;
  59563. TIME_ELAPSED_EXT: number;
  59564. TIMESTAMP_EXT: number;
  59565. GPU_DISJOINT_EXT: number;
  59566. QUERY_RESULT_EXT: number;
  59567. QUERY_RESULT_AVAILABLE_EXT: number;
  59568. queryCounterEXT(query: WebGLQuery, target: number): void;
  59569. createQueryEXT(): WebGLQuery;
  59570. beginQueryEXT(target: number, query: WebGLQuery): void;
  59571. endQueryEXT(target: number): void;
  59572. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59573. deleteQueryEXT(query: WebGLQuery): void;
  59574. }
  59575. interface WebGLUniformLocation {
  59576. _currentState: any;
  59577. }
  59578. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59579. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59580. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59581. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59582. interface WebGLRenderingContext {
  59583. readonly RASTERIZER_DISCARD: number;
  59584. readonly DEPTH_COMPONENT24: number;
  59585. readonly TEXTURE_3D: number;
  59586. readonly TEXTURE_2D_ARRAY: number;
  59587. readonly TEXTURE_COMPARE_FUNC: number;
  59588. readonly TEXTURE_COMPARE_MODE: number;
  59589. readonly COMPARE_REF_TO_TEXTURE: number;
  59590. readonly TEXTURE_WRAP_R: number;
  59591. readonly HALF_FLOAT: number;
  59592. readonly RGB8: number;
  59593. readonly RED_INTEGER: number;
  59594. readonly RG_INTEGER: number;
  59595. readonly RGB_INTEGER: number;
  59596. readonly RGBA_INTEGER: number;
  59597. readonly R8_SNORM: number;
  59598. readonly RG8_SNORM: number;
  59599. readonly RGB8_SNORM: number;
  59600. readonly RGBA8_SNORM: number;
  59601. readonly R8I: number;
  59602. readonly RG8I: number;
  59603. readonly RGB8I: number;
  59604. readonly RGBA8I: number;
  59605. readonly R8UI: number;
  59606. readonly RG8UI: number;
  59607. readonly RGB8UI: number;
  59608. readonly RGBA8UI: number;
  59609. readonly R16I: number;
  59610. readonly RG16I: number;
  59611. readonly RGB16I: number;
  59612. readonly RGBA16I: number;
  59613. readonly R16UI: number;
  59614. readonly RG16UI: number;
  59615. readonly RGB16UI: number;
  59616. readonly RGBA16UI: number;
  59617. readonly R32I: number;
  59618. readonly RG32I: number;
  59619. readonly RGB32I: number;
  59620. readonly RGBA32I: number;
  59621. readonly R32UI: number;
  59622. readonly RG32UI: number;
  59623. readonly RGB32UI: number;
  59624. readonly RGBA32UI: number;
  59625. readonly RGB10_A2UI: number;
  59626. readonly R11F_G11F_B10F: number;
  59627. readonly RGB9_E5: number;
  59628. readonly RGB10_A2: number;
  59629. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59630. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59631. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59632. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59633. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59634. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59635. 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;
  59636. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59637. readonly TRANSFORM_FEEDBACK: number;
  59638. readonly INTERLEAVED_ATTRIBS: number;
  59639. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59640. createTransformFeedback(): WebGLTransformFeedback;
  59641. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59642. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59643. beginTransformFeedback(primitiveMode: number): void;
  59644. endTransformFeedback(): void;
  59645. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59646. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59647. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59648. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59649. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59650. }
  59651. interface ImageBitmap {
  59652. readonly width: number;
  59653. readonly height: number;
  59654. close(): void;
  59655. }
  59656. interface WebGLQuery extends WebGLObject {
  59657. }
  59658. declare var WebGLQuery: {
  59659. prototype: WebGLQuery;
  59660. new(): WebGLQuery;
  59661. };
  59662. interface WebGLSampler extends WebGLObject {
  59663. }
  59664. declare var WebGLSampler: {
  59665. prototype: WebGLSampler;
  59666. new(): WebGLSampler;
  59667. };
  59668. interface WebGLSync extends WebGLObject {
  59669. }
  59670. declare var WebGLSync: {
  59671. prototype: WebGLSync;
  59672. new(): WebGLSync;
  59673. };
  59674. interface WebGLTransformFeedback extends WebGLObject {
  59675. }
  59676. declare var WebGLTransformFeedback: {
  59677. prototype: WebGLTransformFeedback;
  59678. new(): WebGLTransformFeedback;
  59679. };
  59680. interface WebGLVertexArrayObject extends WebGLObject {
  59681. }
  59682. declare var WebGLVertexArrayObject: {
  59683. prototype: WebGLVertexArrayObject;
  59684. new(): WebGLVertexArrayObject;
  59685. };
  59686. // Type definitions for WebVR API
  59687. // Project: https://w3c.github.io/webvr/
  59688. // Definitions by: six a <https://github.com/lostfictions>
  59689. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59690. interface VRDisplay extends EventTarget {
  59691. /**
  59692. * Dictionary of capabilities describing the VRDisplay.
  59693. */
  59694. readonly capabilities: VRDisplayCapabilities;
  59695. /**
  59696. * z-depth defining the far plane of the eye view frustum
  59697. * enables mapping of values in the render target depth
  59698. * attachment to scene coordinates. Initially set to 10000.0.
  59699. */
  59700. depthFar: number;
  59701. /**
  59702. * z-depth defining the near plane of the eye view frustum
  59703. * enables mapping of values in the render target depth
  59704. * attachment to scene coordinates. Initially set to 0.01.
  59705. */
  59706. depthNear: number;
  59707. /**
  59708. * An identifier for this distinct VRDisplay. Used as an
  59709. * association point in the Gamepad API.
  59710. */
  59711. readonly displayId: number;
  59712. /**
  59713. * A display name, a user-readable name identifying it.
  59714. */
  59715. readonly displayName: string;
  59716. readonly isConnected: boolean;
  59717. readonly isPresenting: boolean;
  59718. /**
  59719. * If this VRDisplay supports room-scale experiences, the optional
  59720. * stage attribute contains details on the room-scale parameters.
  59721. */
  59722. readonly stageParameters: VRStageParameters | null;
  59723. /**
  59724. * Passing the value returned by `requestAnimationFrame` to
  59725. * `cancelAnimationFrame` will unregister the callback.
  59726. * @param handle Define the hanle of the request to cancel
  59727. */
  59728. cancelAnimationFrame(handle: number): void;
  59729. /**
  59730. * Stops presenting to the VRDisplay.
  59731. * @returns a promise to know when it stopped
  59732. */
  59733. exitPresent(): Promise<void>;
  59734. /**
  59735. * Return the current VREyeParameters for the given eye.
  59736. * @param whichEye Define the eye we want the parameter for
  59737. * @returns the eye parameters
  59738. */
  59739. getEyeParameters(whichEye: string): VREyeParameters;
  59740. /**
  59741. * Populates the passed VRFrameData with the information required to render
  59742. * the current frame.
  59743. * @param frameData Define the data structure to populate
  59744. * @returns true if ok otherwise false
  59745. */
  59746. getFrameData(frameData: VRFrameData): boolean;
  59747. /**
  59748. * Get the layers currently being presented.
  59749. * @returns the list of VR layers
  59750. */
  59751. getLayers(): VRLayer[];
  59752. /**
  59753. * Return a VRPose containing the future predicted pose of the VRDisplay
  59754. * when the current frame will be presented. The value returned will not
  59755. * change until JavaScript has returned control to the browser.
  59756. *
  59757. * The VRPose will contain the position, orientation, velocity,
  59758. * and acceleration of each of these properties.
  59759. * @returns the pose object
  59760. */
  59761. getPose(): VRPose;
  59762. /**
  59763. * Return the current instantaneous pose of the VRDisplay, with no
  59764. * prediction applied.
  59765. * @returns the current instantaneous pose
  59766. */
  59767. getImmediatePose(): VRPose;
  59768. /**
  59769. * The callback passed to `requestAnimationFrame` will be called
  59770. * any time a new frame should be rendered. When the VRDisplay is
  59771. * presenting the callback will be called at the native refresh
  59772. * rate of the HMD. When not presenting this function acts
  59773. * identically to how window.requestAnimationFrame acts. Content should
  59774. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59775. * asynchronously from other displays and at differing refresh rates.
  59776. * @param callback Define the eaction to run next frame
  59777. * @returns the request handle it
  59778. */
  59779. requestAnimationFrame(callback: FrameRequestCallback): number;
  59780. /**
  59781. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59782. * Repeat calls while already presenting will update the VRLayers being displayed.
  59783. * @param layers Define the list of layer to present
  59784. * @returns a promise to know when the request has been fulfilled
  59785. */
  59786. requestPresent(layers: VRLayer[]): Promise<void>;
  59787. /**
  59788. * Reset the pose for this display, treating its current position and
  59789. * orientation as the "origin/zero" values. VRPose.position,
  59790. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59791. * updated when calling resetPose(). This should be called in only
  59792. * sitting-space experiences.
  59793. */
  59794. resetPose(): void;
  59795. /**
  59796. * The VRLayer provided to the VRDisplay will be captured and presented
  59797. * in the HMD. Calling this function has the same effect on the source
  59798. * canvas as any other operation that uses its source image, and canvases
  59799. * created without preserveDrawingBuffer set to true will be cleared.
  59800. * @param pose Define the pose to submit
  59801. */
  59802. submitFrame(pose?: VRPose): void;
  59803. }
  59804. declare var VRDisplay: {
  59805. prototype: VRDisplay;
  59806. new(): VRDisplay;
  59807. };
  59808. interface VRLayer {
  59809. leftBounds?: number[] | Float32Array | null;
  59810. rightBounds?: number[] | Float32Array | null;
  59811. source?: HTMLCanvasElement | null;
  59812. }
  59813. interface VRDisplayCapabilities {
  59814. readonly canPresent: boolean;
  59815. readonly hasExternalDisplay: boolean;
  59816. readonly hasOrientation: boolean;
  59817. readonly hasPosition: boolean;
  59818. readonly maxLayers: number;
  59819. }
  59820. interface VREyeParameters {
  59821. /** @deprecated */
  59822. readonly fieldOfView: VRFieldOfView;
  59823. readonly offset: Float32Array;
  59824. readonly renderHeight: number;
  59825. readonly renderWidth: number;
  59826. }
  59827. interface VRFieldOfView {
  59828. readonly downDegrees: number;
  59829. readonly leftDegrees: number;
  59830. readonly rightDegrees: number;
  59831. readonly upDegrees: number;
  59832. }
  59833. interface VRFrameData {
  59834. readonly leftProjectionMatrix: Float32Array;
  59835. readonly leftViewMatrix: Float32Array;
  59836. readonly pose: VRPose;
  59837. readonly rightProjectionMatrix: Float32Array;
  59838. readonly rightViewMatrix: Float32Array;
  59839. readonly timestamp: number;
  59840. }
  59841. interface VRPose {
  59842. readonly angularAcceleration: Float32Array | null;
  59843. readonly angularVelocity: Float32Array | null;
  59844. readonly linearAcceleration: Float32Array | null;
  59845. readonly linearVelocity: Float32Array | null;
  59846. readonly orientation: Float32Array | null;
  59847. readonly position: Float32Array | null;
  59848. readonly timestamp: number;
  59849. }
  59850. interface VRStageParameters {
  59851. sittingToStandingTransform?: Float32Array;
  59852. sizeX?: number;
  59853. sizeY?: number;
  59854. }
  59855. interface Navigator {
  59856. getVRDisplays(): Promise<VRDisplay[]>;
  59857. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59858. }
  59859. interface Window {
  59860. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59861. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59862. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59863. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59864. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59865. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59866. }
  59867. interface Gamepad {
  59868. readonly displayId: number;
  59869. }
  59870. interface XRDevice {
  59871. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59872. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59873. }
  59874. interface XRSession {
  59875. getInputSources(): Array<any>;
  59876. baseLayer: XRWebGLLayer;
  59877. requestFrameOfReference(type: string): Promise<void>;
  59878. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59879. end(): Promise<void>;
  59880. requestAnimationFrame: Function;
  59881. addEventListener: Function;
  59882. }
  59883. interface XRSessionCreationOptions {
  59884. outputContext?: WebGLRenderingContext | null;
  59885. immersive?: boolean;
  59886. environmentIntegration?: boolean;
  59887. }
  59888. interface XRLayer {
  59889. getViewport: Function;
  59890. framebufferWidth: number;
  59891. framebufferHeight: number;
  59892. }
  59893. interface XRView {
  59894. projectionMatrix: Float32Array;
  59895. }
  59896. interface XRFrame {
  59897. getDevicePose: Function;
  59898. getInputPose: Function;
  59899. views: Array<XRView>;
  59900. baseLayer: XRLayer;
  59901. }
  59902. interface XRFrameOfReference {
  59903. }
  59904. interface XRWebGLLayer extends XRLayer {
  59905. framebuffer: WebGLFramebuffer;
  59906. }
  59907. declare var XRWebGLLayer: {
  59908. prototype: XRWebGLLayer;
  59909. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59910. };
  59911. declare module "babylonjs" {
  59912. export * from "babylonjs/Legacy/legacy";
  59913. }
  59914. declare module BABYLON {
  59915. /** Alias type for value that can be null */
  59916. export type Nullable<T> = T | null;
  59917. /**
  59918. * Alias type for number that are floats
  59919. * @ignorenaming
  59920. */
  59921. export type float = number;
  59922. /**
  59923. * Alias type for number that are doubles.
  59924. * @ignorenaming
  59925. */
  59926. export type double = number;
  59927. /**
  59928. * Alias type for number that are integer
  59929. * @ignorenaming
  59930. */
  59931. export type int = number;
  59932. /** Alias type for number array or Float32Array */
  59933. export type FloatArray = number[] | Float32Array;
  59934. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59935. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59936. /**
  59937. * Alias for types that can be used by a Buffer or VertexBuffer.
  59938. */
  59939. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59940. /**
  59941. * Alias type for primitive types
  59942. * @ignorenaming
  59943. */
  59944. type Primitive = undefined | null | boolean | string | number | Function;
  59945. /**
  59946. * Type modifier to make all the properties of an object Readonly
  59947. */
  59948. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59949. /**
  59950. * Type modifier to make all the properties of an object Readonly recursively
  59951. */
  59952. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59953. /** @hidden */
  59954. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59955. }
  59956. /** @hidden */
  59957. /** @hidden */
  59958. type DeepImmutableObject<T> = {
  59959. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59960. };
  59961. }
  59962. declare module BABYLON {
  59963. /**
  59964. * Class containing a set of static utilities functions for arrays.
  59965. */
  59966. export class ArrayTools {
  59967. /**
  59968. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59969. * @param size the number of element to construct and put in the array
  59970. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59971. * @returns a new array filled with new objects
  59972. */
  59973. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59974. }
  59975. }
  59976. declare module BABYLON {
  59977. /**
  59978. * Scalar computation library
  59979. */
  59980. export class Scalar {
  59981. /**
  59982. * Two pi constants convenient for computation.
  59983. */
  59984. static TwoPi: number;
  59985. /**
  59986. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59987. * @param a number
  59988. * @param b number
  59989. * @param epsilon (default = 1.401298E-45)
  59990. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59991. */
  59992. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59993. /**
  59994. * Returns a string : the upper case translation of the number i to hexadecimal.
  59995. * @param i number
  59996. * @returns the upper case translation of the number i to hexadecimal.
  59997. */
  59998. static ToHex(i: number): string;
  59999. /**
  60000. * Returns -1 if value is negative and +1 is value is positive.
  60001. * @param value the value
  60002. * @returns the value itself if it's equal to zero.
  60003. */
  60004. static Sign(value: number): number;
  60005. /**
  60006. * Returns the value itself if it's between min and max.
  60007. * Returns min if the value is lower than min.
  60008. * Returns max if the value is greater than max.
  60009. * @param value the value to clmap
  60010. * @param min the min value to clamp to (default: 0)
  60011. * @param max the max value to clamp to (default: 1)
  60012. * @returns the clamped value
  60013. */
  60014. static Clamp(value: number, min?: number, max?: number): number;
  60015. /**
  60016. * the log2 of value.
  60017. * @param value the value to compute log2 of
  60018. * @returns the log2 of value.
  60019. */
  60020. static Log2(value: number): number;
  60021. /**
  60022. * Loops the value, so that it is never larger than length and never smaller than 0.
  60023. *
  60024. * This is similar to the modulo operator but it works with floating point numbers.
  60025. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  60026. * With t = 5 and length = 2.5, the result would be 0.0.
  60027. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  60028. * @param value the value
  60029. * @param length the length
  60030. * @returns the looped value
  60031. */
  60032. static Repeat(value: number, length: number): number;
  60033. /**
  60034. * Normalize the value between 0.0 and 1.0 using min and max values
  60035. * @param value value to normalize
  60036. * @param min max to normalize between
  60037. * @param max min to normalize between
  60038. * @returns the normalized value
  60039. */
  60040. static Normalize(value: number, min: number, max: number): number;
  60041. /**
  60042. * Denormalize the value from 0.0 and 1.0 using min and max values
  60043. * @param normalized value to denormalize
  60044. * @param min max to denormalize between
  60045. * @param max min to denormalize between
  60046. * @returns the denormalized value
  60047. */
  60048. static Denormalize(normalized: number, min: number, max: number): number;
  60049. /**
  60050. * Calculates the shortest difference between two given angles given in degrees.
  60051. * @param current current angle in degrees
  60052. * @param target target angle in degrees
  60053. * @returns the delta
  60054. */
  60055. static DeltaAngle(current: number, target: number): number;
  60056. /**
  60057. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  60058. * @param tx value
  60059. * @param length length
  60060. * @returns The returned value will move back and forth between 0 and length
  60061. */
  60062. static PingPong(tx: number, length: number): number;
  60063. /**
  60064. * Interpolates between min and max with smoothing at the limits.
  60065. *
  60066. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  60067. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  60068. * @param from from
  60069. * @param to to
  60070. * @param tx value
  60071. * @returns the smooth stepped value
  60072. */
  60073. static SmoothStep(from: number, to: number, tx: number): number;
  60074. /**
  60075. * Moves a value current towards target.
  60076. *
  60077. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  60078. * Negative values of maxDelta pushes the value away from target.
  60079. * @param current current value
  60080. * @param target target value
  60081. * @param maxDelta max distance to move
  60082. * @returns resulting value
  60083. */
  60084. static MoveTowards(current: number, target: number, maxDelta: number): number;
  60085. /**
  60086. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60087. *
  60088. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  60089. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  60090. * @param current current value
  60091. * @param target target value
  60092. * @param maxDelta max distance to move
  60093. * @returns resulting angle
  60094. */
  60095. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  60096. /**
  60097. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  60098. * @param start start value
  60099. * @param end target value
  60100. * @param amount amount to lerp between
  60101. * @returns the lerped value
  60102. */
  60103. static Lerp(start: number, end: number, amount: number): number;
  60104. /**
  60105. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60106. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  60107. * @param start start value
  60108. * @param end target value
  60109. * @param amount amount to lerp between
  60110. * @returns the lerped value
  60111. */
  60112. static LerpAngle(start: number, end: number, amount: number): number;
  60113. /**
  60114. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  60115. * @param a start value
  60116. * @param b target value
  60117. * @param value value between a and b
  60118. * @returns the inverseLerp value
  60119. */
  60120. static InverseLerp(a: number, b: number, value: number): number;
  60121. /**
  60122. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  60123. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  60124. * @param value1 spline value
  60125. * @param tangent1 spline value
  60126. * @param value2 spline value
  60127. * @param tangent2 spline value
  60128. * @param amount input value
  60129. * @returns hermite result
  60130. */
  60131. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  60132. /**
  60133. * Returns a random float number between and min and max values
  60134. * @param min min value of random
  60135. * @param max max value of random
  60136. * @returns random value
  60137. */
  60138. static RandomRange(min: number, max: number): number;
  60139. /**
  60140. * This function returns percentage of a number in a given range.
  60141. *
  60142. * RangeToPercent(40,20,60) will return 0.5 (50%)
  60143. * RangeToPercent(34,0,100) will return 0.34 (34%)
  60144. * @param number to convert to percentage
  60145. * @param min min range
  60146. * @param max max range
  60147. * @returns the percentage
  60148. */
  60149. static RangeToPercent(number: number, min: number, max: number): number;
  60150. /**
  60151. * This function returns number that corresponds to the percentage in a given range.
  60152. *
  60153. * PercentToRange(0.34,0,100) will return 34.
  60154. * @param percent to convert to number
  60155. * @param min min range
  60156. * @param max max range
  60157. * @returns the number
  60158. */
  60159. static PercentToRange(percent: number, min: number, max: number): number;
  60160. /**
  60161. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  60162. * @param angle The angle to normalize in radian.
  60163. * @return The converted angle.
  60164. */
  60165. static NormalizeRadians(angle: number): number;
  60166. }
  60167. }
  60168. declare module BABYLON {
  60169. /**
  60170. * Constant used to convert a value to gamma space
  60171. * @ignorenaming
  60172. */
  60173. export const ToGammaSpace: number;
  60174. /**
  60175. * Constant used to convert a value to linear space
  60176. * @ignorenaming
  60177. */
  60178. export const ToLinearSpace = 2.2;
  60179. /**
  60180. * Constant used to define the minimal number value in Babylon.js
  60181. * @ignorenaming
  60182. */
  60183. let Epsilon: number;
  60184. /**
  60185. * Class used to hold a RBG color
  60186. */
  60187. export class Color3 {
  60188. /**
  60189. * Defines the red component (between 0 and 1, default is 0)
  60190. */
  60191. r: number;
  60192. /**
  60193. * Defines the green component (between 0 and 1, default is 0)
  60194. */
  60195. g: number;
  60196. /**
  60197. * Defines the blue component (between 0 and 1, default is 0)
  60198. */
  60199. b: number;
  60200. /**
  60201. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  60202. * @param r defines the red component (between 0 and 1, default is 0)
  60203. * @param g defines the green component (between 0 and 1, default is 0)
  60204. * @param b defines the blue component (between 0 and 1, default is 0)
  60205. */
  60206. constructor(
  60207. /**
  60208. * Defines the red component (between 0 and 1, default is 0)
  60209. */
  60210. r?: number,
  60211. /**
  60212. * Defines the green component (between 0 and 1, default is 0)
  60213. */
  60214. g?: number,
  60215. /**
  60216. * Defines the blue component (between 0 and 1, default is 0)
  60217. */
  60218. b?: number);
  60219. /**
  60220. * Creates a string with the Color3 current values
  60221. * @returns the string representation of the Color3 object
  60222. */
  60223. toString(): string;
  60224. /**
  60225. * Returns the string "Color3"
  60226. * @returns "Color3"
  60227. */
  60228. getClassName(): string;
  60229. /**
  60230. * Compute the Color3 hash code
  60231. * @returns an unique number that can be used to hash Color3 objects
  60232. */
  60233. getHashCode(): number;
  60234. /**
  60235. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  60236. * @param array defines the array where to store the r,g,b components
  60237. * @param index defines an optional index in the target array to define where to start storing values
  60238. * @returns the current Color3 object
  60239. */
  60240. toArray(array: FloatArray, index?: number): Color3;
  60241. /**
  60242. * Returns a new Color4 object from the current Color3 and the given alpha
  60243. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  60244. * @returns a new Color4 object
  60245. */
  60246. toColor4(alpha?: number): Color4;
  60247. /**
  60248. * Returns a new array populated with 3 numeric elements : red, green and blue values
  60249. * @returns the new array
  60250. */
  60251. asArray(): number[];
  60252. /**
  60253. * Returns the luminance value
  60254. * @returns a float value
  60255. */
  60256. toLuminance(): number;
  60257. /**
  60258. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  60259. * @param otherColor defines the second operand
  60260. * @returns the new Color3 object
  60261. */
  60262. multiply(otherColor: DeepImmutable<Color3>): Color3;
  60263. /**
  60264. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  60265. * @param otherColor defines the second operand
  60266. * @param result defines the Color3 object where to store the result
  60267. * @returns the current Color3
  60268. */
  60269. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60270. /**
  60271. * Determines equality between Color3 objects
  60272. * @param otherColor defines the second operand
  60273. * @returns true if the rgb values are equal to the given ones
  60274. */
  60275. equals(otherColor: DeepImmutable<Color3>): boolean;
  60276. /**
  60277. * Determines equality between the current Color3 object and a set of r,b,g values
  60278. * @param r defines the red component to check
  60279. * @param g defines the green component to check
  60280. * @param b defines the blue component to check
  60281. * @returns true if the rgb values are equal to the given ones
  60282. */
  60283. equalsFloats(r: number, g: number, b: number): boolean;
  60284. /**
  60285. * Multiplies in place each rgb value by scale
  60286. * @param scale defines the scaling factor
  60287. * @returns the updated Color3
  60288. */
  60289. scale(scale: number): Color3;
  60290. /**
  60291. * Multiplies the rgb values by scale and stores the result into "result"
  60292. * @param scale defines the scaling factor
  60293. * @param result defines the Color3 object where to store the result
  60294. * @returns the unmodified current Color3
  60295. */
  60296. scaleToRef(scale: number, result: Color3): Color3;
  60297. /**
  60298. * Scale the current Color3 values by a factor and add the result to a given Color3
  60299. * @param scale defines the scale factor
  60300. * @param result defines color to store the result into
  60301. * @returns the unmodified current Color3
  60302. */
  60303. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60304. /**
  60305. * Clamps the rgb values by the min and max values and stores the result into "result"
  60306. * @param min defines minimum clamping value (default is 0)
  60307. * @param max defines maximum clamping value (default is 1)
  60308. * @param result defines color to store the result into
  60309. * @returns the original Color3
  60310. */
  60311. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60312. /**
  60313. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60314. * @param otherColor defines the second operand
  60315. * @returns the new Color3
  60316. */
  60317. add(otherColor: DeepImmutable<Color3>): Color3;
  60318. /**
  60319. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60320. * @param otherColor defines the second operand
  60321. * @param result defines Color3 object to store the result into
  60322. * @returns the unmodified current Color3
  60323. */
  60324. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60325. /**
  60326. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60327. * @param otherColor defines the second operand
  60328. * @returns the new Color3
  60329. */
  60330. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60331. /**
  60332. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60333. * @param otherColor defines the second operand
  60334. * @param result defines Color3 object to store the result into
  60335. * @returns the unmodified current Color3
  60336. */
  60337. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60338. /**
  60339. * Copy the current object
  60340. * @returns a new Color3 copied the current one
  60341. */
  60342. clone(): Color3;
  60343. /**
  60344. * Copies the rgb values from the source in the current Color3
  60345. * @param source defines the source Color3 object
  60346. * @returns the updated Color3 object
  60347. */
  60348. copyFrom(source: DeepImmutable<Color3>): Color3;
  60349. /**
  60350. * Updates the Color3 rgb values from the given floats
  60351. * @param r defines the red component to read from
  60352. * @param g defines the green component to read from
  60353. * @param b defines the blue component to read from
  60354. * @returns the current Color3 object
  60355. */
  60356. copyFromFloats(r: number, g: number, b: number): Color3;
  60357. /**
  60358. * Updates the Color3 rgb values from the given floats
  60359. * @param r defines the red component to read from
  60360. * @param g defines the green component to read from
  60361. * @param b defines the blue component to read from
  60362. * @returns the current Color3 object
  60363. */
  60364. set(r: number, g: number, b: number): Color3;
  60365. /**
  60366. * Compute the Color3 hexadecimal code as a string
  60367. * @returns a string containing the hexadecimal representation of the Color3 object
  60368. */
  60369. toHexString(): string;
  60370. /**
  60371. * Computes a new Color3 converted from the current one to linear space
  60372. * @returns a new Color3 object
  60373. */
  60374. toLinearSpace(): Color3;
  60375. /**
  60376. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60377. * @param convertedColor defines the Color3 object where to store the linear space version
  60378. * @returns the unmodified Color3
  60379. */
  60380. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60381. /**
  60382. * Computes a new Color3 converted from the current one to gamma space
  60383. * @returns a new Color3 object
  60384. */
  60385. toGammaSpace(): Color3;
  60386. /**
  60387. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60388. * @param convertedColor defines the Color3 object where to store the gamma space version
  60389. * @returns the unmodified Color3
  60390. */
  60391. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60392. private static _BlackReadOnly;
  60393. /**
  60394. * Creates a new Color3 from the string containing valid hexadecimal values
  60395. * @param hex defines a string containing valid hexadecimal values
  60396. * @returns a new Color3 object
  60397. */
  60398. static FromHexString(hex: string): Color3;
  60399. /**
  60400. * Creates a new Color3 from the starting index of the given array
  60401. * @param array defines the source array
  60402. * @param offset defines an offset in the source array
  60403. * @returns a new Color3 object
  60404. */
  60405. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60406. /**
  60407. * Creates a new Color3 from integer values (< 256)
  60408. * @param r defines the red component to read from (value between 0 and 255)
  60409. * @param g defines the green component to read from (value between 0 and 255)
  60410. * @param b defines the blue component to read from (value between 0 and 255)
  60411. * @returns a new Color3 object
  60412. */
  60413. static FromInts(r: number, g: number, b: number): Color3;
  60414. /**
  60415. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60416. * @param start defines the start Color3 value
  60417. * @param end defines the end Color3 value
  60418. * @param amount defines the gradient value between start and end
  60419. * @returns a new Color3 object
  60420. */
  60421. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60422. /**
  60423. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60424. * @param left defines the start value
  60425. * @param right defines the end value
  60426. * @param amount defines the gradient factor
  60427. * @param result defines the Color3 object where to store the result
  60428. */
  60429. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60430. /**
  60431. * Returns a Color3 value containing a red color
  60432. * @returns a new Color3 object
  60433. */
  60434. static Red(): Color3;
  60435. /**
  60436. * Returns a Color3 value containing a green color
  60437. * @returns a new Color3 object
  60438. */
  60439. static Green(): Color3;
  60440. /**
  60441. * Returns a Color3 value containing a blue color
  60442. * @returns a new Color3 object
  60443. */
  60444. static Blue(): Color3;
  60445. /**
  60446. * Returns a Color3 value containing a black color
  60447. * @returns a new Color3 object
  60448. */
  60449. static Black(): Color3;
  60450. /**
  60451. * Gets a Color3 value containing a black color that must not be updated
  60452. */
  60453. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60454. /**
  60455. * Returns a Color3 value containing a white color
  60456. * @returns a new Color3 object
  60457. */
  60458. static White(): Color3;
  60459. /**
  60460. * Returns a Color3 value containing a purple color
  60461. * @returns a new Color3 object
  60462. */
  60463. static Purple(): Color3;
  60464. /**
  60465. * Returns a Color3 value containing a magenta color
  60466. * @returns a new Color3 object
  60467. */
  60468. static Magenta(): Color3;
  60469. /**
  60470. * Returns a Color3 value containing a yellow color
  60471. * @returns a new Color3 object
  60472. */
  60473. static Yellow(): Color3;
  60474. /**
  60475. * Returns a Color3 value containing a gray color
  60476. * @returns a new Color3 object
  60477. */
  60478. static Gray(): Color3;
  60479. /**
  60480. * Returns a Color3 value containing a teal color
  60481. * @returns a new Color3 object
  60482. */
  60483. static Teal(): Color3;
  60484. /**
  60485. * Returns a Color3 value containing a random color
  60486. * @returns a new Color3 object
  60487. */
  60488. static Random(): Color3;
  60489. }
  60490. /**
  60491. * Class used to hold a RBGA color
  60492. */
  60493. export class Color4 {
  60494. /**
  60495. * Defines the red component (between 0 and 1, default is 0)
  60496. */
  60497. r: number;
  60498. /**
  60499. * Defines the green component (between 0 and 1, default is 0)
  60500. */
  60501. g: number;
  60502. /**
  60503. * Defines the blue component (between 0 and 1, default is 0)
  60504. */
  60505. b: number;
  60506. /**
  60507. * Defines the alpha component (between 0 and 1, default is 1)
  60508. */
  60509. a: number;
  60510. /**
  60511. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60512. * @param r defines the red component (between 0 and 1, default is 0)
  60513. * @param g defines the green component (between 0 and 1, default is 0)
  60514. * @param b defines the blue component (between 0 and 1, default is 0)
  60515. * @param a defines the alpha component (between 0 and 1, default is 1)
  60516. */
  60517. constructor(
  60518. /**
  60519. * Defines the red component (between 0 and 1, default is 0)
  60520. */
  60521. r?: number,
  60522. /**
  60523. * Defines the green component (between 0 and 1, default is 0)
  60524. */
  60525. g?: number,
  60526. /**
  60527. * Defines the blue component (between 0 and 1, default is 0)
  60528. */
  60529. b?: number,
  60530. /**
  60531. * Defines the alpha component (between 0 and 1, default is 1)
  60532. */
  60533. a?: number);
  60534. /**
  60535. * Adds in place the given Color4 values to the current Color4 object
  60536. * @param right defines the second operand
  60537. * @returns the current updated Color4 object
  60538. */
  60539. addInPlace(right: DeepImmutable<Color4>): Color4;
  60540. /**
  60541. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60542. * @returns the new array
  60543. */
  60544. asArray(): number[];
  60545. /**
  60546. * Stores from the starting index in the given array the Color4 successive values
  60547. * @param array defines the array where to store the r,g,b components
  60548. * @param index defines an optional index in the target array to define where to start storing values
  60549. * @returns the current Color4 object
  60550. */
  60551. toArray(array: number[], index?: number): Color4;
  60552. /**
  60553. * Determines equality between Color4 objects
  60554. * @param otherColor defines the second operand
  60555. * @returns true if the rgba values are equal to the given ones
  60556. */
  60557. equals(otherColor: DeepImmutable<Color4>): boolean;
  60558. /**
  60559. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60560. * @param right defines the second operand
  60561. * @returns a new Color4 object
  60562. */
  60563. add(right: DeepImmutable<Color4>): Color4;
  60564. /**
  60565. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60566. * @param right defines the second operand
  60567. * @returns a new Color4 object
  60568. */
  60569. subtract(right: DeepImmutable<Color4>): Color4;
  60570. /**
  60571. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60572. * @param right defines the second operand
  60573. * @param result defines the Color4 object where to store the result
  60574. * @returns the current Color4 object
  60575. */
  60576. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60577. /**
  60578. * Creates a new Color4 with the current Color4 values multiplied by scale
  60579. * @param scale defines the scaling factor to apply
  60580. * @returns a new Color4 object
  60581. */
  60582. scale(scale: number): Color4;
  60583. /**
  60584. * Multiplies the current Color4 values by scale and stores the result in "result"
  60585. * @param scale defines the scaling factor to apply
  60586. * @param result defines the Color4 object where to store the result
  60587. * @returns the current unmodified Color4
  60588. */
  60589. scaleToRef(scale: number, result: Color4): Color4;
  60590. /**
  60591. * Scale the current Color4 values by a factor and add the result to a given Color4
  60592. * @param scale defines the scale factor
  60593. * @param result defines the Color4 object where to store the result
  60594. * @returns the unmodified current Color4
  60595. */
  60596. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60597. /**
  60598. * Clamps the rgb values by the min and max values and stores the result into "result"
  60599. * @param min defines minimum clamping value (default is 0)
  60600. * @param max defines maximum clamping value (default is 1)
  60601. * @param result defines color to store the result into.
  60602. * @returns the cuurent Color4
  60603. */
  60604. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60605. /**
  60606. * Multipy an Color4 value by another and return a new Color4 object
  60607. * @param color defines the Color4 value to multiply by
  60608. * @returns a new Color4 object
  60609. */
  60610. multiply(color: Color4): Color4;
  60611. /**
  60612. * Multipy a Color4 value by another and push the result in a reference value
  60613. * @param color defines the Color4 value to multiply by
  60614. * @param result defines the Color4 to fill the result in
  60615. * @returns the result Color4
  60616. */
  60617. multiplyToRef(color: Color4, result: Color4): Color4;
  60618. /**
  60619. * Creates a string with the Color4 current values
  60620. * @returns the string representation of the Color4 object
  60621. */
  60622. toString(): string;
  60623. /**
  60624. * Returns the string "Color4"
  60625. * @returns "Color4"
  60626. */
  60627. getClassName(): string;
  60628. /**
  60629. * Compute the Color4 hash code
  60630. * @returns an unique number that can be used to hash Color4 objects
  60631. */
  60632. getHashCode(): number;
  60633. /**
  60634. * Creates a new Color4 copied from the current one
  60635. * @returns a new Color4 object
  60636. */
  60637. clone(): Color4;
  60638. /**
  60639. * Copies the given Color4 values into the current one
  60640. * @param source defines the source Color4 object
  60641. * @returns the current updated Color4 object
  60642. */
  60643. copyFrom(source: Color4): Color4;
  60644. /**
  60645. * Copies the given float values into the current one
  60646. * @param r defines the red component to read from
  60647. * @param g defines the green component to read from
  60648. * @param b defines the blue component to read from
  60649. * @param a defines the alpha component to read from
  60650. * @returns the current updated Color4 object
  60651. */
  60652. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60653. /**
  60654. * Copies the given float values into the current one
  60655. * @param r defines the red component to read from
  60656. * @param g defines the green component to read from
  60657. * @param b defines the blue component to read from
  60658. * @param a defines the alpha component to read from
  60659. * @returns the current updated Color4 object
  60660. */
  60661. set(r: number, g: number, b: number, a: number): Color4;
  60662. /**
  60663. * Compute the Color4 hexadecimal code as a string
  60664. * @returns a string containing the hexadecimal representation of the Color4 object
  60665. */
  60666. toHexString(): string;
  60667. /**
  60668. * Computes a new Color4 converted from the current one to linear space
  60669. * @returns a new Color4 object
  60670. */
  60671. toLinearSpace(): Color4;
  60672. /**
  60673. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60674. * @param convertedColor defines the Color4 object where to store the linear space version
  60675. * @returns the unmodified Color4
  60676. */
  60677. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60678. /**
  60679. * Computes a new Color4 converted from the current one to gamma space
  60680. * @returns a new Color4 object
  60681. */
  60682. toGammaSpace(): Color4;
  60683. /**
  60684. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60685. * @param convertedColor defines the Color4 object where to store the gamma space version
  60686. * @returns the unmodified Color4
  60687. */
  60688. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60689. /**
  60690. * Creates a new Color4 from the string containing valid hexadecimal values
  60691. * @param hex defines a string containing valid hexadecimal values
  60692. * @returns a new Color4 object
  60693. */
  60694. static FromHexString(hex: string): Color4;
  60695. /**
  60696. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60697. * @param left defines the start value
  60698. * @param right defines the end value
  60699. * @param amount defines the gradient factor
  60700. * @returns a new Color4 object
  60701. */
  60702. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60703. /**
  60704. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60705. * @param left defines the start value
  60706. * @param right defines the end value
  60707. * @param amount defines the gradient factor
  60708. * @param result defines the Color4 object where to store data
  60709. */
  60710. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60711. /**
  60712. * Creates a new Color4 from a Color3 and an alpha value
  60713. * @param color3 defines the source Color3 to read from
  60714. * @param alpha defines the alpha component (1.0 by default)
  60715. * @returns a new Color4 object
  60716. */
  60717. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60718. /**
  60719. * Creates a new Color4 from the starting index element of the given array
  60720. * @param array defines the source array to read from
  60721. * @param offset defines the offset in the source array
  60722. * @returns a new Color4 object
  60723. */
  60724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60725. /**
  60726. * Creates a new Color3 from integer values (< 256)
  60727. * @param r defines the red component to read from (value between 0 and 255)
  60728. * @param g defines the green component to read from (value between 0 and 255)
  60729. * @param b defines the blue component to read from (value between 0 and 255)
  60730. * @param a defines the alpha component to read from (value between 0 and 255)
  60731. * @returns a new Color3 object
  60732. */
  60733. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60734. /**
  60735. * Check the content of a given array and convert it to an array containing RGBA data
  60736. * If the original array was already containing count * 4 values then it is returned directly
  60737. * @param colors defines the array to check
  60738. * @param count defines the number of RGBA data to expect
  60739. * @returns an array containing count * 4 values (RGBA)
  60740. */
  60741. static CheckColors4(colors: number[], count: number): number[];
  60742. }
  60743. /**
  60744. * Class representing a vector containing 2 coordinates
  60745. */
  60746. export class Vector2 {
  60747. /** defines the first coordinate */
  60748. x: number;
  60749. /** defines the second coordinate */
  60750. y: number;
  60751. /**
  60752. * Creates a new Vector2 from the given x and y coordinates
  60753. * @param x defines the first coordinate
  60754. * @param y defines the second coordinate
  60755. */
  60756. constructor(
  60757. /** defines the first coordinate */
  60758. x?: number,
  60759. /** defines the second coordinate */
  60760. y?: number);
  60761. /**
  60762. * Gets a string with the Vector2 coordinates
  60763. * @returns a string with the Vector2 coordinates
  60764. */
  60765. toString(): string;
  60766. /**
  60767. * Gets class name
  60768. * @returns the string "Vector2"
  60769. */
  60770. getClassName(): string;
  60771. /**
  60772. * Gets current vector hash code
  60773. * @returns the Vector2 hash code as a number
  60774. */
  60775. getHashCode(): number;
  60776. /**
  60777. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60778. * @param array defines the source array
  60779. * @param index defines the offset in source array
  60780. * @returns the current Vector2
  60781. */
  60782. toArray(array: FloatArray, index?: number): Vector2;
  60783. /**
  60784. * Copy the current vector to an array
  60785. * @returns a new array with 2 elements: the Vector2 coordinates.
  60786. */
  60787. asArray(): number[];
  60788. /**
  60789. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60790. * @param source defines the source Vector2
  60791. * @returns the current updated Vector2
  60792. */
  60793. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60794. /**
  60795. * Sets the Vector2 coordinates with the given floats
  60796. * @param x defines the first coordinate
  60797. * @param y defines the second coordinate
  60798. * @returns the current updated Vector2
  60799. */
  60800. copyFromFloats(x: number, y: number): Vector2;
  60801. /**
  60802. * Sets the Vector2 coordinates with the given floats
  60803. * @param x defines the first coordinate
  60804. * @param y defines the second coordinate
  60805. * @returns the current updated Vector2
  60806. */
  60807. set(x: number, y: number): Vector2;
  60808. /**
  60809. * Add another vector with the current one
  60810. * @param otherVector defines the other vector
  60811. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60812. */
  60813. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60814. /**
  60815. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60816. * @param otherVector defines the other vector
  60817. * @param result defines the target vector
  60818. * @returns the unmodified current Vector2
  60819. */
  60820. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60821. /**
  60822. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60823. * @param otherVector defines the other vector
  60824. * @returns the current updated Vector2
  60825. */
  60826. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60827. /**
  60828. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60829. * @param otherVector defines the other vector
  60830. * @returns a new Vector2
  60831. */
  60832. addVector3(otherVector: Vector3): Vector2;
  60833. /**
  60834. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60835. * @param otherVector defines the other vector
  60836. * @returns a new Vector2
  60837. */
  60838. subtract(otherVector: Vector2): Vector2;
  60839. /**
  60840. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60841. * @param otherVector defines the other vector
  60842. * @param result defines the target vector
  60843. * @returns the unmodified current Vector2
  60844. */
  60845. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60846. /**
  60847. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60848. * @param otherVector defines the other vector
  60849. * @returns the current updated Vector2
  60850. */
  60851. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60852. /**
  60853. * Multiplies in place the current Vector2 coordinates by the given ones
  60854. * @param otherVector defines the other vector
  60855. * @returns the current updated Vector2
  60856. */
  60857. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60858. /**
  60859. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60860. * @param otherVector defines the other vector
  60861. * @returns a new Vector2
  60862. */
  60863. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60864. /**
  60865. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60866. * @param otherVector defines the other vector
  60867. * @param result defines the target vector
  60868. * @returns the unmodified current Vector2
  60869. */
  60870. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60871. /**
  60872. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60873. * @param x defines the first coordinate
  60874. * @param y defines the second coordinate
  60875. * @returns a new Vector2
  60876. */
  60877. multiplyByFloats(x: number, y: number): Vector2;
  60878. /**
  60879. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60880. * @param otherVector defines the other vector
  60881. * @returns a new Vector2
  60882. */
  60883. divide(otherVector: Vector2): Vector2;
  60884. /**
  60885. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60886. * @param otherVector defines the other vector
  60887. * @param result defines the target vector
  60888. * @returns the unmodified current Vector2
  60889. */
  60890. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60891. /**
  60892. * Divides the current Vector2 coordinates by the given ones
  60893. * @param otherVector defines the other vector
  60894. * @returns the current updated Vector2
  60895. */
  60896. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60897. /**
  60898. * Gets a new Vector2 with current Vector2 negated coordinates
  60899. * @returns a new Vector2
  60900. */
  60901. negate(): Vector2;
  60902. /**
  60903. * Multiply the Vector2 coordinates by scale
  60904. * @param scale defines the scaling factor
  60905. * @returns the current updated Vector2
  60906. */
  60907. scaleInPlace(scale: number): Vector2;
  60908. /**
  60909. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60910. * @param scale defines the scaling factor
  60911. * @returns a new Vector2
  60912. */
  60913. scale(scale: number): Vector2;
  60914. /**
  60915. * Scale the current Vector2 values by a factor to a given Vector2
  60916. * @param scale defines the scale factor
  60917. * @param result defines the Vector2 object where to store the result
  60918. * @returns the unmodified current Vector2
  60919. */
  60920. scaleToRef(scale: number, result: Vector2): Vector2;
  60921. /**
  60922. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60923. * @param scale defines the scale factor
  60924. * @param result defines the Vector2 object where to store the result
  60925. * @returns the unmodified current Vector2
  60926. */
  60927. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60928. /**
  60929. * Gets a boolean if two vectors are equals
  60930. * @param otherVector defines the other vector
  60931. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60932. */
  60933. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60934. /**
  60935. * Gets a boolean if two vectors are equals (using an epsilon value)
  60936. * @param otherVector defines the other vector
  60937. * @param epsilon defines the minimal distance to consider equality
  60938. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60939. */
  60940. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60941. /**
  60942. * Gets a new Vector2 from current Vector2 floored values
  60943. * @returns a new Vector2
  60944. */
  60945. floor(): Vector2;
  60946. /**
  60947. * Gets a new Vector2 from current Vector2 floored values
  60948. * @returns a new Vector2
  60949. */
  60950. fract(): Vector2;
  60951. /**
  60952. * Gets the length of the vector
  60953. * @returns the vector length (float)
  60954. */
  60955. length(): number;
  60956. /**
  60957. * Gets the vector squared length
  60958. * @returns the vector squared length (float)
  60959. */
  60960. lengthSquared(): number;
  60961. /**
  60962. * Normalize the vector
  60963. * @returns the current updated Vector2
  60964. */
  60965. normalize(): Vector2;
  60966. /**
  60967. * Gets a new Vector2 copied from the Vector2
  60968. * @returns a new Vector2
  60969. */
  60970. clone(): Vector2;
  60971. /**
  60972. * Gets a new Vector2(0, 0)
  60973. * @returns a new Vector2
  60974. */
  60975. static Zero(): Vector2;
  60976. /**
  60977. * Gets a new Vector2(1, 1)
  60978. * @returns a new Vector2
  60979. */
  60980. static One(): Vector2;
  60981. /**
  60982. * Gets a new Vector2 set from the given index element of the given array
  60983. * @param array defines the data source
  60984. * @param offset defines the offset in the data source
  60985. * @returns a new Vector2
  60986. */
  60987. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60988. /**
  60989. * Sets "result" from the given index element of the given array
  60990. * @param array defines the data source
  60991. * @param offset defines the offset in the data source
  60992. * @param result defines the target vector
  60993. */
  60994. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60995. /**
  60996. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60997. * @param value1 defines 1st point of control
  60998. * @param value2 defines 2nd point of control
  60999. * @param value3 defines 3rd point of control
  61000. * @param value4 defines 4th point of control
  61001. * @param amount defines the interpolation factor
  61002. * @returns a new Vector2
  61003. */
  61004. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  61005. /**
  61006. * 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".
  61007. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  61008. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  61009. * @param value defines the value to clamp
  61010. * @param min defines the lower limit
  61011. * @param max defines the upper limit
  61012. * @returns a new Vector2
  61013. */
  61014. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  61015. /**
  61016. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  61017. * @param value1 defines the 1st control point
  61018. * @param tangent1 defines the outgoing tangent
  61019. * @param value2 defines the 2nd control point
  61020. * @param tangent2 defines the incoming tangent
  61021. * @param amount defines the interpolation factor
  61022. * @returns a new Vector2
  61023. */
  61024. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  61025. /**
  61026. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  61027. * @param start defines the start vector
  61028. * @param end defines the end vector
  61029. * @param amount defines the interpolation factor
  61030. * @returns a new Vector2
  61031. */
  61032. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  61033. /**
  61034. * Gets the dot product of the vector "left" and the vector "right"
  61035. * @param left defines first vector
  61036. * @param right defines second vector
  61037. * @returns the dot product (float)
  61038. */
  61039. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  61040. /**
  61041. * Returns a new Vector2 equal to the normalized given vector
  61042. * @param vector defines the vector to normalize
  61043. * @returns a new Vector2
  61044. */
  61045. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  61046. /**
  61047. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  61048. * @param left defines 1st vector
  61049. * @param right defines 2nd vector
  61050. * @returns a new Vector2
  61051. */
  61052. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61053. /**
  61054. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  61055. * @param left defines 1st vector
  61056. * @param right defines 2nd vector
  61057. * @returns a new Vector2
  61058. */
  61059. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61060. /**
  61061. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  61062. * @param vector defines the vector to transform
  61063. * @param transformation defines the matrix to apply
  61064. * @returns a new Vector2
  61065. */
  61066. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  61067. /**
  61068. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  61069. * @param vector defines the vector to transform
  61070. * @param transformation defines the matrix to apply
  61071. * @param result defines the target vector
  61072. */
  61073. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  61074. /**
  61075. * Determines if a given vector is included in a triangle
  61076. * @param p defines the vector to test
  61077. * @param p0 defines 1st triangle point
  61078. * @param p1 defines 2nd triangle point
  61079. * @param p2 defines 3rd triangle point
  61080. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  61081. */
  61082. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  61083. /**
  61084. * Gets the distance between the vectors "value1" and "value2"
  61085. * @param value1 defines first vector
  61086. * @param value2 defines second vector
  61087. * @returns the distance between vectors
  61088. */
  61089. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61090. /**
  61091. * Returns the squared distance between the vectors "value1" and "value2"
  61092. * @param value1 defines first vector
  61093. * @param value2 defines second vector
  61094. * @returns the squared distance between vectors
  61095. */
  61096. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61097. /**
  61098. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  61099. * @param value1 defines first vector
  61100. * @param value2 defines second vector
  61101. * @returns a new Vector2
  61102. */
  61103. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  61104. /**
  61105. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  61106. * @param p defines the middle point
  61107. * @param segA defines one point of the segment
  61108. * @param segB defines the other point of the segment
  61109. * @returns the shortest distance
  61110. */
  61111. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  61112. }
  61113. /**
  61114. * Classed used to store (x,y,z) vector representation
  61115. * A Vector3 is the main object used in 3D geometry
  61116. * It can represent etiher the coordinates of a point the space, either a direction
  61117. * Reminder: js uses a left handed forward facing system
  61118. */
  61119. export class Vector3 {
  61120. /**
  61121. * Defines the first coordinates (on X axis)
  61122. */
  61123. x: number;
  61124. /**
  61125. * Defines the second coordinates (on Y axis)
  61126. */
  61127. y: number;
  61128. /**
  61129. * Defines the third coordinates (on Z axis)
  61130. */
  61131. z: number;
  61132. private static _UpReadOnly;
  61133. /**
  61134. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  61135. * @param x defines the first coordinates (on X axis)
  61136. * @param y defines the second coordinates (on Y axis)
  61137. * @param z defines the third coordinates (on Z axis)
  61138. */
  61139. constructor(
  61140. /**
  61141. * Defines the first coordinates (on X axis)
  61142. */
  61143. x?: number,
  61144. /**
  61145. * Defines the second coordinates (on Y axis)
  61146. */
  61147. y?: number,
  61148. /**
  61149. * Defines the third coordinates (on Z axis)
  61150. */
  61151. z?: number);
  61152. /**
  61153. * Creates a string representation of the Vector3
  61154. * @returns a string with the Vector3 coordinates.
  61155. */
  61156. toString(): string;
  61157. /**
  61158. * Gets the class name
  61159. * @returns the string "Vector3"
  61160. */
  61161. getClassName(): string;
  61162. /**
  61163. * Creates the Vector3 hash code
  61164. * @returns a number which tends to be unique between Vector3 instances
  61165. */
  61166. getHashCode(): number;
  61167. /**
  61168. * Creates an array containing three elements : the coordinates of the Vector3
  61169. * @returns a new array of numbers
  61170. */
  61171. asArray(): number[];
  61172. /**
  61173. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  61174. * @param array defines the destination array
  61175. * @param index defines the offset in the destination array
  61176. * @returns the current Vector3
  61177. */
  61178. toArray(array: FloatArray, index?: number): Vector3;
  61179. /**
  61180. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  61181. * @returns a new Quaternion object, computed from the Vector3 coordinates
  61182. */
  61183. toQuaternion(): Quaternion;
  61184. /**
  61185. * Adds the given vector to the current Vector3
  61186. * @param otherVector defines the second operand
  61187. * @returns the current updated Vector3
  61188. */
  61189. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61190. /**
  61191. * Adds the given coordinates to the current Vector3
  61192. * @param x defines the x coordinate of the operand
  61193. * @param y defines the y coordinate of the operand
  61194. * @param z defines the z coordinate of the operand
  61195. * @returns the current updated Vector3
  61196. */
  61197. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61198. /**
  61199. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  61200. * @param otherVector defines the second operand
  61201. * @returns the resulting Vector3
  61202. */
  61203. add(otherVector: DeepImmutable<Vector3>): Vector3;
  61204. /**
  61205. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  61206. * @param otherVector defines the second operand
  61207. * @param result defines the Vector3 object where to store the result
  61208. * @returns the current Vector3
  61209. */
  61210. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61211. /**
  61212. * Subtract the given vector from the current Vector3
  61213. * @param otherVector defines the second operand
  61214. * @returns the current updated Vector3
  61215. */
  61216. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61217. /**
  61218. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  61219. * @param otherVector defines the second operand
  61220. * @returns the resulting Vector3
  61221. */
  61222. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  61223. /**
  61224. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  61225. * @param otherVector defines the second operand
  61226. * @param result defines the Vector3 object where to store the result
  61227. * @returns the current Vector3
  61228. */
  61229. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61230. /**
  61231. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  61232. * @param x defines the x coordinate of the operand
  61233. * @param y defines the y coordinate of the operand
  61234. * @param z defines the z coordinate of the operand
  61235. * @returns the resulting Vector3
  61236. */
  61237. subtractFromFloats(x: number, y: number, z: number): Vector3;
  61238. /**
  61239. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  61240. * @param x defines the x coordinate of the operand
  61241. * @param y defines the y coordinate of the operand
  61242. * @param z defines the z coordinate of the operand
  61243. * @param result defines the Vector3 object where to store the result
  61244. * @returns the current Vector3
  61245. */
  61246. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  61247. /**
  61248. * Gets a new Vector3 set with the current Vector3 negated coordinates
  61249. * @returns a new Vector3
  61250. */
  61251. negate(): Vector3;
  61252. /**
  61253. * Multiplies the Vector3 coordinates by the float "scale"
  61254. * @param scale defines the multiplier factor
  61255. * @returns the current updated Vector3
  61256. */
  61257. scaleInPlace(scale: number): Vector3;
  61258. /**
  61259. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  61260. * @param scale defines the multiplier factor
  61261. * @returns a new Vector3
  61262. */
  61263. scale(scale: number): Vector3;
  61264. /**
  61265. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  61266. * @param scale defines the multiplier factor
  61267. * @param result defines the Vector3 object where to store the result
  61268. * @returns the current Vector3
  61269. */
  61270. scaleToRef(scale: number, result: Vector3): Vector3;
  61271. /**
  61272. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  61273. * @param scale defines the scale factor
  61274. * @param result defines the Vector3 object where to store the result
  61275. * @returns the unmodified current Vector3
  61276. */
  61277. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61278. /**
  61279. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61280. * @param otherVector defines the second operand
  61281. * @returns true if both vectors are equals
  61282. */
  61283. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61284. /**
  61285. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61286. * @param otherVector defines the second operand
  61287. * @param epsilon defines the minimal distance to define values as equals
  61288. * @returns true if both vectors are distant less than epsilon
  61289. */
  61290. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61291. /**
  61292. * Returns true if the current Vector3 coordinates equals the given floats
  61293. * @param x defines the x coordinate of the operand
  61294. * @param y defines the y coordinate of the operand
  61295. * @param z defines the z coordinate of the operand
  61296. * @returns true if both vectors are equals
  61297. */
  61298. equalsToFloats(x: number, y: number, z: number): boolean;
  61299. /**
  61300. * Multiplies the current Vector3 coordinates by the given ones
  61301. * @param otherVector defines the second operand
  61302. * @returns the current updated Vector3
  61303. */
  61304. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61305. /**
  61306. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61307. * @param otherVector defines the second operand
  61308. * @returns the new Vector3
  61309. */
  61310. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61311. /**
  61312. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61313. * @param otherVector defines the second operand
  61314. * @param result defines the Vector3 object where to store the result
  61315. * @returns the current Vector3
  61316. */
  61317. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61318. /**
  61319. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  61320. * @param x defines the x coordinate of the operand
  61321. * @param y defines the y coordinate of the operand
  61322. * @param z defines the z coordinate of the operand
  61323. * @returns the new Vector3
  61324. */
  61325. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61326. /**
  61327. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61328. * @param otherVector defines the second operand
  61329. * @returns the new Vector3
  61330. */
  61331. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61332. /**
  61333. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  61334. * @param otherVector defines the second operand
  61335. * @param result defines the Vector3 object where to store the result
  61336. * @returns the current Vector3
  61337. */
  61338. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61339. /**
  61340. * Divides the current Vector3 coordinates by the given ones.
  61341. * @param otherVector defines the second operand
  61342. * @returns the current updated Vector3
  61343. */
  61344. divideInPlace(otherVector: Vector3): Vector3;
  61345. /**
  61346. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61347. * @param other defines the second operand
  61348. * @returns the current updated Vector3
  61349. */
  61350. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61351. /**
  61352. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61353. * @param other defines the second operand
  61354. * @returns the current updated Vector3
  61355. */
  61356. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61357. /**
  61358. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61359. * @param x defines the x coordinate of the operand
  61360. * @param y defines the y coordinate of the operand
  61361. * @param z defines the z coordinate of the operand
  61362. * @returns the current updated Vector3
  61363. */
  61364. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61365. /**
  61366. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61367. * @param x defines the x coordinate of the operand
  61368. * @param y defines the y coordinate of the operand
  61369. * @param z defines the z coordinate of the operand
  61370. * @returns the current updated Vector3
  61371. */
  61372. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61373. /**
  61374. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61375. * Check if is non uniform within a certain amount of decimal places to account for this
  61376. * @param epsilon the amount the values can differ
  61377. * @returns if the the vector is non uniform to a certain number of decimal places
  61378. */
  61379. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61380. /**
  61381. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61382. */
  61383. readonly isNonUniform: boolean;
  61384. /**
  61385. * Gets a new Vector3 from current Vector3 floored values
  61386. * @returns a new Vector3
  61387. */
  61388. floor(): Vector3;
  61389. /**
  61390. * Gets a new Vector3 from current Vector3 floored values
  61391. * @returns a new Vector3
  61392. */
  61393. fract(): Vector3;
  61394. /**
  61395. * Gets the length of the Vector3
  61396. * @returns the length of the Vecto3
  61397. */
  61398. length(): number;
  61399. /**
  61400. * Gets the squared length of the Vector3
  61401. * @returns squared length of the Vector3
  61402. */
  61403. lengthSquared(): number;
  61404. /**
  61405. * Normalize the current Vector3.
  61406. * Please note that this is an in place operation.
  61407. * @returns the current updated Vector3
  61408. */
  61409. normalize(): Vector3;
  61410. /**
  61411. * Reorders the x y z properties of the vector in place
  61412. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61413. * @returns the current updated vector
  61414. */
  61415. reorderInPlace(order: string): this;
  61416. /**
  61417. * Rotates the vector around 0,0,0 by a quaternion
  61418. * @param quaternion the rotation quaternion
  61419. * @param result vector to store the result
  61420. * @returns the resulting vector
  61421. */
  61422. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61423. /**
  61424. * Rotates a vector around a given point
  61425. * @param quaternion the rotation quaternion
  61426. * @param point the point to rotate around
  61427. * @param result vector to store the result
  61428. * @returns the resulting vector
  61429. */
  61430. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61431. /**
  61432. * Normalize the current Vector3 with the given input length.
  61433. * Please note that this is an in place operation.
  61434. * @param len the length of the vector
  61435. * @returns the current updated Vector3
  61436. */
  61437. normalizeFromLength(len: number): Vector3;
  61438. /**
  61439. * Normalize the current Vector3 to a new vector
  61440. * @returns the new Vector3
  61441. */
  61442. normalizeToNew(): Vector3;
  61443. /**
  61444. * Normalize the current Vector3 to the reference
  61445. * @param reference define the Vector3 to update
  61446. * @returns the updated Vector3
  61447. */
  61448. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61449. /**
  61450. * Creates a new Vector3 copied from the current Vector3
  61451. * @returns the new Vector3
  61452. */
  61453. clone(): Vector3;
  61454. /**
  61455. * Copies the given vector coordinates to the current Vector3 ones
  61456. * @param source defines the source Vector3
  61457. * @returns the current updated Vector3
  61458. */
  61459. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61460. /**
  61461. * Copies the given floats to the current Vector3 coordinates
  61462. * @param x defines the x coordinate of the operand
  61463. * @param y defines the y coordinate of the operand
  61464. * @param z defines the z coordinate of the operand
  61465. * @returns the current updated Vector3
  61466. */
  61467. copyFromFloats(x: number, y: number, z: number): Vector3;
  61468. /**
  61469. * Copies the given floats to the current Vector3 coordinates
  61470. * @param x defines the x coordinate of the operand
  61471. * @param y defines the y coordinate of the operand
  61472. * @param z defines the z coordinate of the operand
  61473. * @returns the current updated Vector3
  61474. */
  61475. set(x: number, y: number, z: number): Vector3;
  61476. /**
  61477. * Copies the given float to the current Vector3 coordinates
  61478. * @param v defines the x, y and z coordinates of the operand
  61479. * @returns the current updated Vector3
  61480. */
  61481. setAll(v: number): Vector3;
  61482. /**
  61483. * Get the clip factor between two vectors
  61484. * @param vector0 defines the first operand
  61485. * @param vector1 defines the second operand
  61486. * @param axis defines the axis to use
  61487. * @param size defines the size along the axis
  61488. * @returns the clip factor
  61489. */
  61490. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61491. /**
  61492. * Get angle between two vectors
  61493. * @param vector0 angle between vector0 and vector1
  61494. * @param vector1 angle between vector0 and vector1
  61495. * @param normal direction of the normal
  61496. * @return the angle between vector0 and vector1
  61497. */
  61498. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61499. /**
  61500. * Returns a new Vector3 set from the index "offset" of the given array
  61501. * @param array defines the source array
  61502. * @param offset defines the offset in the source array
  61503. * @returns the new Vector3
  61504. */
  61505. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61506. /**
  61507. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61508. * This function is deprecated. Use FromArray instead
  61509. * @param array defines the source array
  61510. * @param offset defines the offset in the source array
  61511. * @returns the new Vector3
  61512. */
  61513. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61514. /**
  61515. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61516. * @param array defines the source array
  61517. * @param offset defines the offset in the source array
  61518. * @param result defines the Vector3 where to store the result
  61519. */
  61520. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61521. /**
  61522. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61523. * This function is deprecated. Use FromArrayToRef instead.
  61524. * @param array defines the source array
  61525. * @param offset defines the offset in the source array
  61526. * @param result defines the Vector3 where to store the result
  61527. */
  61528. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61529. /**
  61530. * Sets the given vector "result" with the given floats.
  61531. * @param x defines the x coordinate of the source
  61532. * @param y defines the y coordinate of the source
  61533. * @param z defines the z coordinate of the source
  61534. * @param result defines the Vector3 where to store the result
  61535. */
  61536. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61537. /**
  61538. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61539. * @returns a new empty Vector3
  61540. */
  61541. static Zero(): Vector3;
  61542. /**
  61543. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61544. * @returns a new unit Vector3
  61545. */
  61546. static One(): Vector3;
  61547. /**
  61548. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61549. * @returns a new up Vector3
  61550. */
  61551. static Up(): Vector3;
  61552. /**
  61553. * Gets a up Vector3 that must not be updated
  61554. */
  61555. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61556. /**
  61557. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61558. * @returns a new down Vector3
  61559. */
  61560. static Down(): Vector3;
  61561. /**
  61562. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61563. * @returns a new forward Vector3
  61564. */
  61565. static Forward(): Vector3;
  61566. /**
  61567. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61568. * @returns a new forward Vector3
  61569. */
  61570. static Backward(): Vector3;
  61571. /**
  61572. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61573. * @returns a new right Vector3
  61574. */
  61575. static Right(): Vector3;
  61576. /**
  61577. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61578. * @returns a new left Vector3
  61579. */
  61580. static Left(): Vector3;
  61581. /**
  61582. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61583. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61584. * @param vector defines the Vector3 to transform
  61585. * @param transformation defines the transformation matrix
  61586. * @returns the transformed Vector3
  61587. */
  61588. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61589. /**
  61590. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61591. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61592. * @param vector defines the Vector3 to transform
  61593. * @param transformation defines the transformation matrix
  61594. * @param result defines the Vector3 where to store the result
  61595. */
  61596. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61597. /**
  61598. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61599. * This method computes tranformed coordinates only, not transformed direction vectors
  61600. * @param x define the x coordinate of the source vector
  61601. * @param y define the y coordinate of the source vector
  61602. * @param z define the z coordinate of the source vector
  61603. * @param transformation defines the transformation matrix
  61604. * @param result defines the Vector3 where to store the result
  61605. */
  61606. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61607. /**
  61608. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61609. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61610. * @param vector defines the Vector3 to transform
  61611. * @param transformation defines the transformation matrix
  61612. * @returns the new Vector3
  61613. */
  61614. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61615. /**
  61616. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61617. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61618. * @param vector defines the Vector3 to transform
  61619. * @param transformation defines the transformation matrix
  61620. * @param result defines the Vector3 where to store the result
  61621. */
  61622. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61623. /**
  61624. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61625. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61626. * @param x define the x coordinate of the source vector
  61627. * @param y define the y coordinate of the source vector
  61628. * @param z define the z coordinate of the source vector
  61629. * @param transformation defines the transformation matrix
  61630. * @param result defines the Vector3 where to store the result
  61631. */
  61632. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61633. /**
  61634. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61635. * @param value1 defines the first control point
  61636. * @param value2 defines the second control point
  61637. * @param value3 defines the third control point
  61638. * @param value4 defines the fourth control point
  61639. * @param amount defines the amount on the spline to use
  61640. * @returns the new Vector3
  61641. */
  61642. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61643. /**
  61644. * 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"
  61645. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61646. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61647. * @param value defines the current value
  61648. * @param min defines the lower range value
  61649. * @param max defines the upper range value
  61650. * @returns the new Vector3
  61651. */
  61652. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61653. /**
  61654. * 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"
  61655. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61656. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61657. * @param value defines the current value
  61658. * @param min defines the lower range value
  61659. * @param max defines the upper range value
  61660. * @param result defines the Vector3 where to store the result
  61661. */
  61662. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61663. /**
  61664. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61665. * @param value1 defines the first control point
  61666. * @param tangent1 defines the first tangent vector
  61667. * @param value2 defines the second control point
  61668. * @param tangent2 defines the second tangent vector
  61669. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61670. * @returns the new Vector3
  61671. */
  61672. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61673. /**
  61674. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61675. * @param start defines the start value
  61676. * @param end defines the end value
  61677. * @param amount max defines amount between both (between 0 and 1)
  61678. * @returns the new Vector3
  61679. */
  61680. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61681. /**
  61682. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61683. * @param start defines the start value
  61684. * @param end defines the end value
  61685. * @param amount max defines amount between both (between 0 and 1)
  61686. * @param result defines the Vector3 where to store the result
  61687. */
  61688. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61689. /**
  61690. * Returns the dot product (float) between the vectors "left" and "right"
  61691. * @param left defines the left operand
  61692. * @param right defines the right operand
  61693. * @returns the dot product
  61694. */
  61695. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61696. /**
  61697. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61698. * The cross product is then orthogonal to both "left" and "right"
  61699. * @param left defines the left operand
  61700. * @param right defines the right operand
  61701. * @returns the cross product
  61702. */
  61703. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61704. /**
  61705. * Sets the given vector "result" with the cross product of "left" and "right"
  61706. * The cross product is then orthogonal to both "left" and "right"
  61707. * @param left defines the left operand
  61708. * @param right defines the right operand
  61709. * @param result defines the Vector3 where to store the result
  61710. */
  61711. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61712. /**
  61713. * Returns a new Vector3 as the normalization of the given vector
  61714. * @param vector defines the Vector3 to normalize
  61715. * @returns the new Vector3
  61716. */
  61717. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61718. /**
  61719. * Sets the given vector "result" with the normalization of the given first vector
  61720. * @param vector defines the Vector3 to normalize
  61721. * @param result defines the Vector3 where to store the result
  61722. */
  61723. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61724. /**
  61725. * Project a Vector3 onto screen space
  61726. * @param vector defines the Vector3 to project
  61727. * @param world defines the world matrix to use
  61728. * @param transform defines the transform (view x projection) matrix to use
  61729. * @param viewport defines the screen viewport to use
  61730. * @returns the new Vector3
  61731. */
  61732. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61733. /** @hidden */
  61734. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61735. /**
  61736. * Unproject from screen space to object space
  61737. * @param source defines the screen space Vector3 to use
  61738. * @param viewportWidth defines the current width of the viewport
  61739. * @param viewportHeight defines the current height of the viewport
  61740. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61741. * @param transform defines the transform (view x projection) matrix to use
  61742. * @returns the new Vector3
  61743. */
  61744. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61745. /**
  61746. * Unproject from screen space to object space
  61747. * @param source defines the screen space Vector3 to use
  61748. * @param viewportWidth defines the current width of the viewport
  61749. * @param viewportHeight defines the current height of the viewport
  61750. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61751. * @param view defines the view matrix to use
  61752. * @param projection defines the projection matrix to use
  61753. * @returns the new Vector3
  61754. */
  61755. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61756. /**
  61757. * Unproject from screen space to object space
  61758. * @param source defines the screen space Vector3 to use
  61759. * @param viewportWidth defines the current width of the viewport
  61760. * @param viewportHeight defines the current height of the viewport
  61761. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61762. * @param view defines the view matrix to use
  61763. * @param projection defines the projection matrix to use
  61764. * @param result defines the Vector3 where to store the result
  61765. */
  61766. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61767. /**
  61768. * Unproject from screen space to object space
  61769. * @param sourceX defines the screen space x coordinate to use
  61770. * @param sourceY defines the screen space y coordinate to use
  61771. * @param sourceZ defines the screen space z coordinate to use
  61772. * @param viewportWidth defines the current width of the viewport
  61773. * @param viewportHeight defines the current height of the viewport
  61774. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61775. * @param view defines the view matrix to use
  61776. * @param projection defines the projection matrix to use
  61777. * @param result defines the Vector3 where to store the result
  61778. */
  61779. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61780. /**
  61781. * Gets the minimal coordinate values between two Vector3
  61782. * @param left defines the first operand
  61783. * @param right defines the second operand
  61784. * @returns the new Vector3
  61785. */
  61786. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61787. /**
  61788. * Gets the maximal coordinate values between two Vector3
  61789. * @param left defines the first operand
  61790. * @param right defines the second operand
  61791. * @returns the new Vector3
  61792. */
  61793. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61794. /**
  61795. * Returns the distance between the vectors "value1" and "value2"
  61796. * @param value1 defines the first operand
  61797. * @param value2 defines the second operand
  61798. * @returns the distance
  61799. */
  61800. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61801. /**
  61802. * Returns the squared distance between the vectors "value1" and "value2"
  61803. * @param value1 defines the first operand
  61804. * @param value2 defines the second operand
  61805. * @returns the squared distance
  61806. */
  61807. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61808. /**
  61809. * Returns a new Vector3 located at the center between "value1" and "value2"
  61810. * @param value1 defines the first operand
  61811. * @param value2 defines the second operand
  61812. * @returns the new Vector3
  61813. */
  61814. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61815. /**
  61816. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61817. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61818. * to something in order to rotate it from its local system to the given target system
  61819. * Note: axis1, axis2 and axis3 are normalized during this operation
  61820. * @param axis1 defines the first axis
  61821. * @param axis2 defines the second axis
  61822. * @param axis3 defines the third axis
  61823. * @returns a new Vector3
  61824. */
  61825. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61826. /**
  61827. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61828. * @param axis1 defines the first axis
  61829. * @param axis2 defines the second axis
  61830. * @param axis3 defines the third axis
  61831. * @param ref defines the Vector3 where to store the result
  61832. */
  61833. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61834. }
  61835. /**
  61836. * Vector4 class created for EulerAngle class conversion to Quaternion
  61837. */
  61838. export class Vector4 {
  61839. /** x value of the vector */
  61840. x: number;
  61841. /** y value of the vector */
  61842. y: number;
  61843. /** z value of the vector */
  61844. z: number;
  61845. /** w value of the vector */
  61846. w: number;
  61847. /**
  61848. * Creates a Vector4 object from the given floats.
  61849. * @param x x value of the vector
  61850. * @param y y value of the vector
  61851. * @param z z value of the vector
  61852. * @param w w value of the vector
  61853. */
  61854. constructor(
  61855. /** x value of the vector */
  61856. x: number,
  61857. /** y value of the vector */
  61858. y: number,
  61859. /** z value of the vector */
  61860. z: number,
  61861. /** w value of the vector */
  61862. w: number);
  61863. /**
  61864. * Returns the string with the Vector4 coordinates.
  61865. * @returns a string containing all the vector values
  61866. */
  61867. toString(): string;
  61868. /**
  61869. * Returns the string "Vector4".
  61870. * @returns "Vector4"
  61871. */
  61872. getClassName(): string;
  61873. /**
  61874. * Returns the Vector4 hash code.
  61875. * @returns a unique hash code
  61876. */
  61877. getHashCode(): number;
  61878. /**
  61879. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61880. * @returns the resulting array
  61881. */
  61882. asArray(): number[];
  61883. /**
  61884. * Populates the given array from the given index with the Vector4 coordinates.
  61885. * @param array array to populate
  61886. * @param index index of the array to start at (default: 0)
  61887. * @returns the Vector4.
  61888. */
  61889. toArray(array: FloatArray, index?: number): Vector4;
  61890. /**
  61891. * Adds the given vector to the current Vector4.
  61892. * @param otherVector the vector to add
  61893. * @returns the updated Vector4.
  61894. */
  61895. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61896. /**
  61897. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61898. * @param otherVector the vector to add
  61899. * @returns the resulting vector
  61900. */
  61901. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61902. /**
  61903. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61904. * @param otherVector the vector to add
  61905. * @param result the vector to store the result
  61906. * @returns the current Vector4.
  61907. */
  61908. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61909. /**
  61910. * Subtract in place the given vector from the current Vector4.
  61911. * @param otherVector the vector to subtract
  61912. * @returns the updated Vector4.
  61913. */
  61914. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61915. /**
  61916. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61917. * @param otherVector the vector to add
  61918. * @returns the new vector with the result
  61919. */
  61920. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61921. /**
  61922. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61923. * @param otherVector the vector to subtract
  61924. * @param result the vector to store the result
  61925. * @returns the current Vector4.
  61926. */
  61927. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61928. /**
  61929. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61930. */
  61931. /**
  61932. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61933. * @param x value to subtract
  61934. * @param y value to subtract
  61935. * @param z value to subtract
  61936. * @param w value to subtract
  61937. * @returns new vector containing the result
  61938. */
  61939. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61940. /**
  61941. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61942. * @param x value to subtract
  61943. * @param y value to subtract
  61944. * @param z value to subtract
  61945. * @param w value to subtract
  61946. * @param result the vector to store the result in
  61947. * @returns the current Vector4.
  61948. */
  61949. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61950. /**
  61951. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61952. * @returns a new vector with the negated values
  61953. */
  61954. negate(): Vector4;
  61955. /**
  61956. * Multiplies the current Vector4 coordinates by scale (float).
  61957. * @param scale the number to scale with
  61958. * @returns the updated Vector4.
  61959. */
  61960. scaleInPlace(scale: number): Vector4;
  61961. /**
  61962. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61963. * @param scale the number to scale with
  61964. * @returns a new vector with the result
  61965. */
  61966. scale(scale: number): Vector4;
  61967. /**
  61968. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61969. * @param scale the number to scale with
  61970. * @param result a vector to store the result in
  61971. * @returns the current Vector4.
  61972. */
  61973. scaleToRef(scale: number, result: Vector4): Vector4;
  61974. /**
  61975. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61976. * @param scale defines the scale factor
  61977. * @param result defines the Vector4 object where to store the result
  61978. * @returns the unmodified current Vector4
  61979. */
  61980. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61981. /**
  61982. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61983. * @param otherVector the vector to compare against
  61984. * @returns true if they are equal
  61985. */
  61986. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61987. /**
  61988. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61989. * @param otherVector vector to compare against
  61990. * @param epsilon (Default: very small number)
  61991. * @returns true if they are equal
  61992. */
  61993. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61994. /**
  61995. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61996. * @param x x value to compare against
  61997. * @param y y value to compare against
  61998. * @param z z value to compare against
  61999. * @param w w value to compare against
  62000. * @returns true if equal
  62001. */
  62002. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  62003. /**
  62004. * Multiplies in place the current Vector4 by the given one.
  62005. * @param otherVector vector to multiple with
  62006. * @returns the updated Vector4.
  62007. */
  62008. multiplyInPlace(otherVector: Vector4): Vector4;
  62009. /**
  62010. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  62011. * @param otherVector vector to multiple with
  62012. * @returns resulting new vector
  62013. */
  62014. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  62015. /**
  62016. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  62017. * @param otherVector vector to multiple with
  62018. * @param result vector to store the result
  62019. * @returns the current Vector4.
  62020. */
  62021. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62022. /**
  62023. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  62024. * @param x x value multiply with
  62025. * @param y y value multiply with
  62026. * @param z z value multiply with
  62027. * @param w w value multiply with
  62028. * @returns resulting new vector
  62029. */
  62030. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  62031. /**
  62032. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  62033. * @param otherVector vector to devide with
  62034. * @returns resulting new vector
  62035. */
  62036. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  62037. /**
  62038. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  62039. * @param otherVector vector to devide with
  62040. * @param result vector to store the result
  62041. * @returns the current Vector4.
  62042. */
  62043. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62044. /**
  62045. * Divides the current Vector3 coordinates by the given ones.
  62046. * @param otherVector vector to devide with
  62047. * @returns the updated Vector3.
  62048. */
  62049. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62050. /**
  62051. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  62052. * @param other defines the second operand
  62053. * @returns the current updated Vector4
  62054. */
  62055. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62056. /**
  62057. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  62058. * @param other defines the second operand
  62059. * @returns the current updated Vector4
  62060. */
  62061. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62062. /**
  62063. * Gets a new Vector4 from current Vector4 floored values
  62064. * @returns a new Vector4
  62065. */
  62066. floor(): Vector4;
  62067. /**
  62068. * Gets a new Vector4 from current Vector3 floored values
  62069. * @returns a new Vector4
  62070. */
  62071. fract(): Vector4;
  62072. /**
  62073. * Returns the Vector4 length (float).
  62074. * @returns the length
  62075. */
  62076. length(): number;
  62077. /**
  62078. * Returns the Vector4 squared length (float).
  62079. * @returns the length squared
  62080. */
  62081. lengthSquared(): number;
  62082. /**
  62083. * Normalizes in place the Vector4.
  62084. * @returns the updated Vector4.
  62085. */
  62086. normalize(): Vector4;
  62087. /**
  62088. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  62089. * @returns this converted to a new vector3
  62090. */
  62091. toVector3(): Vector3;
  62092. /**
  62093. * Returns a new Vector4 copied from the current one.
  62094. * @returns the new cloned vector
  62095. */
  62096. clone(): Vector4;
  62097. /**
  62098. * Updates the current Vector4 with the given one coordinates.
  62099. * @param source the source vector to copy from
  62100. * @returns the updated Vector4.
  62101. */
  62102. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  62103. /**
  62104. * Updates the current Vector4 coordinates with the given floats.
  62105. * @param x float to copy from
  62106. * @param y float to copy from
  62107. * @param z float to copy from
  62108. * @param w float to copy from
  62109. * @returns the updated Vector4.
  62110. */
  62111. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62112. /**
  62113. * Updates the current Vector4 coordinates with the given floats.
  62114. * @param x float to set from
  62115. * @param y float to set from
  62116. * @param z float to set from
  62117. * @param w float to set from
  62118. * @returns the updated Vector4.
  62119. */
  62120. set(x: number, y: number, z: number, w: number): Vector4;
  62121. /**
  62122. * Copies the given float to the current Vector3 coordinates
  62123. * @param v defines the x, y, z and w coordinates of the operand
  62124. * @returns the current updated Vector3
  62125. */
  62126. setAll(v: number): Vector4;
  62127. /**
  62128. * Returns a new Vector4 set from the starting index of the given array.
  62129. * @param array the array to pull values from
  62130. * @param offset the offset into the array to start at
  62131. * @returns the new vector
  62132. */
  62133. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  62134. /**
  62135. * Updates the given vector "result" from the starting index of the given array.
  62136. * @param array the array to pull values from
  62137. * @param offset the offset into the array to start at
  62138. * @param result the vector to store the result in
  62139. */
  62140. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  62141. /**
  62142. * Updates the given vector "result" from the starting index of the given Float32Array.
  62143. * @param array the array to pull values from
  62144. * @param offset the offset into the array to start at
  62145. * @param result the vector to store the result in
  62146. */
  62147. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  62148. /**
  62149. * Updates the given vector "result" coordinates from the given floats.
  62150. * @param x float to set from
  62151. * @param y float to set from
  62152. * @param z float to set from
  62153. * @param w float to set from
  62154. * @param result the vector to the floats in
  62155. */
  62156. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  62157. /**
  62158. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  62159. * @returns the new vector
  62160. */
  62161. static Zero(): Vector4;
  62162. /**
  62163. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  62164. * @returns the new vector
  62165. */
  62166. static One(): Vector4;
  62167. /**
  62168. * Returns a new normalized Vector4 from the given one.
  62169. * @param vector the vector to normalize
  62170. * @returns the vector
  62171. */
  62172. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  62173. /**
  62174. * Updates the given vector "result" from the normalization of the given one.
  62175. * @param vector the vector to normalize
  62176. * @param result the vector to store the result in
  62177. */
  62178. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  62179. /**
  62180. * Returns a vector with the minimum values from the left and right vectors
  62181. * @param left left vector to minimize
  62182. * @param right right vector to minimize
  62183. * @returns a new vector with the minimum of the left and right vector values
  62184. */
  62185. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62186. /**
  62187. * Returns a vector with the maximum values from the left and right vectors
  62188. * @param left left vector to maximize
  62189. * @param right right vector to maximize
  62190. * @returns a new vector with the maximum of the left and right vector values
  62191. */
  62192. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62193. /**
  62194. * Returns the distance (float) between the vectors "value1" and "value2".
  62195. * @param value1 value to calulate the distance between
  62196. * @param value2 value to calulate the distance between
  62197. * @return the distance between the two vectors
  62198. */
  62199. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62200. /**
  62201. * Returns the squared distance (float) between the vectors "value1" and "value2".
  62202. * @param value1 value to calulate the distance between
  62203. * @param value2 value to calulate the distance between
  62204. * @return the distance between the two vectors squared
  62205. */
  62206. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62207. /**
  62208. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  62209. * @param value1 value to calulate the center between
  62210. * @param value2 value to calulate the center between
  62211. * @return the center between the two vectors
  62212. */
  62213. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  62214. /**
  62215. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  62216. * This methods computes transformed normalized direction vectors only.
  62217. * @param vector the vector to transform
  62218. * @param transformation the transformation matrix to apply
  62219. * @returns the new vector
  62220. */
  62221. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  62222. /**
  62223. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  62224. * This methods computes transformed normalized direction vectors only.
  62225. * @param vector the vector to transform
  62226. * @param transformation the transformation matrix to apply
  62227. * @param result the vector to store the result in
  62228. */
  62229. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62230. /**
  62231. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  62232. * This methods computes transformed normalized direction vectors only.
  62233. * @param x value to transform
  62234. * @param y value to transform
  62235. * @param z value to transform
  62236. * @param w value to transform
  62237. * @param transformation the transformation matrix to apply
  62238. * @param result the vector to store the results in
  62239. */
  62240. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62241. /**
  62242. * Creates a new Vector4 from a Vector3
  62243. * @param source defines the source data
  62244. * @param w defines the 4th component (default is 0)
  62245. * @returns a new Vector4
  62246. */
  62247. static FromVector3(source: Vector3, w?: number): Vector4;
  62248. }
  62249. /**
  62250. * Interface for the size containing width and height
  62251. */
  62252. export interface ISize {
  62253. /**
  62254. * Width
  62255. */
  62256. width: number;
  62257. /**
  62258. * Heighht
  62259. */
  62260. height: number;
  62261. }
  62262. /**
  62263. * Size containing widht and height
  62264. */
  62265. export class Size implements ISize {
  62266. /**
  62267. * Width
  62268. */
  62269. width: number;
  62270. /**
  62271. * Height
  62272. */
  62273. height: number;
  62274. /**
  62275. * Creates a Size object from the given width and height (floats).
  62276. * @param width width of the new size
  62277. * @param height height of the new size
  62278. */
  62279. constructor(width: number, height: number);
  62280. /**
  62281. * Returns a string with the Size width and height
  62282. * @returns a string with the Size width and height
  62283. */
  62284. toString(): string;
  62285. /**
  62286. * "Size"
  62287. * @returns the string "Size"
  62288. */
  62289. getClassName(): string;
  62290. /**
  62291. * Returns the Size hash code.
  62292. * @returns a hash code for a unique width and height
  62293. */
  62294. getHashCode(): number;
  62295. /**
  62296. * Updates the current size from the given one.
  62297. * @param src the given size
  62298. */
  62299. copyFrom(src: Size): void;
  62300. /**
  62301. * Updates in place the current Size from the given floats.
  62302. * @param width width of the new size
  62303. * @param height height of the new size
  62304. * @returns the updated Size.
  62305. */
  62306. copyFromFloats(width: number, height: number): Size;
  62307. /**
  62308. * Updates in place the current Size from the given floats.
  62309. * @param width width to set
  62310. * @param height height to set
  62311. * @returns the updated Size.
  62312. */
  62313. set(width: number, height: number): Size;
  62314. /**
  62315. * Multiplies the width and height by numbers
  62316. * @param w factor to multiple the width by
  62317. * @param h factor to multiple the height by
  62318. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62319. */
  62320. multiplyByFloats(w: number, h: number): Size;
  62321. /**
  62322. * Clones the size
  62323. * @returns a new Size copied from the given one.
  62324. */
  62325. clone(): Size;
  62326. /**
  62327. * True if the current Size and the given one width and height are strictly equal.
  62328. * @param other the other size to compare against
  62329. * @returns True if the current Size and the given one width and height are strictly equal.
  62330. */
  62331. equals(other: Size): boolean;
  62332. /**
  62333. * The surface of the Size : width * height (float).
  62334. */
  62335. readonly surface: number;
  62336. /**
  62337. * Create a new size of zero
  62338. * @returns a new Size set to (0.0, 0.0)
  62339. */
  62340. static Zero(): Size;
  62341. /**
  62342. * Sums the width and height of two sizes
  62343. * @param otherSize size to add to this size
  62344. * @returns a new Size set as the addition result of the current Size and the given one.
  62345. */
  62346. add(otherSize: Size): Size;
  62347. /**
  62348. * Subtracts the width and height of two
  62349. * @param otherSize size to subtract to this size
  62350. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62351. */
  62352. subtract(otherSize: Size): Size;
  62353. /**
  62354. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62355. * @param start starting size to lerp between
  62356. * @param end end size to lerp between
  62357. * @param amount amount to lerp between the start and end values
  62358. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62359. */
  62360. static Lerp(start: Size, end: Size, amount: number): Size;
  62361. }
  62362. /**
  62363. * Class used to store quaternion data
  62364. * @see https://en.wikipedia.org/wiki/Quaternion
  62365. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62366. */
  62367. export class Quaternion {
  62368. /** defines the first component (0 by default) */
  62369. x: number;
  62370. /** defines the second component (0 by default) */
  62371. y: number;
  62372. /** defines the third component (0 by default) */
  62373. z: number;
  62374. /** defines the fourth component (1.0 by default) */
  62375. w: number;
  62376. /**
  62377. * Creates a new Quaternion from the given floats
  62378. * @param x defines the first component (0 by default)
  62379. * @param y defines the second component (0 by default)
  62380. * @param z defines the third component (0 by default)
  62381. * @param w defines the fourth component (1.0 by default)
  62382. */
  62383. constructor(
  62384. /** defines the first component (0 by default) */
  62385. x?: number,
  62386. /** defines the second component (0 by default) */
  62387. y?: number,
  62388. /** defines the third component (0 by default) */
  62389. z?: number,
  62390. /** defines the fourth component (1.0 by default) */
  62391. w?: number);
  62392. /**
  62393. * Gets a string representation for the current quaternion
  62394. * @returns a string with the Quaternion coordinates
  62395. */
  62396. toString(): string;
  62397. /**
  62398. * Gets the class name of the quaternion
  62399. * @returns the string "Quaternion"
  62400. */
  62401. getClassName(): string;
  62402. /**
  62403. * Gets a hash code for this quaternion
  62404. * @returns the quaternion hash code
  62405. */
  62406. getHashCode(): number;
  62407. /**
  62408. * Copy the quaternion to an array
  62409. * @returns a new array populated with 4 elements from the quaternion coordinates
  62410. */
  62411. asArray(): number[];
  62412. /**
  62413. * Check if two quaternions are equals
  62414. * @param otherQuaternion defines the second operand
  62415. * @return true if the current quaternion and the given one coordinates are strictly equals
  62416. */
  62417. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62418. /**
  62419. * Clone the current quaternion
  62420. * @returns a new quaternion copied from the current one
  62421. */
  62422. clone(): Quaternion;
  62423. /**
  62424. * Copy a quaternion to the current one
  62425. * @param other defines the other quaternion
  62426. * @returns the updated current quaternion
  62427. */
  62428. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62429. /**
  62430. * Updates the current quaternion with the given float coordinates
  62431. * @param x defines the x coordinate
  62432. * @param y defines the y coordinate
  62433. * @param z defines the z coordinate
  62434. * @param w defines the w coordinate
  62435. * @returns the updated current quaternion
  62436. */
  62437. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62438. /**
  62439. * Updates the current quaternion from the given float coordinates
  62440. * @param x defines the x coordinate
  62441. * @param y defines the y coordinate
  62442. * @param z defines the z coordinate
  62443. * @param w defines the w coordinate
  62444. * @returns the updated current quaternion
  62445. */
  62446. set(x: number, y: number, z: number, w: number): Quaternion;
  62447. /**
  62448. * Adds two quaternions
  62449. * @param other defines the second operand
  62450. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62451. */
  62452. add(other: DeepImmutable<Quaternion>): Quaternion;
  62453. /**
  62454. * Add a quaternion to the current one
  62455. * @param other defines the quaternion to add
  62456. * @returns the current quaternion
  62457. */
  62458. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62459. /**
  62460. * Subtract two quaternions
  62461. * @param other defines the second operand
  62462. * @returns a new quaternion as the subtraction result of the given one from the current one
  62463. */
  62464. subtract(other: Quaternion): Quaternion;
  62465. /**
  62466. * Multiplies the current quaternion by a scale factor
  62467. * @param value defines the scale factor
  62468. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62469. */
  62470. scale(value: number): Quaternion;
  62471. /**
  62472. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62473. * @param scale defines the scale factor
  62474. * @param result defines the Quaternion object where to store the result
  62475. * @returns the unmodified current quaternion
  62476. */
  62477. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62478. /**
  62479. * Multiplies in place the current quaternion by a scale factor
  62480. * @param value defines the scale factor
  62481. * @returns the current modified quaternion
  62482. */
  62483. scaleInPlace(value: number): Quaternion;
  62484. /**
  62485. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62486. * @param scale defines the scale factor
  62487. * @param result defines the Quaternion object where to store the result
  62488. * @returns the unmodified current quaternion
  62489. */
  62490. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62491. /**
  62492. * Multiplies two quaternions
  62493. * @param q1 defines the second operand
  62494. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62495. */
  62496. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62497. /**
  62498. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62499. * @param q1 defines the second operand
  62500. * @param result defines the target quaternion
  62501. * @returns the current quaternion
  62502. */
  62503. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62504. /**
  62505. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62506. * @param q1 defines the second operand
  62507. * @returns the currentupdated quaternion
  62508. */
  62509. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62510. /**
  62511. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62512. * @param ref defines the target quaternion
  62513. * @returns the current quaternion
  62514. */
  62515. conjugateToRef(ref: Quaternion): Quaternion;
  62516. /**
  62517. * Conjugates in place (1-q) the current quaternion
  62518. * @returns the current updated quaternion
  62519. */
  62520. conjugateInPlace(): Quaternion;
  62521. /**
  62522. * Conjugates in place (1-q) the current quaternion
  62523. * @returns a new quaternion
  62524. */
  62525. conjugate(): Quaternion;
  62526. /**
  62527. * Gets length of current quaternion
  62528. * @returns the quaternion length (float)
  62529. */
  62530. length(): number;
  62531. /**
  62532. * Normalize in place the current quaternion
  62533. * @returns the current updated quaternion
  62534. */
  62535. normalize(): Quaternion;
  62536. /**
  62537. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62538. * @param order is a reserved parameter and is ignore for now
  62539. * @returns a new Vector3 containing the Euler angles
  62540. */
  62541. toEulerAngles(order?: string): Vector3;
  62542. /**
  62543. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62544. * @param result defines the vector which will be filled with the Euler angles
  62545. * @param order is a reserved parameter and is ignore for now
  62546. * @returns the current unchanged quaternion
  62547. */
  62548. toEulerAnglesToRef(result: Vector3): Quaternion;
  62549. /**
  62550. * Updates the given rotation matrix with the current quaternion values
  62551. * @param result defines the target matrix
  62552. * @returns the current unchanged quaternion
  62553. */
  62554. toRotationMatrix(result: Matrix): Quaternion;
  62555. /**
  62556. * Updates the current quaternion from the given rotation matrix values
  62557. * @param matrix defines the source matrix
  62558. * @returns the current updated quaternion
  62559. */
  62560. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62561. /**
  62562. * Creates a new quaternion from a rotation matrix
  62563. * @param matrix defines the source matrix
  62564. * @returns a new quaternion created from the given rotation matrix values
  62565. */
  62566. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62567. /**
  62568. * Updates the given quaternion with the given rotation matrix values
  62569. * @param matrix defines the source matrix
  62570. * @param result defines the target quaternion
  62571. */
  62572. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62573. /**
  62574. * Returns the dot product (float) between the quaternions "left" and "right"
  62575. * @param left defines the left operand
  62576. * @param right defines the right operand
  62577. * @returns the dot product
  62578. */
  62579. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62580. /**
  62581. * Checks if the two quaternions are close to each other
  62582. * @param quat0 defines the first quaternion to check
  62583. * @param quat1 defines the second quaternion to check
  62584. * @returns true if the two quaternions are close to each other
  62585. */
  62586. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62587. /**
  62588. * Creates an empty quaternion
  62589. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62590. */
  62591. static Zero(): Quaternion;
  62592. /**
  62593. * Inverse a given quaternion
  62594. * @param q defines the source quaternion
  62595. * @returns a new quaternion as the inverted current quaternion
  62596. */
  62597. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62598. /**
  62599. * Inverse a given quaternion
  62600. * @param q defines the source quaternion
  62601. * @param result the quaternion the result will be stored in
  62602. * @returns the result quaternion
  62603. */
  62604. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62605. /**
  62606. * Creates an identity quaternion
  62607. * @returns the identity quaternion
  62608. */
  62609. static Identity(): Quaternion;
  62610. /**
  62611. * Gets a boolean indicating if the given quaternion is identity
  62612. * @param quaternion defines the quaternion to check
  62613. * @returns true if the quaternion is identity
  62614. */
  62615. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62616. /**
  62617. * Creates a quaternion from a rotation around an axis
  62618. * @param axis defines the axis to use
  62619. * @param angle defines the angle to use
  62620. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62621. */
  62622. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62623. /**
  62624. * Creates a rotation around an axis and stores it into the given quaternion
  62625. * @param axis defines the axis to use
  62626. * @param angle defines the angle to use
  62627. * @param result defines the target quaternion
  62628. * @returns the target quaternion
  62629. */
  62630. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62631. /**
  62632. * Creates a new quaternion from data stored into an array
  62633. * @param array defines the data source
  62634. * @param offset defines the offset in the source array where the data starts
  62635. * @returns a new quaternion
  62636. */
  62637. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62638. /**
  62639. * Create a quaternion from Euler rotation angles
  62640. * @param x Pitch
  62641. * @param y Yaw
  62642. * @param z Roll
  62643. * @returns the new Quaternion
  62644. */
  62645. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62646. /**
  62647. * Updates a quaternion from Euler rotation angles
  62648. * @param x Pitch
  62649. * @param y Yaw
  62650. * @param z Roll
  62651. * @param result the quaternion to store the result
  62652. * @returns the updated quaternion
  62653. */
  62654. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62655. /**
  62656. * Create a quaternion from Euler rotation vector
  62657. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62658. * @returns the new Quaternion
  62659. */
  62660. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62661. /**
  62662. * Updates a quaternion from Euler rotation vector
  62663. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62664. * @param result the quaternion to store the result
  62665. * @returns the updated quaternion
  62666. */
  62667. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62668. /**
  62669. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62670. * @param yaw defines the rotation around Y axis
  62671. * @param pitch defines the rotation around X axis
  62672. * @param roll defines the rotation around Z axis
  62673. * @returns the new quaternion
  62674. */
  62675. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62676. /**
  62677. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62678. * @param yaw defines the rotation around Y axis
  62679. * @param pitch defines the rotation around X axis
  62680. * @param roll defines the rotation around Z axis
  62681. * @param result defines the target quaternion
  62682. */
  62683. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62684. /**
  62685. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62686. * @param alpha defines the rotation around first axis
  62687. * @param beta defines the rotation around second axis
  62688. * @param gamma defines the rotation around third axis
  62689. * @returns the new quaternion
  62690. */
  62691. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62692. /**
  62693. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62694. * @param alpha defines the rotation around first axis
  62695. * @param beta defines the rotation around second axis
  62696. * @param gamma defines the rotation around third axis
  62697. * @param result defines the target quaternion
  62698. */
  62699. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62700. /**
  62701. * 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)
  62702. * @param axis1 defines the first axis
  62703. * @param axis2 defines the second axis
  62704. * @param axis3 defines the third axis
  62705. * @returns the new quaternion
  62706. */
  62707. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62708. /**
  62709. * 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
  62710. * @param axis1 defines the first axis
  62711. * @param axis2 defines the second axis
  62712. * @param axis3 defines the third axis
  62713. * @param ref defines the target quaternion
  62714. */
  62715. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62716. /**
  62717. * Interpolates between two quaternions
  62718. * @param left defines first quaternion
  62719. * @param right defines second quaternion
  62720. * @param amount defines the gradient to use
  62721. * @returns the new interpolated quaternion
  62722. */
  62723. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62724. /**
  62725. * Interpolates between two quaternions and stores it into a target quaternion
  62726. * @param left defines first quaternion
  62727. * @param right defines second quaternion
  62728. * @param amount defines the gradient to use
  62729. * @param result defines the target quaternion
  62730. */
  62731. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62732. /**
  62733. * Interpolate between two quaternions using Hermite interpolation
  62734. * @param value1 defines first quaternion
  62735. * @param tangent1 defines the incoming tangent
  62736. * @param value2 defines second quaternion
  62737. * @param tangent2 defines the outgoing tangent
  62738. * @param amount defines the target quaternion
  62739. * @returns the new interpolated quaternion
  62740. */
  62741. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62742. }
  62743. /**
  62744. * Class used to store matrix data (4x4)
  62745. */
  62746. export class Matrix {
  62747. private static _updateFlagSeed;
  62748. private static _identityReadOnly;
  62749. private _isIdentity;
  62750. private _isIdentityDirty;
  62751. private _isIdentity3x2;
  62752. private _isIdentity3x2Dirty;
  62753. /**
  62754. * Gets the update flag of the matrix which is an unique number for the matrix.
  62755. * It will be incremented every time the matrix data change.
  62756. * You can use it to speed the comparison between two versions of the same matrix.
  62757. */
  62758. updateFlag: number;
  62759. private readonly _m;
  62760. /**
  62761. * Gets the internal data of the matrix
  62762. */
  62763. readonly m: DeepImmutable<Float32Array>;
  62764. /** @hidden */
  62765. _markAsUpdated(): void;
  62766. /** @hidden */
  62767. private _updateIdentityStatus;
  62768. /**
  62769. * Creates an empty matrix (filled with zeros)
  62770. */
  62771. constructor();
  62772. /**
  62773. * Check if the current matrix is identity
  62774. * @returns true is the matrix is the identity matrix
  62775. */
  62776. isIdentity(): boolean;
  62777. /**
  62778. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62779. * @returns true is the matrix is the identity matrix
  62780. */
  62781. isIdentityAs3x2(): boolean;
  62782. /**
  62783. * Gets the determinant of the matrix
  62784. * @returns the matrix determinant
  62785. */
  62786. determinant(): number;
  62787. /**
  62788. * Returns the matrix as a Float32Array
  62789. * @returns the matrix underlying array
  62790. */
  62791. toArray(): DeepImmutable<Float32Array>;
  62792. /**
  62793. * Returns the matrix as a Float32Array
  62794. * @returns the matrix underlying array.
  62795. */
  62796. asArray(): DeepImmutable<Float32Array>;
  62797. /**
  62798. * Inverts the current matrix in place
  62799. * @returns the current inverted matrix
  62800. */
  62801. invert(): Matrix;
  62802. /**
  62803. * Sets all the matrix elements to zero
  62804. * @returns the current matrix
  62805. */
  62806. reset(): Matrix;
  62807. /**
  62808. * Adds the current matrix with a second one
  62809. * @param other defines the matrix to add
  62810. * @returns a new matrix as the addition of the current matrix and the given one
  62811. */
  62812. add(other: DeepImmutable<Matrix>): Matrix;
  62813. /**
  62814. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62815. * @param other defines the matrix to add
  62816. * @param result defines the target matrix
  62817. * @returns the current matrix
  62818. */
  62819. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62820. /**
  62821. * Adds in place the given matrix to the current matrix
  62822. * @param other defines the second operand
  62823. * @returns the current updated matrix
  62824. */
  62825. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62826. /**
  62827. * Sets the given matrix to the current inverted Matrix
  62828. * @param other defines the target matrix
  62829. * @returns the unmodified current matrix
  62830. */
  62831. invertToRef(other: Matrix): Matrix;
  62832. /**
  62833. * add a value at the specified position in the current Matrix
  62834. * @param index the index of the value within the matrix. between 0 and 15.
  62835. * @param value the value to be added
  62836. * @returns the current updated matrix
  62837. */
  62838. addAtIndex(index: number, value: number): Matrix;
  62839. /**
  62840. * mutiply the specified position in the current Matrix by a value
  62841. * @param index the index of the value within the matrix. between 0 and 15.
  62842. * @param value the value to be added
  62843. * @returns the current updated matrix
  62844. */
  62845. multiplyAtIndex(index: number, value: number): Matrix;
  62846. /**
  62847. * Inserts the translation vector (using 3 floats) in the current matrix
  62848. * @param x defines the 1st component of the translation
  62849. * @param y defines the 2nd component of the translation
  62850. * @param z defines the 3rd component of the translation
  62851. * @returns the current updated matrix
  62852. */
  62853. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62854. /**
  62855. * Adds the translation vector (using 3 floats) in the current matrix
  62856. * @param x defines the 1st component of the translation
  62857. * @param y defines the 2nd component of the translation
  62858. * @param z defines the 3rd component of the translation
  62859. * @returns the current updated matrix
  62860. */
  62861. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62862. /**
  62863. * Inserts the translation vector in the current matrix
  62864. * @param vector3 defines the translation to insert
  62865. * @returns the current updated matrix
  62866. */
  62867. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62868. /**
  62869. * Gets the translation value of the current matrix
  62870. * @returns a new Vector3 as the extracted translation from the matrix
  62871. */
  62872. getTranslation(): Vector3;
  62873. /**
  62874. * Fill a Vector3 with the extracted translation from the matrix
  62875. * @param result defines the Vector3 where to store the translation
  62876. * @returns the current matrix
  62877. */
  62878. getTranslationToRef(result: Vector3): Matrix;
  62879. /**
  62880. * Remove rotation and scaling part from the matrix
  62881. * @returns the updated matrix
  62882. */
  62883. removeRotationAndScaling(): Matrix;
  62884. /**
  62885. * Multiply two matrices
  62886. * @param other defines the second operand
  62887. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62888. */
  62889. multiply(other: DeepImmutable<Matrix>): Matrix;
  62890. /**
  62891. * Copy the current matrix from the given one
  62892. * @param other defines the source matrix
  62893. * @returns the current updated matrix
  62894. */
  62895. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62896. /**
  62897. * Populates the given array from the starting index with the current matrix values
  62898. * @param array defines the target array
  62899. * @param offset defines the offset in the target array where to start storing values
  62900. * @returns the current matrix
  62901. */
  62902. copyToArray(array: Float32Array, offset?: number): Matrix;
  62903. /**
  62904. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62905. * @param other defines the second operand
  62906. * @param result defines the matrix where to store the multiplication
  62907. * @returns the current matrix
  62908. */
  62909. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62910. /**
  62911. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62912. * @param other defines the second operand
  62913. * @param result defines the array where to store the multiplication
  62914. * @param offset defines the offset in the target array where to start storing values
  62915. * @returns the current matrix
  62916. */
  62917. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62918. /**
  62919. * Check equality between this matrix and a second one
  62920. * @param value defines the second matrix to compare
  62921. * @returns true is the current matrix and the given one values are strictly equal
  62922. */
  62923. equals(value: DeepImmutable<Matrix>): boolean;
  62924. /**
  62925. * Clone the current matrix
  62926. * @returns a new matrix from the current matrix
  62927. */
  62928. clone(): Matrix;
  62929. /**
  62930. * Returns the name of the current matrix class
  62931. * @returns the string "Matrix"
  62932. */
  62933. getClassName(): string;
  62934. /**
  62935. * Gets the hash code of the current matrix
  62936. * @returns the hash code
  62937. */
  62938. getHashCode(): number;
  62939. /**
  62940. * Decomposes the current Matrix into a translation, rotation and scaling components
  62941. * @param scale defines the scale vector3 given as a reference to update
  62942. * @param rotation defines the rotation quaternion given as a reference to update
  62943. * @param translation defines the translation vector3 given as a reference to update
  62944. * @returns true if operation was successful
  62945. */
  62946. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62947. /**
  62948. * Gets specific row of the matrix
  62949. * @param index defines the number of the row to get
  62950. * @returns the index-th row of the current matrix as a new Vector4
  62951. */
  62952. getRow(index: number): Nullable<Vector4>;
  62953. /**
  62954. * Sets the index-th row of the current matrix to the vector4 values
  62955. * @param index defines the number of the row to set
  62956. * @param row defines the target vector4
  62957. * @returns the updated current matrix
  62958. */
  62959. setRow(index: number, row: Vector4): Matrix;
  62960. /**
  62961. * Compute the transpose of the matrix
  62962. * @returns the new transposed matrix
  62963. */
  62964. transpose(): Matrix;
  62965. /**
  62966. * Compute the transpose of the matrix and store it in a given matrix
  62967. * @param result defines the target matrix
  62968. * @returns the current matrix
  62969. */
  62970. transposeToRef(result: Matrix): Matrix;
  62971. /**
  62972. * Sets the index-th row of the current matrix with the given 4 x float values
  62973. * @param index defines the row index
  62974. * @param x defines the x component to set
  62975. * @param y defines the y component to set
  62976. * @param z defines the z component to set
  62977. * @param w defines the w component to set
  62978. * @returns the updated current matrix
  62979. */
  62980. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62981. /**
  62982. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62983. * @param scale defines the scale factor
  62984. * @returns a new matrix
  62985. */
  62986. scale(scale: number): Matrix;
  62987. /**
  62988. * Scale the current matrix values by a factor to a given result matrix
  62989. * @param scale defines the scale factor
  62990. * @param result defines the matrix to store the result
  62991. * @returns the current matrix
  62992. */
  62993. scaleToRef(scale: number, result: Matrix): Matrix;
  62994. /**
  62995. * Scale the current matrix values by a factor and add the result to a given matrix
  62996. * @param scale defines the scale factor
  62997. * @param result defines the Matrix to store the result
  62998. * @returns the current matrix
  62999. */
  63000. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  63001. /**
  63002. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  63003. * @param ref matrix to store the result
  63004. */
  63005. toNormalMatrix(ref: Matrix): void;
  63006. /**
  63007. * Gets only rotation part of the current matrix
  63008. * @returns a new matrix sets to the extracted rotation matrix from the current one
  63009. */
  63010. getRotationMatrix(): Matrix;
  63011. /**
  63012. * Extracts the rotation matrix from the current one and sets it as the given "result"
  63013. * @param result defines the target matrix to store data to
  63014. * @returns the current matrix
  63015. */
  63016. getRotationMatrixToRef(result: Matrix): Matrix;
  63017. /**
  63018. * Toggles model matrix from being right handed to left handed in place and vice versa
  63019. */
  63020. toggleModelMatrixHandInPlace(): void;
  63021. /**
  63022. * Toggles projection matrix from being right handed to left handed in place and vice versa
  63023. */
  63024. toggleProjectionMatrixHandInPlace(): void;
  63025. /**
  63026. * Creates a matrix from an array
  63027. * @param array defines the source array
  63028. * @param offset defines an offset in the source array
  63029. * @returns a new Matrix set from the starting index of the given array
  63030. */
  63031. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  63032. /**
  63033. * Copy the content of an array into a given matrix
  63034. * @param array defines the source array
  63035. * @param offset defines an offset in the source array
  63036. * @param result defines the target matrix
  63037. */
  63038. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  63039. /**
  63040. * Stores an array into a matrix after having multiplied each component by a given factor
  63041. * @param array defines the source array
  63042. * @param offset defines the offset in the source array
  63043. * @param scale defines the scaling factor
  63044. * @param result defines the target matrix
  63045. */
  63046. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  63047. /**
  63048. * Gets an identity matrix that must not be updated
  63049. */
  63050. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  63051. /**
  63052. * Stores a list of values (16) inside a given matrix
  63053. * @param initialM11 defines 1st value of 1st row
  63054. * @param initialM12 defines 2nd value of 1st row
  63055. * @param initialM13 defines 3rd value of 1st row
  63056. * @param initialM14 defines 4th value of 1st row
  63057. * @param initialM21 defines 1st value of 2nd row
  63058. * @param initialM22 defines 2nd value of 2nd row
  63059. * @param initialM23 defines 3rd value of 2nd row
  63060. * @param initialM24 defines 4th value of 2nd row
  63061. * @param initialM31 defines 1st value of 3rd row
  63062. * @param initialM32 defines 2nd value of 3rd row
  63063. * @param initialM33 defines 3rd value of 3rd row
  63064. * @param initialM34 defines 4th value of 3rd row
  63065. * @param initialM41 defines 1st value of 4th row
  63066. * @param initialM42 defines 2nd value of 4th row
  63067. * @param initialM43 defines 3rd value of 4th row
  63068. * @param initialM44 defines 4th value of 4th row
  63069. * @param result defines the target matrix
  63070. */
  63071. 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;
  63072. /**
  63073. * Creates new matrix from a list of values (16)
  63074. * @param initialM11 defines 1st value of 1st row
  63075. * @param initialM12 defines 2nd value of 1st row
  63076. * @param initialM13 defines 3rd value of 1st row
  63077. * @param initialM14 defines 4th value of 1st row
  63078. * @param initialM21 defines 1st value of 2nd row
  63079. * @param initialM22 defines 2nd value of 2nd row
  63080. * @param initialM23 defines 3rd value of 2nd row
  63081. * @param initialM24 defines 4th value of 2nd row
  63082. * @param initialM31 defines 1st value of 3rd row
  63083. * @param initialM32 defines 2nd value of 3rd row
  63084. * @param initialM33 defines 3rd value of 3rd row
  63085. * @param initialM34 defines 4th value of 3rd row
  63086. * @param initialM41 defines 1st value of 4th row
  63087. * @param initialM42 defines 2nd value of 4th row
  63088. * @param initialM43 defines 3rd value of 4th row
  63089. * @param initialM44 defines 4th value of 4th row
  63090. * @returns the new matrix
  63091. */
  63092. 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;
  63093. /**
  63094. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63095. * @param scale defines the scale vector3
  63096. * @param rotation defines the rotation quaternion
  63097. * @param translation defines the translation vector3
  63098. * @returns a new matrix
  63099. */
  63100. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  63101. /**
  63102. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63103. * @param scale defines the scale vector3
  63104. * @param rotation defines the rotation quaternion
  63105. * @param translation defines the translation vector3
  63106. * @param result defines the target matrix
  63107. */
  63108. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  63109. /**
  63110. * Creates a new identity matrix
  63111. * @returns a new identity matrix
  63112. */
  63113. static Identity(): Matrix;
  63114. /**
  63115. * Creates a new identity matrix and stores the result in a given matrix
  63116. * @param result defines the target matrix
  63117. */
  63118. static IdentityToRef(result: Matrix): void;
  63119. /**
  63120. * Creates a new zero matrix
  63121. * @returns a new zero matrix
  63122. */
  63123. static Zero(): Matrix;
  63124. /**
  63125. * Creates a new rotation matrix for "angle" radians around the X axis
  63126. * @param angle defines the angle (in radians) to use
  63127. * @return the new matrix
  63128. */
  63129. static RotationX(angle: number): Matrix;
  63130. /**
  63131. * Creates a new matrix as the invert of a given matrix
  63132. * @param source defines the source matrix
  63133. * @returns the new matrix
  63134. */
  63135. static Invert(source: DeepImmutable<Matrix>): Matrix;
  63136. /**
  63137. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  63138. * @param angle defines the angle (in radians) to use
  63139. * @param result defines the target matrix
  63140. */
  63141. static RotationXToRef(angle: number, result: Matrix): void;
  63142. /**
  63143. * Creates a new rotation matrix for "angle" radians around the Y axis
  63144. * @param angle defines the angle (in radians) to use
  63145. * @return the new matrix
  63146. */
  63147. static RotationY(angle: number): Matrix;
  63148. /**
  63149. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  63150. * @param angle defines the angle (in radians) to use
  63151. * @param result defines the target matrix
  63152. */
  63153. static RotationYToRef(angle: number, result: Matrix): void;
  63154. /**
  63155. * Creates a new rotation matrix for "angle" radians around the Z axis
  63156. * @param angle defines the angle (in radians) to use
  63157. * @return the new matrix
  63158. */
  63159. static RotationZ(angle: number): Matrix;
  63160. /**
  63161. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  63162. * @param angle defines the angle (in radians) to use
  63163. * @param result defines the target matrix
  63164. */
  63165. static RotationZToRef(angle: number, result: Matrix): void;
  63166. /**
  63167. * Creates a new rotation matrix for "angle" radians around the given axis
  63168. * @param axis defines the axis to use
  63169. * @param angle defines the angle (in radians) to use
  63170. * @return the new matrix
  63171. */
  63172. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  63173. /**
  63174. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  63175. * @param axis defines the axis to use
  63176. * @param angle defines the angle (in radians) to use
  63177. * @param result defines the target matrix
  63178. */
  63179. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  63180. /**
  63181. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  63182. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  63183. * @param from defines the vector to align
  63184. * @param to defines the vector to align to
  63185. * @param result defines the target matrix
  63186. */
  63187. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  63188. /**
  63189. * Creates a rotation matrix
  63190. * @param yaw defines the yaw angle in radians (Y axis)
  63191. * @param pitch defines the pitch angle in radians (X axis)
  63192. * @param roll defines the roll angle in radians (X axis)
  63193. * @returns the new rotation matrix
  63194. */
  63195. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  63196. /**
  63197. * Creates a rotation matrix and stores it in a given matrix
  63198. * @param yaw defines the yaw angle in radians (Y axis)
  63199. * @param pitch defines the pitch angle in radians (X axis)
  63200. * @param roll defines the roll angle in radians (X axis)
  63201. * @param result defines the target matrix
  63202. */
  63203. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  63204. /**
  63205. * Creates a scaling matrix
  63206. * @param x defines the scale factor on X axis
  63207. * @param y defines the scale factor on Y axis
  63208. * @param z defines the scale factor on Z axis
  63209. * @returns the new matrix
  63210. */
  63211. static Scaling(x: number, y: number, z: number): Matrix;
  63212. /**
  63213. * Creates a scaling matrix and stores it in a given matrix
  63214. * @param x defines the scale factor on X axis
  63215. * @param y defines the scale factor on Y axis
  63216. * @param z defines the scale factor on Z axis
  63217. * @param result defines the target matrix
  63218. */
  63219. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  63220. /**
  63221. * Creates a translation matrix
  63222. * @param x defines the translation on X axis
  63223. * @param y defines the translation on Y axis
  63224. * @param z defines the translationon Z axis
  63225. * @returns the new matrix
  63226. */
  63227. static Translation(x: number, y: number, z: number): Matrix;
  63228. /**
  63229. * Creates a translation matrix and stores it in a given matrix
  63230. * @param x defines the translation on X axis
  63231. * @param y defines the translation on Y axis
  63232. * @param z defines the translationon Z axis
  63233. * @param result defines the target matrix
  63234. */
  63235. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  63236. /**
  63237. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63238. * @param startValue defines the start value
  63239. * @param endValue defines the end value
  63240. * @param gradient defines the gradient factor
  63241. * @returns the new matrix
  63242. */
  63243. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63244. /**
  63245. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63246. * @param startValue defines the start value
  63247. * @param endValue defines the end value
  63248. * @param gradient defines the gradient factor
  63249. * @param result defines the Matrix object where to store data
  63250. */
  63251. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63252. /**
  63253. * Builds a new matrix whose values are computed by:
  63254. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63255. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63256. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63257. * @param startValue defines the first matrix
  63258. * @param endValue defines the second matrix
  63259. * @param gradient defines the gradient between the two matrices
  63260. * @returns the new matrix
  63261. */
  63262. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63263. /**
  63264. * Update a matrix to values which are computed by:
  63265. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63266. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63267. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63268. * @param startValue defines the first matrix
  63269. * @param endValue defines the second matrix
  63270. * @param gradient defines the gradient between the two matrices
  63271. * @param result defines the target matrix
  63272. */
  63273. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63274. /**
  63275. * 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"
  63276. * This function works in left handed mode
  63277. * @param eye defines the final position of the entity
  63278. * @param target defines where the entity should look at
  63279. * @param up defines the up vector for the entity
  63280. * @returns the new matrix
  63281. */
  63282. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63283. /**
  63284. * 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".
  63285. * This function works in left handed mode
  63286. * @param eye defines the final position of the entity
  63287. * @param target defines where the entity should look at
  63288. * @param up defines the up vector for the entity
  63289. * @param result defines the target matrix
  63290. */
  63291. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63292. /**
  63293. * 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"
  63294. * This function works in right handed mode
  63295. * @param eye defines the final position of the entity
  63296. * @param target defines where the entity should look at
  63297. * @param up defines the up vector for the entity
  63298. * @returns the new matrix
  63299. */
  63300. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63301. /**
  63302. * 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".
  63303. * This function works in right handed mode
  63304. * @param eye defines the final position of the entity
  63305. * @param target defines where the entity should look at
  63306. * @param up defines the up vector for the entity
  63307. * @param result defines the target matrix
  63308. */
  63309. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63310. /**
  63311. * Create a left-handed orthographic projection matrix
  63312. * @param width defines the viewport width
  63313. * @param height defines the viewport height
  63314. * @param znear defines the near clip plane
  63315. * @param zfar defines the far clip plane
  63316. * @returns a new matrix as a left-handed orthographic projection matrix
  63317. */
  63318. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63319. /**
  63320. * Store a left-handed orthographic projection to a given matrix
  63321. * @param width defines the viewport width
  63322. * @param height defines the viewport height
  63323. * @param znear defines the near clip plane
  63324. * @param zfar defines the far clip plane
  63325. * @param result defines the target matrix
  63326. */
  63327. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63328. /**
  63329. * Create a left-handed orthographic projection matrix
  63330. * @param left defines the viewport left coordinate
  63331. * @param right defines the viewport right coordinate
  63332. * @param bottom defines the viewport bottom coordinate
  63333. * @param top defines the viewport top coordinate
  63334. * @param znear defines the near clip plane
  63335. * @param zfar defines the far clip plane
  63336. * @returns a new matrix as a left-handed orthographic projection matrix
  63337. */
  63338. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63339. /**
  63340. * Stores a left-handed orthographic projection into a given matrix
  63341. * @param left defines the viewport left coordinate
  63342. * @param right defines the viewport right coordinate
  63343. * @param bottom defines the viewport bottom coordinate
  63344. * @param top defines the viewport top coordinate
  63345. * @param znear defines the near clip plane
  63346. * @param zfar defines the far clip plane
  63347. * @param result defines the target matrix
  63348. */
  63349. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63350. /**
  63351. * Creates a right-handed orthographic projection matrix
  63352. * @param left defines the viewport left coordinate
  63353. * @param right defines the viewport right coordinate
  63354. * @param bottom defines the viewport bottom coordinate
  63355. * @param top defines the viewport top coordinate
  63356. * @param znear defines the near clip plane
  63357. * @param zfar defines the far clip plane
  63358. * @returns a new matrix as a right-handed orthographic projection matrix
  63359. */
  63360. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63361. /**
  63362. * Stores a right-handed orthographic projection into a given matrix
  63363. * @param left defines the viewport left coordinate
  63364. * @param right defines the viewport right coordinate
  63365. * @param bottom defines the viewport bottom coordinate
  63366. * @param top defines the viewport top coordinate
  63367. * @param znear defines the near clip plane
  63368. * @param zfar defines the far clip plane
  63369. * @param result defines the target matrix
  63370. */
  63371. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63372. /**
  63373. * Creates a left-handed perspective projection matrix
  63374. * @param width defines the viewport width
  63375. * @param height defines the viewport height
  63376. * @param znear defines the near clip plane
  63377. * @param zfar defines the far clip plane
  63378. * @returns a new matrix as a left-handed perspective projection matrix
  63379. */
  63380. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63381. /**
  63382. * Creates a left-handed perspective projection matrix
  63383. * @param fov defines the horizontal field of view
  63384. * @param aspect defines the aspect ratio
  63385. * @param znear defines the near clip plane
  63386. * @param zfar defines the far clip plane
  63387. * @returns a new matrix as a left-handed perspective projection matrix
  63388. */
  63389. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63390. /**
  63391. * Stores a left-handed perspective projection into a given matrix
  63392. * @param fov defines the horizontal field of view
  63393. * @param aspect defines the aspect ratio
  63394. * @param znear defines the near clip plane
  63395. * @param zfar defines the far clip plane
  63396. * @param result defines the target matrix
  63397. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63398. */
  63399. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63400. /**
  63401. * Creates a right-handed perspective projection matrix
  63402. * @param fov defines the horizontal field of view
  63403. * @param aspect defines the aspect ratio
  63404. * @param znear defines the near clip plane
  63405. * @param zfar defines the far clip plane
  63406. * @returns a new matrix as a right-handed perspective projection matrix
  63407. */
  63408. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63409. /**
  63410. * Stores a right-handed perspective projection into a given matrix
  63411. * @param fov defines the horizontal field of view
  63412. * @param aspect defines the aspect ratio
  63413. * @param znear defines the near clip plane
  63414. * @param zfar defines the far clip plane
  63415. * @param result defines the target matrix
  63416. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63417. */
  63418. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63419. /**
  63420. * Stores a perspective projection for WebVR info a given matrix
  63421. * @param fov defines the field of view
  63422. * @param znear defines the near clip plane
  63423. * @param zfar defines the far clip plane
  63424. * @param result defines the target matrix
  63425. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63426. */
  63427. static PerspectiveFovWebVRToRef(fov: {
  63428. upDegrees: number;
  63429. downDegrees: number;
  63430. leftDegrees: number;
  63431. rightDegrees: number;
  63432. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63433. /**
  63434. * Computes a complete transformation matrix
  63435. * @param viewport defines the viewport to use
  63436. * @param world defines the world matrix
  63437. * @param view defines the view matrix
  63438. * @param projection defines the projection matrix
  63439. * @param zmin defines the near clip plane
  63440. * @param zmax defines the far clip plane
  63441. * @returns the transformation matrix
  63442. */
  63443. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63444. /**
  63445. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63446. * @param matrix defines the matrix to use
  63447. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63448. */
  63449. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63450. /**
  63451. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63452. * @param matrix defines the matrix to use
  63453. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63454. */
  63455. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63456. /**
  63457. * Compute the transpose of a given matrix
  63458. * @param matrix defines the matrix to transpose
  63459. * @returns the new matrix
  63460. */
  63461. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63462. /**
  63463. * Compute the transpose of a matrix and store it in a target matrix
  63464. * @param matrix defines the matrix to transpose
  63465. * @param result defines the target matrix
  63466. */
  63467. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63468. /**
  63469. * Computes a reflection matrix from a plane
  63470. * @param plane defines the reflection plane
  63471. * @returns a new matrix
  63472. */
  63473. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63474. /**
  63475. * Computes a reflection matrix from a plane
  63476. * @param plane defines the reflection plane
  63477. * @param result defines the target matrix
  63478. */
  63479. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63480. /**
  63481. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63482. * @param xaxis defines the value of the 1st axis
  63483. * @param yaxis defines the value of the 2nd axis
  63484. * @param zaxis defines the value of the 3rd axis
  63485. * @param result defines the target matrix
  63486. */
  63487. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63488. /**
  63489. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63490. * @param quat defines the quaternion to use
  63491. * @param result defines the target matrix
  63492. */
  63493. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63494. }
  63495. /**
  63496. * Represens a plane by the equation ax + by + cz + d = 0
  63497. */
  63498. export class Plane {
  63499. /**
  63500. * Normal of the plane (a,b,c)
  63501. */
  63502. normal: Vector3;
  63503. /**
  63504. * d component of the plane
  63505. */
  63506. d: number;
  63507. /**
  63508. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63509. * @param a a component of the plane
  63510. * @param b b component of the plane
  63511. * @param c c component of the plane
  63512. * @param d d component of the plane
  63513. */
  63514. constructor(a: number, b: number, c: number, d: number);
  63515. /**
  63516. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63517. */
  63518. asArray(): number[];
  63519. /**
  63520. * @returns a new plane copied from the current Plane.
  63521. */
  63522. clone(): Plane;
  63523. /**
  63524. * @returns the string "Plane".
  63525. */
  63526. getClassName(): string;
  63527. /**
  63528. * @returns the Plane hash code.
  63529. */
  63530. getHashCode(): number;
  63531. /**
  63532. * Normalize the current Plane in place.
  63533. * @returns the updated Plane.
  63534. */
  63535. normalize(): Plane;
  63536. /**
  63537. * Applies a transformation the plane and returns the result
  63538. * @param transformation the transformation matrix to be applied to the plane
  63539. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63540. */
  63541. transform(transformation: DeepImmutable<Matrix>): Plane;
  63542. /**
  63543. * Calcualtte the dot product between the point and the plane normal
  63544. * @param point point to calculate the dot product with
  63545. * @returns the dot product (float) of the point coordinates and the plane normal.
  63546. */
  63547. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63548. /**
  63549. * Updates the current Plane from the plane defined by the three given points.
  63550. * @param point1 one of the points used to contruct the plane
  63551. * @param point2 one of the points used to contruct the plane
  63552. * @param point3 one of the points used to contruct the plane
  63553. * @returns the updated Plane.
  63554. */
  63555. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63556. /**
  63557. * Checks if the plane is facing a given direction
  63558. * @param direction the direction to check if the plane is facing
  63559. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63560. * @returns True is the vector "direction" is the same side than the plane normal.
  63561. */
  63562. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63563. /**
  63564. * Calculates the distance to a point
  63565. * @param point point to calculate distance to
  63566. * @returns the signed distance (float) from the given point to the Plane.
  63567. */
  63568. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63569. /**
  63570. * Creates a plane from an array
  63571. * @param array the array to create a plane from
  63572. * @returns a new Plane from the given array.
  63573. */
  63574. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63575. /**
  63576. * Creates a plane from three points
  63577. * @param point1 point used to create the plane
  63578. * @param point2 point used to create the plane
  63579. * @param point3 point used to create the plane
  63580. * @returns a new Plane defined by the three given points.
  63581. */
  63582. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63583. /**
  63584. * Creates a plane from an origin point and a normal
  63585. * @param origin origin of the plane to be constructed
  63586. * @param normal normal of the plane to be constructed
  63587. * @returns a new Plane the normal vector to this plane at the given origin point.
  63588. * Note : the vector "normal" is updated because normalized.
  63589. */
  63590. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63591. /**
  63592. * Calculates the distance from a plane and a point
  63593. * @param origin origin of the plane to be constructed
  63594. * @param normal normal of the plane to be constructed
  63595. * @param point point to calculate distance to
  63596. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63597. */
  63598. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63599. }
  63600. /**
  63601. * Class used to represent a viewport on screen
  63602. */
  63603. export class Viewport {
  63604. /** viewport left coordinate */
  63605. x: number;
  63606. /** viewport top coordinate */
  63607. y: number;
  63608. /**viewport width */
  63609. width: number;
  63610. /** viewport height */
  63611. height: number;
  63612. /**
  63613. * Creates a Viewport object located at (x, y) and sized (width, height)
  63614. * @param x defines viewport left coordinate
  63615. * @param y defines viewport top coordinate
  63616. * @param width defines the viewport width
  63617. * @param height defines the viewport height
  63618. */
  63619. constructor(
  63620. /** viewport left coordinate */
  63621. x: number,
  63622. /** viewport top coordinate */
  63623. y: number,
  63624. /**viewport width */
  63625. width: number,
  63626. /** viewport height */
  63627. height: number);
  63628. /**
  63629. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63630. * @param renderWidth defines the rendering width
  63631. * @param renderHeight defines the rendering height
  63632. * @returns a new Viewport
  63633. */
  63634. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63635. /**
  63636. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63637. * @param renderWidth defines the rendering width
  63638. * @param renderHeight defines the rendering height
  63639. * @param ref defines the target viewport
  63640. * @returns the current viewport
  63641. */
  63642. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63643. /**
  63644. * Returns a new Viewport copied from the current one
  63645. * @returns a new Viewport
  63646. */
  63647. clone(): Viewport;
  63648. }
  63649. /**
  63650. * Reprasents a camera frustum
  63651. */
  63652. export class Frustum {
  63653. /**
  63654. * Gets the planes representing the frustum
  63655. * @param transform matrix to be applied to the returned planes
  63656. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63657. */
  63658. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63659. /**
  63660. * Gets the near frustum plane transformed by the transform matrix
  63661. * @param transform transformation matrix to be applied to the resulting frustum plane
  63662. * @param frustumPlane the resuling frustum plane
  63663. */
  63664. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63665. /**
  63666. * Gets the far frustum plane transformed by the transform matrix
  63667. * @param transform transformation matrix to be applied to the resulting frustum plane
  63668. * @param frustumPlane the resuling frustum plane
  63669. */
  63670. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63671. /**
  63672. * Gets the left frustum plane transformed by the transform matrix
  63673. * @param transform transformation matrix to be applied to the resulting frustum plane
  63674. * @param frustumPlane the resuling frustum plane
  63675. */
  63676. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63677. /**
  63678. * Gets the right frustum plane transformed by the transform matrix
  63679. * @param transform transformation matrix to be applied to the resulting frustum plane
  63680. * @param frustumPlane the resuling frustum plane
  63681. */
  63682. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63683. /**
  63684. * Gets the top frustum plane transformed by the transform matrix
  63685. * @param transform transformation matrix to be applied to the resulting frustum plane
  63686. * @param frustumPlane the resuling frustum plane
  63687. */
  63688. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63689. /**
  63690. * Gets the bottom frustum plane transformed by the transform matrix
  63691. * @param transform transformation matrix to be applied to the resulting frustum plane
  63692. * @param frustumPlane the resuling frustum plane
  63693. */
  63694. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63695. /**
  63696. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63697. * @param transform transformation matrix to be applied to the resulting frustum planes
  63698. * @param frustumPlanes the resuling frustum planes
  63699. */
  63700. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63701. }
  63702. /** Defines supported spaces */
  63703. export enum Space {
  63704. /** Local (object) space */
  63705. LOCAL = 0,
  63706. /** World space */
  63707. WORLD = 1,
  63708. /** Bone space */
  63709. BONE = 2
  63710. }
  63711. /** Defines the 3 main axes */
  63712. export class Axis {
  63713. /** X axis */
  63714. static X: Vector3;
  63715. /** Y axis */
  63716. static Y: Vector3;
  63717. /** Z axis */
  63718. static Z: Vector3;
  63719. }
  63720. /** Class used to represent a Bezier curve */
  63721. export class BezierCurve {
  63722. /**
  63723. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63724. * @param t defines the time
  63725. * @param x1 defines the left coordinate on X axis
  63726. * @param y1 defines the left coordinate on Y axis
  63727. * @param x2 defines the right coordinate on X axis
  63728. * @param y2 defines the right coordinate on Y axis
  63729. * @returns the interpolated value
  63730. */
  63731. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63732. }
  63733. /**
  63734. * Defines potential orientation for back face culling
  63735. */
  63736. export enum Orientation {
  63737. /**
  63738. * Clockwise
  63739. */
  63740. CW = 0,
  63741. /** Counter clockwise */
  63742. CCW = 1
  63743. }
  63744. /**
  63745. * Defines angle representation
  63746. */
  63747. export class Angle {
  63748. private _radians;
  63749. /**
  63750. * Creates an Angle object of "radians" radians (float).
  63751. * @param radians the angle in radians
  63752. */
  63753. constructor(radians: number);
  63754. /**
  63755. * Get value in degrees
  63756. * @returns the Angle value in degrees (float)
  63757. */
  63758. degrees(): number;
  63759. /**
  63760. * Get value in radians
  63761. * @returns the Angle value in radians (float)
  63762. */
  63763. radians(): number;
  63764. /**
  63765. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63766. * @param a defines first vector
  63767. * @param b defines second vector
  63768. * @returns a new Angle
  63769. */
  63770. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63771. /**
  63772. * Gets a new Angle object from the given float in radians
  63773. * @param radians defines the angle value in radians
  63774. * @returns a new Angle
  63775. */
  63776. static FromRadians(radians: number): Angle;
  63777. /**
  63778. * Gets a new Angle object from the given float in degrees
  63779. * @param degrees defines the angle value in degrees
  63780. * @returns a new Angle
  63781. */
  63782. static FromDegrees(degrees: number): Angle;
  63783. }
  63784. /**
  63785. * This represents an arc in a 2d space.
  63786. */
  63787. export class Arc2 {
  63788. /** Defines the start point of the arc */
  63789. startPoint: Vector2;
  63790. /** Defines the mid point of the arc */
  63791. midPoint: Vector2;
  63792. /** Defines the end point of the arc */
  63793. endPoint: Vector2;
  63794. /**
  63795. * Defines the center point of the arc.
  63796. */
  63797. centerPoint: Vector2;
  63798. /**
  63799. * Defines the radius of the arc.
  63800. */
  63801. radius: number;
  63802. /**
  63803. * Defines the angle of the arc (from mid point to end point).
  63804. */
  63805. angle: Angle;
  63806. /**
  63807. * Defines the start angle of the arc (from start point to middle point).
  63808. */
  63809. startAngle: Angle;
  63810. /**
  63811. * Defines the orientation of the arc (clock wise/counter clock wise).
  63812. */
  63813. orientation: Orientation;
  63814. /**
  63815. * Creates an Arc object from the three given points : start, middle and end.
  63816. * @param startPoint Defines the start point of the arc
  63817. * @param midPoint Defines the midlle point of the arc
  63818. * @param endPoint Defines the end point of the arc
  63819. */
  63820. constructor(
  63821. /** Defines the start point of the arc */
  63822. startPoint: Vector2,
  63823. /** Defines the mid point of the arc */
  63824. midPoint: Vector2,
  63825. /** Defines the end point of the arc */
  63826. endPoint: Vector2);
  63827. }
  63828. /**
  63829. * Represents a 2D path made up of multiple 2D points
  63830. */
  63831. export class Path2 {
  63832. private _points;
  63833. private _length;
  63834. /**
  63835. * If the path start and end point are the same
  63836. */
  63837. closed: boolean;
  63838. /**
  63839. * Creates a Path2 object from the starting 2D coordinates x and y.
  63840. * @param x the starting points x value
  63841. * @param y the starting points y value
  63842. */
  63843. constructor(x: number, y: number);
  63844. /**
  63845. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63846. * @param x the added points x value
  63847. * @param y the added points y value
  63848. * @returns the updated Path2.
  63849. */
  63850. addLineTo(x: number, y: number): Path2;
  63851. /**
  63852. * 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.
  63853. * @param midX middle point x value
  63854. * @param midY middle point y value
  63855. * @param endX end point x value
  63856. * @param endY end point y value
  63857. * @param numberOfSegments (default: 36)
  63858. * @returns the updated Path2.
  63859. */
  63860. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63861. /**
  63862. * Closes the Path2.
  63863. * @returns the Path2.
  63864. */
  63865. close(): Path2;
  63866. /**
  63867. * Gets the sum of the distance between each sequential point in the path
  63868. * @returns the Path2 total length (float).
  63869. */
  63870. length(): number;
  63871. /**
  63872. * Gets the points which construct the path
  63873. * @returns the Path2 internal array of points.
  63874. */
  63875. getPoints(): Vector2[];
  63876. /**
  63877. * Retreives the point at the distance aways from the starting point
  63878. * @param normalizedLengthPosition the length along the path to retreive the point from
  63879. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63880. */
  63881. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63882. /**
  63883. * Creates a new path starting from an x and y position
  63884. * @param x starting x value
  63885. * @param y starting y value
  63886. * @returns a new Path2 starting at the coordinates (x, y).
  63887. */
  63888. static StartingAt(x: number, y: number): Path2;
  63889. }
  63890. /**
  63891. * Represents a 3D path made up of multiple 3D points
  63892. */
  63893. export class Path3D {
  63894. /**
  63895. * an array of Vector3, the curve axis of the Path3D
  63896. */
  63897. path: Vector3[];
  63898. private _curve;
  63899. private _distances;
  63900. private _tangents;
  63901. private _normals;
  63902. private _binormals;
  63903. private _raw;
  63904. /**
  63905. * new Path3D(path, normal, raw)
  63906. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63907. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63908. * @param path an array of Vector3, the curve axis of the Path3D
  63909. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63910. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63911. */
  63912. constructor(
  63913. /**
  63914. * an array of Vector3, the curve axis of the Path3D
  63915. */
  63916. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63917. /**
  63918. * Returns the Path3D array of successive Vector3 designing its curve.
  63919. * @returns the Path3D array of successive Vector3 designing its curve.
  63920. */
  63921. getCurve(): Vector3[];
  63922. /**
  63923. * Returns an array populated with tangent vectors on each Path3D curve point.
  63924. * @returns an array populated with tangent vectors on each Path3D curve point.
  63925. */
  63926. getTangents(): Vector3[];
  63927. /**
  63928. * Returns an array populated with normal vectors on each Path3D curve point.
  63929. * @returns an array populated with normal vectors on each Path3D curve point.
  63930. */
  63931. getNormals(): Vector3[];
  63932. /**
  63933. * Returns an array populated with binormal vectors on each Path3D curve point.
  63934. * @returns an array populated with binormal vectors on each Path3D curve point.
  63935. */
  63936. getBinormals(): Vector3[];
  63937. /**
  63938. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63939. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63940. */
  63941. getDistances(): number[];
  63942. /**
  63943. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63944. * @param path path which all values are copied into the curves points
  63945. * @param firstNormal which should be projected onto the curve
  63946. * @returns the same object updated.
  63947. */
  63948. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63949. private _compute;
  63950. private _getFirstNonNullVector;
  63951. private _getLastNonNullVector;
  63952. private _normalVector;
  63953. }
  63954. /**
  63955. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63956. * A Curve3 is designed from a series of successive Vector3.
  63957. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63958. */
  63959. export class Curve3 {
  63960. private _points;
  63961. private _length;
  63962. /**
  63963. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63964. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63965. * @param v1 (Vector3) the control point
  63966. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63967. * @param nbPoints (integer) the wanted number of points in the curve
  63968. * @returns the created Curve3
  63969. */
  63970. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63971. /**
  63972. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63973. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63974. * @param v1 (Vector3) the first control point
  63975. * @param v2 (Vector3) the second control point
  63976. * @param v3 (Vector3) the end point of the Cubic Bezier
  63977. * @param nbPoints (integer) the wanted number of points in the curve
  63978. * @returns the created Curve3
  63979. */
  63980. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63981. /**
  63982. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63983. * @param p1 (Vector3) the origin point of the Hermite Spline
  63984. * @param t1 (Vector3) the tangent vector at the origin point
  63985. * @param p2 (Vector3) the end point of the Hermite Spline
  63986. * @param t2 (Vector3) the tangent vector at the end point
  63987. * @param nbPoints (integer) the wanted number of points in the curve
  63988. * @returns the created Curve3
  63989. */
  63990. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63991. /**
  63992. * Returns a Curve3 object along a CatmullRom Spline curve :
  63993. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63994. * @param nbPoints (integer) the wanted number of points between each curve control points
  63995. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63996. * @returns the created Curve3
  63997. */
  63998. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63999. /**
  64000. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  64001. * A Curve3 is designed from a series of successive Vector3.
  64002. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  64003. * @param points points which make up the curve
  64004. */
  64005. constructor(points: Vector3[]);
  64006. /**
  64007. * @returns the Curve3 stored array of successive Vector3
  64008. */
  64009. getPoints(): Vector3[];
  64010. /**
  64011. * @returns the computed length (float) of the curve.
  64012. */
  64013. length(): number;
  64014. /**
  64015. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  64016. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  64017. * curveA and curveB keep unchanged.
  64018. * @param curve the curve to continue from this curve
  64019. * @returns the newly constructed curve
  64020. */
  64021. continue(curve: DeepImmutable<Curve3>): Curve3;
  64022. private _computeLength;
  64023. }
  64024. /**
  64025. * Contains position and normal vectors for a vertex
  64026. */
  64027. export class PositionNormalVertex {
  64028. /** the position of the vertex (defaut: 0,0,0) */
  64029. position: Vector3;
  64030. /** the normal of the vertex (defaut: 0,1,0) */
  64031. normal: Vector3;
  64032. /**
  64033. * Creates a PositionNormalVertex
  64034. * @param position the position of the vertex (defaut: 0,0,0)
  64035. * @param normal the normal of the vertex (defaut: 0,1,0)
  64036. */
  64037. constructor(
  64038. /** the position of the vertex (defaut: 0,0,0) */
  64039. position?: Vector3,
  64040. /** the normal of the vertex (defaut: 0,1,0) */
  64041. normal?: Vector3);
  64042. /**
  64043. * Clones the PositionNormalVertex
  64044. * @returns the cloned PositionNormalVertex
  64045. */
  64046. clone(): PositionNormalVertex;
  64047. }
  64048. /**
  64049. * Contains position, normal and uv vectors for a vertex
  64050. */
  64051. export class PositionNormalTextureVertex {
  64052. /** the position of the vertex (defaut: 0,0,0) */
  64053. position: Vector3;
  64054. /** the normal of the vertex (defaut: 0,1,0) */
  64055. normal: Vector3;
  64056. /** the uv of the vertex (default: 0,0) */
  64057. uv: Vector2;
  64058. /**
  64059. * Creates a PositionNormalTextureVertex
  64060. * @param position the position of the vertex (defaut: 0,0,0)
  64061. * @param normal the normal of the vertex (defaut: 0,1,0)
  64062. * @param uv the uv of the vertex (default: 0,0)
  64063. */
  64064. constructor(
  64065. /** the position of the vertex (defaut: 0,0,0) */
  64066. position?: Vector3,
  64067. /** the normal of the vertex (defaut: 0,1,0) */
  64068. normal?: Vector3,
  64069. /** the uv of the vertex (default: 0,0) */
  64070. uv?: Vector2);
  64071. /**
  64072. * Clones the PositionNormalTextureVertex
  64073. * @returns the cloned PositionNormalTextureVertex
  64074. */
  64075. clone(): PositionNormalTextureVertex;
  64076. }
  64077. /**
  64078. * @hidden
  64079. */
  64080. export class Tmp {
  64081. static Color3: Color3[];
  64082. static Color4: Color4[];
  64083. static Vector2: Vector2[];
  64084. static Vector3: Vector3[];
  64085. static Vector4: Vector4[];
  64086. static Quaternion: Quaternion[];
  64087. static Matrix: Matrix[];
  64088. }
  64089. }
  64090. declare module BABYLON {
  64091. /**
  64092. * Class used to enable access to offline support
  64093. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64094. */
  64095. export interface IOfflineProvider {
  64096. /**
  64097. * Gets a boolean indicating if scene must be saved in the database
  64098. */
  64099. enableSceneOffline: boolean;
  64100. /**
  64101. * Gets a boolean indicating if textures must be saved in the database
  64102. */
  64103. enableTexturesOffline: boolean;
  64104. /**
  64105. * Open the offline support and make it available
  64106. * @param successCallback defines the callback to call on success
  64107. * @param errorCallback defines the callback to call on error
  64108. */
  64109. open(successCallback: () => void, errorCallback: () => void): void;
  64110. /**
  64111. * Loads an image from the offline support
  64112. * @param url defines the url to load from
  64113. * @param image defines the target DOM image
  64114. */
  64115. loadImage(url: string, image: HTMLImageElement): void;
  64116. /**
  64117. * Loads a file from offline support
  64118. * @param url defines the URL to load from
  64119. * @param sceneLoaded defines a callback to call on success
  64120. * @param progressCallBack defines a callback to call when progress changed
  64121. * @param errorCallback defines a callback to call on error
  64122. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64123. */
  64124. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64125. }
  64126. }
  64127. declare module BABYLON {
  64128. /**
  64129. * A class serves as a medium between the observable and its observers
  64130. */
  64131. export class EventState {
  64132. /**
  64133. * Create a new EventState
  64134. * @param mask defines the mask associated with this state
  64135. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64136. * @param target defines the original target of the state
  64137. * @param currentTarget defines the current target of the state
  64138. */
  64139. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64140. /**
  64141. * Initialize the current event state
  64142. * @param mask defines the mask associated with this state
  64143. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64144. * @param target defines the original target of the state
  64145. * @param currentTarget defines the current target of the state
  64146. * @returns the current event state
  64147. */
  64148. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64149. /**
  64150. * An Observer can set this property to true to prevent subsequent observers of being notified
  64151. */
  64152. skipNextObservers: boolean;
  64153. /**
  64154. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64155. */
  64156. mask: number;
  64157. /**
  64158. * The object that originally notified the event
  64159. */
  64160. target?: any;
  64161. /**
  64162. * The current object in the bubbling phase
  64163. */
  64164. currentTarget?: any;
  64165. /**
  64166. * This will be populated with the return value of the last function that was executed.
  64167. * If it is the first function in the callback chain it will be the event data.
  64168. */
  64169. lastReturnValue?: any;
  64170. }
  64171. /**
  64172. * Represent an Observer registered to a given Observable object.
  64173. */
  64174. export class Observer<T> {
  64175. /**
  64176. * Defines the callback to call when the observer is notified
  64177. */
  64178. callback: (eventData: T, eventState: EventState) => void;
  64179. /**
  64180. * Defines the mask of the observer (used to filter notifications)
  64181. */
  64182. mask: number;
  64183. /**
  64184. * Defines the current scope used to restore the JS context
  64185. */
  64186. scope: any;
  64187. /** @hidden */
  64188. _willBeUnregistered: boolean;
  64189. /**
  64190. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64191. */
  64192. unregisterOnNextCall: boolean;
  64193. /**
  64194. * Creates a new observer
  64195. * @param callback defines the callback to call when the observer is notified
  64196. * @param mask defines the mask of the observer (used to filter notifications)
  64197. * @param scope defines the current scope used to restore the JS context
  64198. */
  64199. constructor(
  64200. /**
  64201. * Defines the callback to call when the observer is notified
  64202. */
  64203. callback: (eventData: T, eventState: EventState) => void,
  64204. /**
  64205. * Defines the mask of the observer (used to filter notifications)
  64206. */
  64207. mask: number,
  64208. /**
  64209. * Defines the current scope used to restore the JS context
  64210. */
  64211. scope?: any);
  64212. }
  64213. /**
  64214. * Represent a list of observers registered to multiple Observables object.
  64215. */
  64216. export class MultiObserver<T> {
  64217. private _observers;
  64218. private _observables;
  64219. /**
  64220. * Release associated resources
  64221. */
  64222. dispose(): void;
  64223. /**
  64224. * Raise a callback when one of the observable will notify
  64225. * @param observables defines a list of observables to watch
  64226. * @param callback defines the callback to call on notification
  64227. * @param mask defines the mask used to filter notifications
  64228. * @param scope defines the current scope used to restore the JS context
  64229. * @returns the new MultiObserver
  64230. */
  64231. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64232. }
  64233. /**
  64234. * The Observable class is a simple implementation of the Observable pattern.
  64235. *
  64236. * 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.
  64237. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64238. * 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).
  64239. * 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.
  64240. */
  64241. export class Observable<T> {
  64242. private _observers;
  64243. private _eventState;
  64244. private _onObserverAdded;
  64245. /**
  64246. * Creates a new observable
  64247. * @param onObserverAdded defines a callback to call when a new observer is added
  64248. */
  64249. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64250. /**
  64251. * Create a new Observer with the specified callback
  64252. * @param callback the callback that will be executed for that Observer
  64253. * @param mask the mask used to filter observers
  64254. * @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.
  64255. * @param scope optional scope for the callback to be called from
  64256. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64257. * @returns the new observer created for the callback
  64258. */
  64259. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64260. /**
  64261. * Create a new Observer with the specified callback and unregisters after the next notification
  64262. * @param callback the callback that will be executed for that Observer
  64263. * @returns the new observer created for the callback
  64264. */
  64265. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64266. /**
  64267. * Remove an Observer from the Observable object
  64268. * @param observer the instance of the Observer to remove
  64269. * @returns false if it doesn't belong to this Observable
  64270. */
  64271. remove(observer: Nullable<Observer<T>>): boolean;
  64272. /**
  64273. * Remove a callback from the Observable object
  64274. * @param callback the callback to remove
  64275. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64276. * @returns false if it doesn't belong to this Observable
  64277. */
  64278. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64279. private _deferUnregister;
  64280. private _remove;
  64281. /**
  64282. * Moves the observable to the top of the observer list making it get called first when notified
  64283. * @param observer the observer to move
  64284. */
  64285. makeObserverTopPriority(observer: Observer<T>): void;
  64286. /**
  64287. * Moves the observable to the bottom of the observer list making it get called last when notified
  64288. * @param observer the observer to move
  64289. */
  64290. makeObserverBottomPriority(observer: Observer<T>): void;
  64291. /**
  64292. * Notify all Observers by calling their respective callback with the given data
  64293. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64294. * @param eventData defines the data to send to all observers
  64295. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64296. * @param target defines the original target of the state
  64297. * @param currentTarget defines the current target of the state
  64298. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64299. */
  64300. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64301. /**
  64302. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64303. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64304. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64305. * and it is crucial that all callbacks will be executed.
  64306. * The order of the callbacks is kept, callbacks are not executed parallel.
  64307. *
  64308. * @param eventData The data to be sent to each callback
  64309. * @param mask is used to filter observers defaults to -1
  64310. * @param target defines the callback target (see EventState)
  64311. * @param currentTarget defines he current object in the bubbling phase
  64312. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64313. */
  64314. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64315. /**
  64316. * Notify a specific observer
  64317. * @param observer defines the observer to notify
  64318. * @param eventData defines the data to be sent to each callback
  64319. * @param mask is used to filter observers defaults to -1
  64320. */
  64321. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64322. /**
  64323. * Gets a boolean indicating if the observable has at least one observer
  64324. * @returns true is the Observable has at least one Observer registered
  64325. */
  64326. hasObservers(): boolean;
  64327. /**
  64328. * Clear the list of observers
  64329. */
  64330. clear(): void;
  64331. /**
  64332. * Clone the current observable
  64333. * @returns a new observable
  64334. */
  64335. clone(): Observable<T>;
  64336. /**
  64337. * Does this observable handles observer registered with a given mask
  64338. * @param mask defines the mask to be tested
  64339. * @return whether or not one observer registered with the given mask is handeled
  64340. **/
  64341. hasSpecificMask(mask?: number): boolean;
  64342. }
  64343. }
  64344. declare module BABYLON {
  64345. /**
  64346. * Class used to help managing file picking and drag'n'drop
  64347. * File Storage
  64348. */
  64349. export class FilesInputStore {
  64350. /**
  64351. * List of files ready to be loaded
  64352. */
  64353. static FilesToLoad: {
  64354. [key: string]: File;
  64355. };
  64356. }
  64357. }
  64358. declare module BABYLON {
  64359. /** Defines the cross module used constants to avoid circular dependncies */
  64360. export class Constants {
  64361. /** Defines that alpha blending is disabled */
  64362. static readonly ALPHA_DISABLE: number;
  64363. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64364. static readonly ALPHA_ADD: number;
  64365. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64366. static readonly ALPHA_COMBINE: number;
  64367. /** Defines that alpha blending to DEST - SRC * DEST */
  64368. static readonly ALPHA_SUBTRACT: number;
  64369. /** Defines that alpha blending to SRC * DEST */
  64370. static readonly ALPHA_MULTIPLY: number;
  64371. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64372. static readonly ALPHA_MAXIMIZED: number;
  64373. /** Defines that alpha blending to SRC + DEST */
  64374. static readonly ALPHA_ONEONE: number;
  64375. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64376. static readonly ALPHA_PREMULTIPLIED: number;
  64377. /**
  64378. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64379. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64380. */
  64381. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64382. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64383. static readonly ALPHA_INTERPOLATE: number;
  64384. /**
  64385. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64386. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64387. */
  64388. static readonly ALPHA_SCREENMODE: number;
  64389. /** Defines that the ressource is not delayed*/
  64390. static readonly DELAYLOADSTATE_NONE: number;
  64391. /** Defines that the ressource was successfully delay loaded */
  64392. static readonly DELAYLOADSTATE_LOADED: number;
  64393. /** Defines that the ressource is currently delay loading */
  64394. static readonly DELAYLOADSTATE_LOADING: number;
  64395. /** Defines that the ressource is delayed and has not started loading */
  64396. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64397. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64398. static readonly NEVER: number;
  64399. /** 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 */
  64400. static readonly ALWAYS: number;
  64401. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64402. static readonly LESS: number;
  64403. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64404. static readonly EQUAL: number;
  64405. /** 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 */
  64406. static readonly LEQUAL: number;
  64407. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64408. static readonly GREATER: number;
  64409. /** 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 */
  64410. static readonly GEQUAL: number;
  64411. /** 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 */
  64412. static readonly NOTEQUAL: number;
  64413. /** Passed to stencilOperation to specify that stencil value must be kept */
  64414. static readonly KEEP: number;
  64415. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64416. static readonly REPLACE: number;
  64417. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64418. static readonly INCR: number;
  64419. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64420. static readonly DECR: number;
  64421. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64422. static readonly INVERT: number;
  64423. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64424. static readonly INCR_WRAP: number;
  64425. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64426. static readonly DECR_WRAP: number;
  64427. /** Texture is not repeating outside of 0..1 UVs */
  64428. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64429. /** Texture is repeating outside of 0..1 UVs */
  64430. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64431. /** Texture is repeating and mirrored */
  64432. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64433. /** ALPHA */
  64434. static readonly TEXTUREFORMAT_ALPHA: number;
  64435. /** LUMINANCE */
  64436. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64437. /** LUMINANCE_ALPHA */
  64438. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64439. /** RGB */
  64440. static readonly TEXTUREFORMAT_RGB: number;
  64441. /** RGBA */
  64442. static readonly TEXTUREFORMAT_RGBA: number;
  64443. /** RED */
  64444. static readonly TEXTUREFORMAT_RED: number;
  64445. /** RED (2nd reference) */
  64446. static readonly TEXTUREFORMAT_R: number;
  64447. /** RG */
  64448. static readonly TEXTUREFORMAT_RG: number;
  64449. /** RED_INTEGER */
  64450. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64451. /** RED_INTEGER (2nd reference) */
  64452. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64453. /** RG_INTEGER */
  64454. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64455. /** RGB_INTEGER */
  64456. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64457. /** RGBA_INTEGER */
  64458. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64459. /** UNSIGNED_BYTE */
  64460. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64461. /** UNSIGNED_BYTE (2nd reference) */
  64462. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64463. /** FLOAT */
  64464. static readonly TEXTURETYPE_FLOAT: number;
  64465. /** HALF_FLOAT */
  64466. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64467. /** BYTE */
  64468. static readonly TEXTURETYPE_BYTE: number;
  64469. /** SHORT */
  64470. static readonly TEXTURETYPE_SHORT: number;
  64471. /** UNSIGNED_SHORT */
  64472. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64473. /** INT */
  64474. static readonly TEXTURETYPE_INT: number;
  64475. /** UNSIGNED_INT */
  64476. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64477. /** UNSIGNED_SHORT_4_4_4_4 */
  64478. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64479. /** UNSIGNED_SHORT_5_5_5_1 */
  64480. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64481. /** UNSIGNED_SHORT_5_6_5 */
  64482. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64483. /** UNSIGNED_INT_2_10_10_10_REV */
  64484. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64485. /** UNSIGNED_INT_24_8 */
  64486. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64487. /** UNSIGNED_INT_10F_11F_11F_REV */
  64488. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64489. /** UNSIGNED_INT_5_9_9_9_REV */
  64490. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64491. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64492. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64493. /** nearest is mag = nearest and min = nearest and mip = linear */
  64494. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64495. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64496. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64497. /** Trilinear is mag = linear and min = linear and mip = linear */
  64498. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64499. /** nearest is mag = nearest and min = nearest and mip = linear */
  64500. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64501. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64502. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64503. /** Trilinear is mag = linear and min = linear and mip = linear */
  64504. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64505. /** mag = nearest and min = nearest and mip = nearest */
  64506. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64507. /** mag = nearest and min = linear and mip = nearest */
  64508. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64509. /** mag = nearest and min = linear and mip = linear */
  64510. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64511. /** mag = nearest and min = linear and mip = none */
  64512. static readonly TEXTURE_NEAREST_LINEAR: number;
  64513. /** mag = nearest and min = nearest and mip = none */
  64514. static readonly TEXTURE_NEAREST_NEAREST: number;
  64515. /** mag = linear and min = nearest and mip = nearest */
  64516. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64517. /** mag = linear and min = nearest and mip = linear */
  64518. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64519. /** mag = linear and min = linear and mip = none */
  64520. static readonly TEXTURE_LINEAR_LINEAR: number;
  64521. /** mag = linear and min = nearest and mip = none */
  64522. static readonly TEXTURE_LINEAR_NEAREST: number;
  64523. /** Explicit coordinates mode */
  64524. static readonly TEXTURE_EXPLICIT_MODE: number;
  64525. /** Spherical coordinates mode */
  64526. static readonly TEXTURE_SPHERICAL_MODE: number;
  64527. /** Planar coordinates mode */
  64528. static readonly TEXTURE_PLANAR_MODE: number;
  64529. /** Cubic coordinates mode */
  64530. static readonly TEXTURE_CUBIC_MODE: number;
  64531. /** Projection coordinates mode */
  64532. static readonly TEXTURE_PROJECTION_MODE: number;
  64533. /** Skybox coordinates mode */
  64534. static readonly TEXTURE_SKYBOX_MODE: number;
  64535. /** Inverse Cubic coordinates mode */
  64536. static readonly TEXTURE_INVCUBIC_MODE: number;
  64537. /** Equirectangular coordinates mode */
  64538. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64539. /** Equirectangular Fixed coordinates mode */
  64540. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64541. /** Equirectangular Fixed Mirrored coordinates mode */
  64542. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64543. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64544. static readonly SCALEMODE_FLOOR: number;
  64545. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64546. static readonly SCALEMODE_NEAREST: number;
  64547. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64548. static readonly SCALEMODE_CEILING: number;
  64549. /**
  64550. * The dirty texture flag value
  64551. */
  64552. static readonly MATERIAL_TextureDirtyFlag: number;
  64553. /**
  64554. * The dirty light flag value
  64555. */
  64556. static readonly MATERIAL_LightDirtyFlag: number;
  64557. /**
  64558. * The dirty fresnel flag value
  64559. */
  64560. static readonly MATERIAL_FresnelDirtyFlag: number;
  64561. /**
  64562. * The dirty attribute flag value
  64563. */
  64564. static readonly MATERIAL_AttributesDirtyFlag: number;
  64565. /**
  64566. * The dirty misc flag value
  64567. */
  64568. static readonly MATERIAL_MiscDirtyFlag: number;
  64569. /**
  64570. * The all dirty flag value
  64571. */
  64572. static readonly MATERIAL_AllDirtyFlag: number;
  64573. /**
  64574. * Returns the triangle fill mode
  64575. */
  64576. static readonly MATERIAL_TriangleFillMode: number;
  64577. /**
  64578. * Returns the wireframe mode
  64579. */
  64580. static readonly MATERIAL_WireFrameFillMode: number;
  64581. /**
  64582. * Returns the point fill mode
  64583. */
  64584. static readonly MATERIAL_PointFillMode: number;
  64585. /**
  64586. * Returns the point list draw mode
  64587. */
  64588. static readonly MATERIAL_PointListDrawMode: number;
  64589. /**
  64590. * Returns the line list draw mode
  64591. */
  64592. static readonly MATERIAL_LineListDrawMode: number;
  64593. /**
  64594. * Returns the line loop draw mode
  64595. */
  64596. static readonly MATERIAL_LineLoopDrawMode: number;
  64597. /**
  64598. * Returns the line strip draw mode
  64599. */
  64600. static readonly MATERIAL_LineStripDrawMode: number;
  64601. /**
  64602. * Returns the triangle strip draw mode
  64603. */
  64604. static readonly MATERIAL_TriangleStripDrawMode: number;
  64605. /**
  64606. * Returns the triangle fan draw mode
  64607. */
  64608. static readonly MATERIAL_TriangleFanDrawMode: number;
  64609. /**
  64610. * Stores the clock-wise side orientation
  64611. */
  64612. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64613. /**
  64614. * Stores the counter clock-wise side orientation
  64615. */
  64616. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64617. /**
  64618. * Nothing
  64619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64620. */
  64621. static readonly ACTION_NothingTrigger: number;
  64622. /**
  64623. * On pick
  64624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64625. */
  64626. static readonly ACTION_OnPickTrigger: number;
  64627. /**
  64628. * On left pick
  64629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64630. */
  64631. static readonly ACTION_OnLeftPickTrigger: number;
  64632. /**
  64633. * On right pick
  64634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64635. */
  64636. static readonly ACTION_OnRightPickTrigger: number;
  64637. /**
  64638. * On center pick
  64639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64640. */
  64641. static readonly ACTION_OnCenterPickTrigger: number;
  64642. /**
  64643. * On pick down
  64644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64645. */
  64646. static readonly ACTION_OnPickDownTrigger: number;
  64647. /**
  64648. * On double pick
  64649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64650. */
  64651. static readonly ACTION_OnDoublePickTrigger: number;
  64652. /**
  64653. * On pick up
  64654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64655. */
  64656. static readonly ACTION_OnPickUpTrigger: number;
  64657. /**
  64658. * On pick out.
  64659. * This trigger will only be raised if you also declared a OnPickDown
  64660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64661. */
  64662. static readonly ACTION_OnPickOutTrigger: number;
  64663. /**
  64664. * On long press
  64665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64666. */
  64667. static readonly ACTION_OnLongPressTrigger: number;
  64668. /**
  64669. * On pointer over
  64670. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64671. */
  64672. static readonly ACTION_OnPointerOverTrigger: number;
  64673. /**
  64674. * On pointer out
  64675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64676. */
  64677. static readonly ACTION_OnPointerOutTrigger: number;
  64678. /**
  64679. * On every frame
  64680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64681. */
  64682. static readonly ACTION_OnEveryFrameTrigger: number;
  64683. /**
  64684. * On intersection enter
  64685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64686. */
  64687. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64688. /**
  64689. * On intersection exit
  64690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64691. */
  64692. static readonly ACTION_OnIntersectionExitTrigger: number;
  64693. /**
  64694. * On key down
  64695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64696. */
  64697. static readonly ACTION_OnKeyDownTrigger: number;
  64698. /**
  64699. * On key up
  64700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64701. */
  64702. static readonly ACTION_OnKeyUpTrigger: number;
  64703. /**
  64704. * Billboard mode will only apply to Y axis
  64705. */
  64706. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64707. /**
  64708. * Billboard mode will apply to all axes
  64709. */
  64710. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64711. /**
  64712. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64713. */
  64714. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64715. /**
  64716. * Gets or sets base Assets URL
  64717. */
  64718. static readonly PARTICLES_BaseAssetsUrl: string;
  64719. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64720. * Test order :
  64721. * Is the bounding sphere outside the frustum ?
  64722. * If not, are the bounding box vertices outside the frustum ?
  64723. * It not, then the cullable object is in the frustum.
  64724. */
  64725. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64726. /** Culling strategy : Bounding Sphere Only.
  64727. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64728. * It's also less accurate than the standard because some not visible objects can still be selected.
  64729. * Test : is the bounding sphere outside the frustum ?
  64730. * If not, then the cullable object is in the frustum.
  64731. */
  64732. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64733. /** Culling strategy : Optimistic Inclusion.
  64734. * This in an inclusion test first, then the standard exclusion test.
  64735. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64736. * 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.
  64737. * Anyway, it's as accurate as the standard strategy.
  64738. * Test :
  64739. * Is the cullable object bounding sphere center in the frustum ?
  64740. * If not, apply the default culling strategy.
  64741. */
  64742. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64743. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64744. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64745. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64746. * 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.
  64747. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64748. * Test :
  64749. * Is the cullable object bounding sphere center in the frustum ?
  64750. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64751. */
  64752. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64753. /**
  64754. * No logging while loading
  64755. */
  64756. static readonly SCENELOADER_NO_LOGGING: number;
  64757. /**
  64758. * Minimal logging while loading
  64759. */
  64760. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64761. /**
  64762. * Summary logging while loading
  64763. */
  64764. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64765. /**
  64766. * Detailled logging while loading
  64767. */
  64768. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64769. }
  64770. }
  64771. declare module BABYLON {
  64772. /**
  64773. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64774. * Babylon.js
  64775. */
  64776. export class DomManagement {
  64777. /**
  64778. * Checks if the window object exists
  64779. * @returns true if the window object exists
  64780. */
  64781. static IsWindowObjectExist(): boolean;
  64782. /**
  64783. * Extracts text content from a DOM element hierarchy
  64784. * @param element defines the root element
  64785. * @returns a string
  64786. */
  64787. static GetDOMTextContent(element: HTMLElement): string;
  64788. }
  64789. }
  64790. declare module BABYLON {
  64791. /**
  64792. * Logger used througouht the application to allow configuration of
  64793. * the log level required for the messages.
  64794. */
  64795. export class Logger {
  64796. /**
  64797. * No log
  64798. */
  64799. static readonly NoneLogLevel: number;
  64800. /**
  64801. * Only message logs
  64802. */
  64803. static readonly MessageLogLevel: number;
  64804. /**
  64805. * Only warning logs
  64806. */
  64807. static readonly WarningLogLevel: number;
  64808. /**
  64809. * Only error logs
  64810. */
  64811. static readonly ErrorLogLevel: number;
  64812. /**
  64813. * All logs
  64814. */
  64815. static readonly AllLogLevel: number;
  64816. private static _LogCache;
  64817. /**
  64818. * Gets a value indicating the number of loading errors
  64819. * @ignorenaming
  64820. */
  64821. static errorsCount: number;
  64822. /**
  64823. * Callback called when a new log is added
  64824. */
  64825. static OnNewCacheEntry: (entry: string) => void;
  64826. private static _AddLogEntry;
  64827. private static _FormatMessage;
  64828. private static _LogDisabled;
  64829. private static _LogEnabled;
  64830. private static _WarnDisabled;
  64831. private static _WarnEnabled;
  64832. private static _ErrorDisabled;
  64833. private static _ErrorEnabled;
  64834. /**
  64835. * Log a message to the console
  64836. */
  64837. static Log: (message: string) => void;
  64838. /**
  64839. * Write a warning message to the console
  64840. */
  64841. static Warn: (message: string) => void;
  64842. /**
  64843. * Write an error message to the console
  64844. */
  64845. static Error: (message: string) => void;
  64846. /**
  64847. * Gets current log cache (list of logs)
  64848. */
  64849. static readonly LogCache: string;
  64850. /**
  64851. * Clears the log cache
  64852. */
  64853. static ClearLogCache(): void;
  64854. /**
  64855. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64856. */
  64857. static LogLevels: number;
  64858. }
  64859. }
  64860. declare module BABYLON {
  64861. /** @hidden */
  64862. export class _TypeStore {
  64863. /** @hidden */
  64864. static RegisteredTypes: {
  64865. [key: string]: Object;
  64866. };
  64867. /** @hidden */
  64868. static GetClass(fqdn: string): any;
  64869. }
  64870. }
  64871. declare module BABYLON {
  64872. /**
  64873. * Class containing a set of static utilities functions for deep copy.
  64874. */
  64875. export class DeepCopier {
  64876. /**
  64877. * Tries to copy an object by duplicating every property
  64878. * @param source defines the source object
  64879. * @param destination defines the target object
  64880. * @param doNotCopyList defines a list of properties to avoid
  64881. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64882. */
  64883. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64884. }
  64885. }
  64886. declare module BABYLON {
  64887. /**
  64888. * Class containing a set of static utilities functions for precision date
  64889. */
  64890. export class PrecisionDate {
  64891. /**
  64892. * Gets either window.performance.now() if supported or Date.now() else
  64893. */
  64894. static readonly Now: number;
  64895. }
  64896. }
  64897. declare module BABYLON {
  64898. /** @hidden */
  64899. export class _DevTools {
  64900. static WarnImport(name: string): string;
  64901. }
  64902. }
  64903. declare module BABYLON {
  64904. /**
  64905. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64906. */
  64907. export class WebRequest {
  64908. private _xhr;
  64909. /**
  64910. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64911. * i.e. when loading files, where the server/service expects an Authorization header
  64912. */
  64913. static CustomRequestHeaders: {
  64914. [key: string]: string;
  64915. };
  64916. /**
  64917. * Add callback functions in this array to update all the requests before they get sent to the network
  64918. */
  64919. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64920. private _injectCustomRequestHeaders;
  64921. /**
  64922. * Gets or sets a function to be called when loading progress changes
  64923. */
  64924. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64925. /**
  64926. * Returns client's state
  64927. */
  64928. readonly readyState: number;
  64929. /**
  64930. * Returns client's status
  64931. */
  64932. readonly status: number;
  64933. /**
  64934. * Returns client's status as a text
  64935. */
  64936. readonly statusText: string;
  64937. /**
  64938. * Returns client's response
  64939. */
  64940. readonly response: any;
  64941. /**
  64942. * Returns client's response url
  64943. */
  64944. readonly responseURL: string;
  64945. /**
  64946. * Returns client's response as text
  64947. */
  64948. readonly responseText: string;
  64949. /**
  64950. * Gets or sets the expected response type
  64951. */
  64952. responseType: XMLHttpRequestResponseType;
  64953. /** @hidden */
  64954. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64955. /** @hidden */
  64956. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64957. /**
  64958. * Cancels any network activity
  64959. */
  64960. abort(): void;
  64961. /**
  64962. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64963. * @param body defines an optional request body
  64964. */
  64965. send(body?: Document | BodyInit | null): void;
  64966. /**
  64967. * Sets the request method, request URL
  64968. * @param method defines the method to use (GET, POST, etc..)
  64969. * @param url defines the url to connect with
  64970. */
  64971. open(method: string, url: string): void;
  64972. }
  64973. }
  64974. declare module BABYLON {
  64975. /**
  64976. * Class used to evalaute queries containing `and` and `or` operators
  64977. */
  64978. export class AndOrNotEvaluator {
  64979. /**
  64980. * Evaluate a query
  64981. * @param query defines the query to evaluate
  64982. * @param evaluateCallback defines the callback used to filter result
  64983. * @returns true if the query matches
  64984. */
  64985. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64986. private static _HandleParenthesisContent;
  64987. private static _SimplifyNegation;
  64988. }
  64989. }
  64990. declare module BABYLON {
  64991. /**
  64992. * Class used to store custom tags
  64993. */
  64994. export class Tags {
  64995. /**
  64996. * Adds support for tags on the given object
  64997. * @param obj defines the object to use
  64998. */
  64999. static EnableFor(obj: any): void;
  65000. /**
  65001. * Removes tags support
  65002. * @param obj defines the object to use
  65003. */
  65004. static DisableFor(obj: any): void;
  65005. /**
  65006. * Gets a boolean indicating if the given object has tags
  65007. * @param obj defines the object to use
  65008. * @returns a boolean
  65009. */
  65010. static HasTags(obj: any): boolean;
  65011. /**
  65012. * Gets the tags available on a given object
  65013. * @param obj defines the object to use
  65014. * @param asString defines if the tags must be returned as a string instead of an array of strings
  65015. * @returns the tags
  65016. */
  65017. static GetTags(obj: any, asString?: boolean): any;
  65018. /**
  65019. * Adds tags to an object
  65020. * @param obj defines the object to use
  65021. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  65022. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  65023. */
  65024. static AddTagsTo(obj: any, tagsString: string): void;
  65025. /**
  65026. * @hidden
  65027. */
  65028. static _AddTagTo(obj: any, tag: string): void;
  65029. /**
  65030. * Removes specific tags from a specific object
  65031. * @param obj defines the object to use
  65032. * @param tagsString defines the tags to remove
  65033. */
  65034. static RemoveTagsFrom(obj: any, tagsString: string): void;
  65035. /**
  65036. * @hidden
  65037. */
  65038. static _RemoveTagFrom(obj: any, tag: string): void;
  65039. /**
  65040. * Defines if tags hosted on an object match a given query
  65041. * @param obj defines the object to use
  65042. * @param tagsQuery defines the tag query
  65043. * @returns a boolean
  65044. */
  65045. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  65046. }
  65047. }
  65048. declare module BABYLON {
  65049. /**
  65050. * Manages the defines for the Material
  65051. */
  65052. export class MaterialDefines {
  65053. private _keys;
  65054. private _isDirty;
  65055. /** @hidden */
  65056. _renderId: number;
  65057. /** @hidden */
  65058. _areLightsDirty: boolean;
  65059. /** @hidden */
  65060. _areAttributesDirty: boolean;
  65061. /** @hidden */
  65062. _areTexturesDirty: boolean;
  65063. /** @hidden */
  65064. _areFresnelDirty: boolean;
  65065. /** @hidden */
  65066. _areMiscDirty: boolean;
  65067. /** @hidden */
  65068. _areImageProcessingDirty: boolean;
  65069. /** @hidden */
  65070. _normals: boolean;
  65071. /** @hidden */
  65072. _uvs: boolean;
  65073. /** @hidden */
  65074. _needNormals: boolean;
  65075. /** @hidden */
  65076. _needUVs: boolean;
  65077. /**
  65078. * Specifies if the material needs to be re-calculated
  65079. */
  65080. readonly isDirty: boolean;
  65081. /**
  65082. * Marks the material to indicate that it has been re-calculated
  65083. */
  65084. markAsProcessed(): void;
  65085. /**
  65086. * Marks the material to indicate that it needs to be re-calculated
  65087. */
  65088. markAsUnprocessed(): void;
  65089. /**
  65090. * Marks the material to indicate all of its defines need to be re-calculated
  65091. */
  65092. markAllAsDirty(): void;
  65093. /**
  65094. * Marks the material to indicate that image processing needs to be re-calculated
  65095. */
  65096. markAsImageProcessingDirty(): void;
  65097. /**
  65098. * Marks the material to indicate the lights need to be re-calculated
  65099. */
  65100. markAsLightDirty(): void;
  65101. /**
  65102. * Marks the attribute state as changed
  65103. */
  65104. markAsAttributesDirty(): void;
  65105. /**
  65106. * Marks the texture state as changed
  65107. */
  65108. markAsTexturesDirty(): void;
  65109. /**
  65110. * Marks the fresnel state as changed
  65111. */
  65112. markAsFresnelDirty(): void;
  65113. /**
  65114. * Marks the misc state as changed
  65115. */
  65116. markAsMiscDirty(): void;
  65117. /**
  65118. * Rebuilds the material defines
  65119. */
  65120. rebuild(): void;
  65121. /**
  65122. * Specifies if two material defines are equal
  65123. * @param other - A material define instance to compare to
  65124. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65125. */
  65126. isEqual(other: MaterialDefines): boolean;
  65127. /**
  65128. * Clones this instance's defines to another instance
  65129. * @param other - material defines to clone values to
  65130. */
  65131. cloneTo(other: MaterialDefines): void;
  65132. /**
  65133. * Resets the material define values
  65134. */
  65135. reset(): void;
  65136. /**
  65137. * Converts the material define values to a string
  65138. * @returns - String of material define information
  65139. */
  65140. toString(): string;
  65141. }
  65142. }
  65143. declare module BABYLON {
  65144. /**
  65145. * Class used to store and describe the pipeline context associated with an effect
  65146. */
  65147. export interface IPipelineContext {
  65148. /**
  65149. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  65150. */
  65151. isAsync: boolean;
  65152. /**
  65153. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  65154. */
  65155. isReady: boolean;
  65156. /** @hidden */
  65157. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  65158. }
  65159. }
  65160. declare module BABYLON {
  65161. /**
  65162. * Class used to store gfx data (like WebGLBuffer)
  65163. */
  65164. export class DataBuffer {
  65165. /**
  65166. * Gets or sets the number of objects referencing this buffer
  65167. */
  65168. references: number;
  65169. /** Gets or sets the size of the underlying buffer */
  65170. capacity: number;
  65171. /**
  65172. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65173. */
  65174. is32Bits: boolean;
  65175. /**
  65176. * Gets the underlying buffer
  65177. */
  65178. readonly underlyingResource: any;
  65179. }
  65180. }
  65181. declare module BABYLON {
  65182. /**
  65183. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65184. */
  65185. export class PerformanceMonitor {
  65186. private _enabled;
  65187. private _rollingFrameTime;
  65188. private _lastFrameTimeMs;
  65189. /**
  65190. * constructor
  65191. * @param frameSampleSize The number of samples required to saturate the sliding window
  65192. */
  65193. constructor(frameSampleSize?: number);
  65194. /**
  65195. * Samples current frame
  65196. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65197. */
  65198. sampleFrame(timeMs?: number): void;
  65199. /**
  65200. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65201. */
  65202. readonly averageFrameTime: number;
  65203. /**
  65204. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65205. */
  65206. readonly averageFrameTimeVariance: number;
  65207. /**
  65208. * Returns the frame time of the most recent frame
  65209. */
  65210. readonly instantaneousFrameTime: number;
  65211. /**
  65212. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65213. */
  65214. readonly averageFPS: number;
  65215. /**
  65216. * Returns the average framerate in frames per second using the most recent frame time
  65217. */
  65218. readonly instantaneousFPS: number;
  65219. /**
  65220. * Returns true if enough samples have been taken to completely fill the sliding window
  65221. */
  65222. readonly isSaturated: boolean;
  65223. /**
  65224. * Enables contributions to the sliding window sample set
  65225. */
  65226. enable(): void;
  65227. /**
  65228. * Disables contributions to the sliding window sample set
  65229. * Samples will not be interpolated over the disabled period
  65230. */
  65231. disable(): void;
  65232. /**
  65233. * Returns true if sampling is enabled
  65234. */
  65235. readonly isEnabled: boolean;
  65236. /**
  65237. * Resets performance monitor
  65238. */
  65239. reset(): void;
  65240. }
  65241. /**
  65242. * RollingAverage
  65243. *
  65244. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65245. */
  65246. export class RollingAverage {
  65247. /**
  65248. * Current average
  65249. */
  65250. average: number;
  65251. /**
  65252. * Current variance
  65253. */
  65254. variance: number;
  65255. protected _samples: Array<number>;
  65256. protected _sampleCount: number;
  65257. protected _pos: number;
  65258. protected _m2: number;
  65259. /**
  65260. * constructor
  65261. * @param length The number of samples required to saturate the sliding window
  65262. */
  65263. constructor(length: number);
  65264. /**
  65265. * Adds a sample to the sample set
  65266. * @param v The sample value
  65267. */
  65268. add(v: number): void;
  65269. /**
  65270. * Returns previously added values or null if outside of history or outside the sliding window domain
  65271. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65272. * @return Value previously recorded with add() or null if outside of range
  65273. */
  65274. history(i: number): number;
  65275. /**
  65276. * Returns true if enough samples have been taken to completely fill the sliding window
  65277. * @return true if sample-set saturated
  65278. */
  65279. isSaturated(): boolean;
  65280. /**
  65281. * Resets the rolling average (equivalent to 0 samples taken so far)
  65282. */
  65283. reset(): void;
  65284. /**
  65285. * Wraps a value around the sample range boundaries
  65286. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65287. * @return Wrapped position in sample range
  65288. */
  65289. protected _wrapPosition(i: number): number;
  65290. }
  65291. }
  65292. declare module BABYLON {
  65293. /**
  65294. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65295. * The underlying implementation relies on an associative array to ensure the best performances.
  65296. * The value can be anything including 'null' but except 'undefined'
  65297. */
  65298. export class StringDictionary<T> {
  65299. /**
  65300. * This will clear this dictionary and copy the content from the 'source' one.
  65301. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65302. * @param source the dictionary to take the content from and copy to this dictionary
  65303. */
  65304. copyFrom(source: StringDictionary<T>): void;
  65305. /**
  65306. * Get a value based from its key
  65307. * @param key the given key to get the matching value from
  65308. * @return the value if found, otherwise undefined is returned
  65309. */
  65310. get(key: string): T | undefined;
  65311. /**
  65312. * Get a value from its key or add it if it doesn't exist.
  65313. * This method will ensure you that a given key/data will be present in the dictionary.
  65314. * @param key the given key to get the matching value from
  65315. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65316. * The factory will only be invoked if there's no data for the given key.
  65317. * @return the value corresponding to the key.
  65318. */
  65319. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65320. /**
  65321. * Get a value from its key if present in the dictionary otherwise add it
  65322. * @param key the key to get the value from
  65323. * @param val if there's no such key/value pair in the dictionary add it with this value
  65324. * @return the value corresponding to the key
  65325. */
  65326. getOrAdd(key: string, val: T): T;
  65327. /**
  65328. * Check if there's a given key in the dictionary
  65329. * @param key the key to check for
  65330. * @return true if the key is present, false otherwise
  65331. */
  65332. contains(key: string): boolean;
  65333. /**
  65334. * Add a new key and its corresponding value
  65335. * @param key the key to add
  65336. * @param value the value corresponding to the key
  65337. * @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
  65338. */
  65339. add(key: string, value: T): boolean;
  65340. /**
  65341. * Update a specific value associated to a key
  65342. * @param key defines the key to use
  65343. * @param value defines the value to store
  65344. * @returns true if the value was updated (or false if the key was not found)
  65345. */
  65346. set(key: string, value: T): boolean;
  65347. /**
  65348. * Get the element of the given key and remove it from the dictionary
  65349. * @param key defines the key to search
  65350. * @returns the value associated with the key or null if not found
  65351. */
  65352. getAndRemove(key: string): Nullable<T>;
  65353. /**
  65354. * Remove a key/value from the dictionary.
  65355. * @param key the key to remove
  65356. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65357. */
  65358. remove(key: string): boolean;
  65359. /**
  65360. * Clear the whole content of the dictionary
  65361. */
  65362. clear(): void;
  65363. /**
  65364. * Gets the current count
  65365. */
  65366. readonly count: number;
  65367. /**
  65368. * Execute a callback on each key/val of the dictionary.
  65369. * Note that you can remove any element in this dictionary in the callback implementation
  65370. * @param callback the callback to execute on a given key/value pair
  65371. */
  65372. forEach(callback: (key: string, val: T) => void): void;
  65373. /**
  65374. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65375. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65376. * Note that you can remove any element in this dictionary in the callback implementation
  65377. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65378. * @returns the first item
  65379. */
  65380. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65381. private _count;
  65382. private _data;
  65383. }
  65384. }
  65385. declare module BABYLON {
  65386. /**
  65387. * Helper class that provides a small promise polyfill
  65388. */
  65389. export class PromisePolyfill {
  65390. /**
  65391. * Static function used to check if the polyfill is required
  65392. * If this is the case then the function will inject the polyfill to window.Promise
  65393. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65394. */
  65395. static Apply(force?: boolean): void;
  65396. }
  65397. }
  65398. declare module BABYLON {
  65399. /**
  65400. * Class used to store data that will be store in GPU memory
  65401. */
  65402. export class Buffer {
  65403. private _engine;
  65404. private _buffer;
  65405. /** @hidden */
  65406. _data: Nullable<DataArray>;
  65407. private _updatable;
  65408. private _instanced;
  65409. /**
  65410. * Gets the byte stride.
  65411. */
  65412. readonly byteStride: number;
  65413. /**
  65414. * Constructor
  65415. * @param engine the engine
  65416. * @param data the data to use for this buffer
  65417. * @param updatable whether the data is updatable
  65418. * @param stride the stride (optional)
  65419. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65420. * @param instanced whether the buffer is instanced (optional)
  65421. * @param useBytes set to true if the stride in in bytes (optional)
  65422. */
  65423. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65424. /**
  65425. * Create a new VertexBuffer based on the current buffer
  65426. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65427. * @param offset defines offset in the buffer (0 by default)
  65428. * @param size defines the size in floats of attributes (position is 3 for instance)
  65429. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65430. * @param instanced defines if the vertex buffer contains indexed data
  65431. * @param useBytes defines if the offset and stride are in bytes
  65432. * @returns the new vertex buffer
  65433. */
  65434. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65435. /**
  65436. * Gets a boolean indicating if the Buffer is updatable?
  65437. * @returns true if the buffer is updatable
  65438. */
  65439. isUpdatable(): boolean;
  65440. /**
  65441. * Gets current buffer's data
  65442. * @returns a DataArray or null
  65443. */
  65444. getData(): Nullable<DataArray>;
  65445. /**
  65446. * Gets underlying native buffer
  65447. * @returns underlying native buffer
  65448. */
  65449. getBuffer(): Nullable<DataBuffer>;
  65450. /**
  65451. * Gets the stride in float32 units (i.e. byte stride / 4).
  65452. * May not be an integer if the byte stride is not divisible by 4.
  65453. * DEPRECATED. Use byteStride instead.
  65454. * @returns the stride in float32 units
  65455. */
  65456. getStrideSize(): number;
  65457. /**
  65458. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65459. * @param data defines the data to store
  65460. */
  65461. create(data?: Nullable<DataArray>): void;
  65462. /** @hidden */
  65463. _rebuild(): void;
  65464. /**
  65465. * Update current buffer data
  65466. * @param data defines the data to store
  65467. */
  65468. update(data: DataArray): void;
  65469. /**
  65470. * Updates the data directly.
  65471. * @param data the new data
  65472. * @param offset the new offset
  65473. * @param vertexCount the vertex count (optional)
  65474. * @param useBytes set to true if the offset is in bytes
  65475. */
  65476. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65477. /**
  65478. * Release all resources
  65479. */
  65480. dispose(): void;
  65481. }
  65482. /**
  65483. * Specialized buffer used to store vertex data
  65484. */
  65485. export class VertexBuffer {
  65486. /** @hidden */
  65487. _buffer: Buffer;
  65488. private _kind;
  65489. private _size;
  65490. private _ownsBuffer;
  65491. private _instanced;
  65492. private _instanceDivisor;
  65493. /**
  65494. * The byte type.
  65495. */
  65496. static readonly BYTE: number;
  65497. /**
  65498. * The unsigned byte type.
  65499. */
  65500. static readonly UNSIGNED_BYTE: number;
  65501. /**
  65502. * The short type.
  65503. */
  65504. static readonly SHORT: number;
  65505. /**
  65506. * The unsigned short type.
  65507. */
  65508. static readonly UNSIGNED_SHORT: number;
  65509. /**
  65510. * The integer type.
  65511. */
  65512. static readonly INT: number;
  65513. /**
  65514. * The unsigned integer type.
  65515. */
  65516. static readonly UNSIGNED_INT: number;
  65517. /**
  65518. * The float type.
  65519. */
  65520. static readonly FLOAT: number;
  65521. /**
  65522. * Gets or sets the instance divisor when in instanced mode
  65523. */
  65524. instanceDivisor: number;
  65525. /**
  65526. * Gets the byte stride.
  65527. */
  65528. readonly byteStride: number;
  65529. /**
  65530. * Gets the byte offset.
  65531. */
  65532. readonly byteOffset: number;
  65533. /**
  65534. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65535. */
  65536. readonly normalized: boolean;
  65537. /**
  65538. * Gets the data type of each component in the array.
  65539. */
  65540. readonly type: number;
  65541. /**
  65542. * Constructor
  65543. * @param engine the engine
  65544. * @param data the data to use for this vertex buffer
  65545. * @param kind the vertex buffer kind
  65546. * @param updatable whether the data is updatable
  65547. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65548. * @param stride the stride (optional)
  65549. * @param instanced whether the buffer is instanced (optional)
  65550. * @param offset the offset of the data (optional)
  65551. * @param size the number of components (optional)
  65552. * @param type the type of the component (optional)
  65553. * @param normalized whether the data contains normalized data (optional)
  65554. * @param useBytes set to true if stride and offset are in bytes (optional)
  65555. */
  65556. 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);
  65557. /** @hidden */
  65558. _rebuild(): void;
  65559. /**
  65560. * Returns the kind of the VertexBuffer (string)
  65561. * @returns a string
  65562. */
  65563. getKind(): string;
  65564. /**
  65565. * Gets a boolean indicating if the VertexBuffer is updatable?
  65566. * @returns true if the buffer is updatable
  65567. */
  65568. isUpdatable(): boolean;
  65569. /**
  65570. * Gets current buffer's data
  65571. * @returns a DataArray or null
  65572. */
  65573. getData(): Nullable<DataArray>;
  65574. /**
  65575. * Gets underlying native buffer
  65576. * @returns underlying native buffer
  65577. */
  65578. getBuffer(): Nullable<DataBuffer>;
  65579. /**
  65580. * Gets the stride in float32 units (i.e. byte stride / 4).
  65581. * May not be an integer if the byte stride is not divisible by 4.
  65582. * DEPRECATED. Use byteStride instead.
  65583. * @returns the stride in float32 units
  65584. */
  65585. getStrideSize(): number;
  65586. /**
  65587. * Returns the offset as a multiple of the type byte length.
  65588. * DEPRECATED. Use byteOffset instead.
  65589. * @returns the offset in bytes
  65590. */
  65591. getOffset(): number;
  65592. /**
  65593. * Returns the number of components per vertex attribute (integer)
  65594. * @returns the size in float
  65595. */
  65596. getSize(): number;
  65597. /**
  65598. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65599. * @returns true if this buffer is instanced
  65600. */
  65601. getIsInstanced(): boolean;
  65602. /**
  65603. * Returns the instancing divisor, zero for non-instanced (integer).
  65604. * @returns a number
  65605. */
  65606. getInstanceDivisor(): number;
  65607. /**
  65608. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65609. * @param data defines the data to store
  65610. */
  65611. create(data?: DataArray): void;
  65612. /**
  65613. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65614. * This function will create a new buffer if the current one is not updatable
  65615. * @param data defines the data to store
  65616. */
  65617. update(data: DataArray): void;
  65618. /**
  65619. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65620. * Returns the directly updated WebGLBuffer.
  65621. * @param data the new data
  65622. * @param offset the new offset
  65623. * @param useBytes set to true if the offset is in bytes
  65624. */
  65625. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65626. /**
  65627. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65628. */
  65629. dispose(): void;
  65630. /**
  65631. * Enumerates each value of this vertex buffer as numbers.
  65632. * @param count the number of values to enumerate
  65633. * @param callback the callback function called for each value
  65634. */
  65635. forEach(count: number, callback: (value: number, index: number) => void): void;
  65636. /**
  65637. * Positions
  65638. */
  65639. static readonly PositionKind: string;
  65640. /**
  65641. * Normals
  65642. */
  65643. static readonly NormalKind: string;
  65644. /**
  65645. * Tangents
  65646. */
  65647. static readonly TangentKind: string;
  65648. /**
  65649. * Texture coordinates
  65650. */
  65651. static readonly UVKind: string;
  65652. /**
  65653. * Texture coordinates 2
  65654. */
  65655. static readonly UV2Kind: string;
  65656. /**
  65657. * Texture coordinates 3
  65658. */
  65659. static readonly UV3Kind: string;
  65660. /**
  65661. * Texture coordinates 4
  65662. */
  65663. static readonly UV4Kind: string;
  65664. /**
  65665. * Texture coordinates 5
  65666. */
  65667. static readonly UV5Kind: string;
  65668. /**
  65669. * Texture coordinates 6
  65670. */
  65671. static readonly UV6Kind: string;
  65672. /**
  65673. * Colors
  65674. */
  65675. static readonly ColorKind: string;
  65676. /**
  65677. * Matrix indices (for bones)
  65678. */
  65679. static readonly MatricesIndicesKind: string;
  65680. /**
  65681. * Matrix weights (for bones)
  65682. */
  65683. static readonly MatricesWeightsKind: string;
  65684. /**
  65685. * Additional matrix indices (for bones)
  65686. */
  65687. static readonly MatricesIndicesExtraKind: string;
  65688. /**
  65689. * Additional matrix weights (for bones)
  65690. */
  65691. static readonly MatricesWeightsExtraKind: string;
  65692. /**
  65693. * Deduces the stride given a kind.
  65694. * @param kind The kind string to deduce
  65695. * @returns The deduced stride
  65696. */
  65697. static DeduceStride(kind: string): number;
  65698. /**
  65699. * Gets the byte length of the given type.
  65700. * @param type the type
  65701. * @returns the number of bytes
  65702. */
  65703. static GetTypeByteLength(type: number): number;
  65704. /**
  65705. * Enumerates each value of the given parameters as numbers.
  65706. * @param data the data to enumerate
  65707. * @param byteOffset the byte offset of the data
  65708. * @param byteStride the byte stride of the data
  65709. * @param componentCount the number of components per element
  65710. * @param componentType the type of the component
  65711. * @param count the total number of components
  65712. * @param normalized whether the data is normalized
  65713. * @param callback the callback function called for each value
  65714. */
  65715. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65716. private static _GetFloatValue;
  65717. }
  65718. }
  65719. declare module BABYLON {
  65720. /**
  65721. * Class representing spherical harmonics coefficients to the 3rd degree
  65722. */
  65723. export class SphericalHarmonics {
  65724. /**
  65725. * Defines whether or not the harmonics have been prescaled for rendering.
  65726. */
  65727. preScaled: boolean;
  65728. /**
  65729. * The l0,0 coefficients of the spherical harmonics
  65730. */
  65731. l00: Vector3;
  65732. /**
  65733. * The l1,-1 coefficients of the spherical harmonics
  65734. */
  65735. l1_1: Vector3;
  65736. /**
  65737. * The l1,0 coefficients of the spherical harmonics
  65738. */
  65739. l10: Vector3;
  65740. /**
  65741. * The l1,1 coefficients of the spherical harmonics
  65742. */
  65743. l11: Vector3;
  65744. /**
  65745. * The l2,-2 coefficients of the spherical harmonics
  65746. */
  65747. l2_2: Vector3;
  65748. /**
  65749. * The l2,-1 coefficients of the spherical harmonics
  65750. */
  65751. l2_1: Vector3;
  65752. /**
  65753. * The l2,0 coefficients of the spherical harmonics
  65754. */
  65755. l20: Vector3;
  65756. /**
  65757. * The l2,1 coefficients of the spherical harmonics
  65758. */
  65759. l21: Vector3;
  65760. /**
  65761. * The l2,2 coefficients of the spherical harmonics
  65762. */
  65763. l22: Vector3;
  65764. /**
  65765. * Adds a light to the spherical harmonics
  65766. * @param direction the direction of the light
  65767. * @param color the color of the light
  65768. * @param deltaSolidAngle the delta solid angle of the light
  65769. */
  65770. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65771. /**
  65772. * Scales the spherical harmonics by the given amount
  65773. * @param scale the amount to scale
  65774. */
  65775. scaleInPlace(scale: number): void;
  65776. /**
  65777. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65778. *
  65779. * ```
  65780. * E_lm = A_l * L_lm
  65781. * ```
  65782. *
  65783. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65784. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65785. * the scaling factors are given in equation 9.
  65786. */
  65787. convertIncidentRadianceToIrradiance(): void;
  65788. /**
  65789. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65790. *
  65791. * ```
  65792. * L = (1/pi) * E * rho
  65793. * ```
  65794. *
  65795. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65796. */
  65797. convertIrradianceToLambertianRadiance(): void;
  65798. /**
  65799. * Integrates the reconstruction coefficients directly in to the SH preventing further
  65800. * required operations at run time.
  65801. *
  65802. * This is simply done by scaling back the SH with Ylm constants parameter.
  65803. * The trigonometric part being applied by the shader at run time.
  65804. */
  65805. preScaleForRendering(): void;
  65806. /**
  65807. * Constructs a spherical harmonics from an array.
  65808. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65809. * @returns the spherical harmonics
  65810. */
  65811. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65812. /**
  65813. * Gets the spherical harmonics from polynomial
  65814. * @param polynomial the spherical polynomial
  65815. * @returns the spherical harmonics
  65816. */
  65817. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65818. }
  65819. /**
  65820. * Class representing spherical polynomial coefficients to the 3rd degree
  65821. */
  65822. export class SphericalPolynomial {
  65823. private _harmonics;
  65824. /**
  65825. * The spherical harmonics used to create the polynomials.
  65826. */
  65827. readonly preScaledHarmonics: SphericalHarmonics;
  65828. /**
  65829. * The x coefficients of the spherical polynomial
  65830. */
  65831. x: Vector3;
  65832. /**
  65833. * The y coefficients of the spherical polynomial
  65834. */
  65835. y: Vector3;
  65836. /**
  65837. * The z coefficients of the spherical polynomial
  65838. */
  65839. z: Vector3;
  65840. /**
  65841. * The xx coefficients of the spherical polynomial
  65842. */
  65843. xx: Vector3;
  65844. /**
  65845. * The yy coefficients of the spherical polynomial
  65846. */
  65847. yy: Vector3;
  65848. /**
  65849. * The zz coefficients of the spherical polynomial
  65850. */
  65851. zz: Vector3;
  65852. /**
  65853. * The xy coefficients of the spherical polynomial
  65854. */
  65855. xy: Vector3;
  65856. /**
  65857. * The yz coefficients of the spherical polynomial
  65858. */
  65859. yz: Vector3;
  65860. /**
  65861. * The zx coefficients of the spherical polynomial
  65862. */
  65863. zx: Vector3;
  65864. /**
  65865. * Adds an ambient color to the spherical polynomial
  65866. * @param color the color to add
  65867. */
  65868. addAmbient(color: Color3): void;
  65869. /**
  65870. * Scales the spherical polynomial by the given amount
  65871. * @param scale the amount to scale
  65872. */
  65873. scaleInPlace(scale: number): void;
  65874. /**
  65875. * Gets the spherical polynomial from harmonics
  65876. * @param harmonics the spherical harmonics
  65877. * @returns the spherical polynomial
  65878. */
  65879. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65880. /**
  65881. * Constructs a spherical polynomial from an array.
  65882. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65883. * @returns the spherical polynomial
  65884. */
  65885. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65886. }
  65887. }
  65888. declare module BABYLON {
  65889. /**
  65890. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65891. */
  65892. export interface CubeMapInfo {
  65893. /**
  65894. * The pixel array for the front face.
  65895. * This is stored in format, left to right, up to down format.
  65896. */
  65897. front: Nullable<ArrayBufferView>;
  65898. /**
  65899. * The pixel array for the back face.
  65900. * This is stored in format, left to right, up to down format.
  65901. */
  65902. back: Nullable<ArrayBufferView>;
  65903. /**
  65904. * The pixel array for the left face.
  65905. * This is stored in format, left to right, up to down format.
  65906. */
  65907. left: Nullable<ArrayBufferView>;
  65908. /**
  65909. * The pixel array for the right face.
  65910. * This is stored in format, left to right, up to down format.
  65911. */
  65912. right: Nullable<ArrayBufferView>;
  65913. /**
  65914. * The pixel array for the up face.
  65915. * This is stored in format, left to right, up to down format.
  65916. */
  65917. up: Nullable<ArrayBufferView>;
  65918. /**
  65919. * The pixel array for the down face.
  65920. * This is stored in format, left to right, up to down format.
  65921. */
  65922. down: Nullable<ArrayBufferView>;
  65923. /**
  65924. * The size of the cubemap stored.
  65925. *
  65926. * Each faces will be size * size pixels.
  65927. */
  65928. size: number;
  65929. /**
  65930. * The format of the texture.
  65931. *
  65932. * RGBA, RGB.
  65933. */
  65934. format: number;
  65935. /**
  65936. * The type of the texture data.
  65937. *
  65938. * UNSIGNED_INT, FLOAT.
  65939. */
  65940. type: number;
  65941. /**
  65942. * Specifies whether the texture is in gamma space.
  65943. */
  65944. gammaSpace: boolean;
  65945. }
  65946. /**
  65947. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65948. */
  65949. export class PanoramaToCubeMapTools {
  65950. private static FACE_FRONT;
  65951. private static FACE_BACK;
  65952. private static FACE_RIGHT;
  65953. private static FACE_LEFT;
  65954. private static FACE_DOWN;
  65955. private static FACE_UP;
  65956. /**
  65957. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65958. *
  65959. * @param float32Array The source data.
  65960. * @param inputWidth The width of the input panorama.
  65961. * @param inputHeight The height of the input panorama.
  65962. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65963. * @return The cubemap data
  65964. */
  65965. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65966. private static CreateCubemapTexture;
  65967. private static CalcProjectionSpherical;
  65968. }
  65969. }
  65970. declare module BABYLON {
  65971. /**
  65972. * Helper class dealing with the extraction of spherical polynomial dataArray
  65973. * from a cube map.
  65974. */
  65975. export class CubeMapToSphericalPolynomialTools {
  65976. private static FileFaces;
  65977. /**
  65978. * Converts a texture to the according Spherical Polynomial data.
  65979. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65980. *
  65981. * @param texture The texture to extract the information from.
  65982. * @return The Spherical Polynomial data.
  65983. */
  65984. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65985. /**
  65986. * Converts a cubemap to the according Spherical Polynomial data.
  65987. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65988. *
  65989. * @param cubeInfo The Cube map to extract the information from.
  65990. * @return The Spherical Polynomial data.
  65991. */
  65992. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65993. }
  65994. }
  65995. declare module BABYLON {
  65996. /**
  65997. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65998. * during the life time of the application.
  65999. */
  66000. export class EngineStore {
  66001. /** Gets the list of created engines */
  66002. static Instances: Engine[];
  66003. /**
  66004. * Gets the latest created engine
  66005. */
  66006. static readonly LastCreatedEngine: Nullable<Engine>;
  66007. /**
  66008. * Gets the latest created scene
  66009. */
  66010. static readonly LastCreatedScene: Nullable<Scene>;
  66011. }
  66012. }
  66013. declare module BABYLON {
  66014. /**
  66015. * Define options used to create a render target texture
  66016. */
  66017. export class RenderTargetCreationOptions {
  66018. /**
  66019. * Specifies is mipmaps must be generated
  66020. */
  66021. generateMipMaps?: boolean;
  66022. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  66023. generateDepthBuffer?: boolean;
  66024. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  66025. generateStencilBuffer?: boolean;
  66026. /** Defines texture type (int by default) */
  66027. type?: number;
  66028. /** Defines sampling mode (trilinear by default) */
  66029. samplingMode?: number;
  66030. /** Defines format (RGBA by default) */
  66031. format?: number;
  66032. }
  66033. }
  66034. declare module BABYLON {
  66035. /**
  66036. * @hidden
  66037. **/
  66038. export class _AlphaState {
  66039. private _isAlphaBlendDirty;
  66040. private _isBlendFunctionParametersDirty;
  66041. private _isBlendEquationParametersDirty;
  66042. private _isBlendConstantsDirty;
  66043. private _alphaBlend;
  66044. private _blendFunctionParameters;
  66045. private _blendEquationParameters;
  66046. private _blendConstants;
  66047. /**
  66048. * Initializes the state.
  66049. */
  66050. constructor();
  66051. readonly isDirty: boolean;
  66052. alphaBlend: boolean;
  66053. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  66054. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  66055. setAlphaEquationParameters(rgb: number, alpha: number): void;
  66056. reset(): void;
  66057. apply(gl: WebGLRenderingContext): void;
  66058. }
  66059. }
  66060. declare module BABYLON {
  66061. /**
  66062. * @hidden
  66063. **/
  66064. export class _DepthCullingState {
  66065. private _isDepthTestDirty;
  66066. private _isDepthMaskDirty;
  66067. private _isDepthFuncDirty;
  66068. private _isCullFaceDirty;
  66069. private _isCullDirty;
  66070. private _isZOffsetDirty;
  66071. private _isFrontFaceDirty;
  66072. private _depthTest;
  66073. private _depthMask;
  66074. private _depthFunc;
  66075. private _cull;
  66076. private _cullFace;
  66077. private _zOffset;
  66078. private _frontFace;
  66079. /**
  66080. * Initializes the state.
  66081. */
  66082. constructor();
  66083. readonly isDirty: boolean;
  66084. zOffset: number;
  66085. cullFace: Nullable<number>;
  66086. cull: Nullable<boolean>;
  66087. depthFunc: Nullable<number>;
  66088. depthMask: boolean;
  66089. depthTest: boolean;
  66090. frontFace: Nullable<number>;
  66091. reset(): void;
  66092. apply(gl: WebGLRenderingContext): void;
  66093. }
  66094. }
  66095. declare module BABYLON {
  66096. /**
  66097. * @hidden
  66098. **/
  66099. export class _StencilState {
  66100. /** 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 */
  66101. static readonly ALWAYS: number;
  66102. /** Passed to stencilOperation to specify that stencil value must be kept */
  66103. static readonly KEEP: number;
  66104. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66105. static readonly REPLACE: number;
  66106. private _isStencilTestDirty;
  66107. private _isStencilMaskDirty;
  66108. private _isStencilFuncDirty;
  66109. private _isStencilOpDirty;
  66110. private _stencilTest;
  66111. private _stencilMask;
  66112. private _stencilFunc;
  66113. private _stencilFuncRef;
  66114. private _stencilFuncMask;
  66115. private _stencilOpStencilFail;
  66116. private _stencilOpDepthFail;
  66117. private _stencilOpStencilDepthPass;
  66118. readonly isDirty: boolean;
  66119. stencilFunc: number;
  66120. stencilFuncRef: number;
  66121. stencilFuncMask: number;
  66122. stencilOpStencilFail: number;
  66123. stencilOpDepthFail: number;
  66124. stencilOpStencilDepthPass: number;
  66125. stencilMask: number;
  66126. stencilTest: boolean;
  66127. constructor();
  66128. reset(): void;
  66129. apply(gl: WebGLRenderingContext): void;
  66130. }
  66131. }
  66132. declare module BABYLON {
  66133. /**
  66134. * @hidden
  66135. **/
  66136. export class _TimeToken {
  66137. _startTimeQuery: Nullable<WebGLQuery>;
  66138. _endTimeQuery: Nullable<WebGLQuery>;
  66139. _timeElapsedQuery: Nullable<WebGLQuery>;
  66140. _timeElapsedQueryEnded: boolean;
  66141. }
  66142. }
  66143. declare module BABYLON {
  66144. /**
  66145. * Class used to store data associated with WebGL texture data for the engine
  66146. * This class should not be used directly
  66147. */
  66148. export class InternalTexture {
  66149. /** hidden */
  66150. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  66151. /**
  66152. * The source of the texture data is unknown
  66153. */
  66154. static DATASOURCE_UNKNOWN: number;
  66155. /**
  66156. * Texture data comes from an URL
  66157. */
  66158. static DATASOURCE_URL: number;
  66159. /**
  66160. * Texture data is only used for temporary storage
  66161. */
  66162. static DATASOURCE_TEMP: number;
  66163. /**
  66164. * Texture data comes from raw data (ArrayBuffer)
  66165. */
  66166. static DATASOURCE_RAW: number;
  66167. /**
  66168. * Texture content is dynamic (video or dynamic texture)
  66169. */
  66170. static DATASOURCE_DYNAMIC: number;
  66171. /**
  66172. * Texture content is generated by rendering to it
  66173. */
  66174. static DATASOURCE_RENDERTARGET: number;
  66175. /**
  66176. * Texture content is part of a multi render target process
  66177. */
  66178. static DATASOURCE_MULTIRENDERTARGET: number;
  66179. /**
  66180. * Texture data comes from a cube data file
  66181. */
  66182. static DATASOURCE_CUBE: number;
  66183. /**
  66184. * Texture data comes from a raw cube data
  66185. */
  66186. static DATASOURCE_CUBERAW: number;
  66187. /**
  66188. * Texture data come from a prefiltered cube data file
  66189. */
  66190. static DATASOURCE_CUBEPREFILTERED: number;
  66191. /**
  66192. * Texture content is raw 3D data
  66193. */
  66194. static DATASOURCE_RAW3D: number;
  66195. /**
  66196. * Texture content is a depth texture
  66197. */
  66198. static DATASOURCE_DEPTHTEXTURE: number;
  66199. /**
  66200. * Texture data comes from a raw cube data encoded with RGBD
  66201. */
  66202. static DATASOURCE_CUBERAW_RGBD: number;
  66203. /**
  66204. * Defines if the texture is ready
  66205. */
  66206. isReady: boolean;
  66207. /**
  66208. * Defines if the texture is a cube texture
  66209. */
  66210. isCube: boolean;
  66211. /**
  66212. * Defines if the texture contains 3D data
  66213. */
  66214. is3D: boolean;
  66215. /**
  66216. * Defines if the texture contains multiview data
  66217. */
  66218. isMultiview: boolean;
  66219. /**
  66220. * Gets the URL used to load this texture
  66221. */
  66222. url: string;
  66223. /**
  66224. * Gets the sampling mode of the texture
  66225. */
  66226. samplingMode: number;
  66227. /**
  66228. * Gets a boolean indicating if the texture needs mipmaps generation
  66229. */
  66230. generateMipMaps: boolean;
  66231. /**
  66232. * Gets the number of samples used by the texture (WebGL2+ only)
  66233. */
  66234. samples: number;
  66235. /**
  66236. * Gets the type of the texture (int, float...)
  66237. */
  66238. type: number;
  66239. /**
  66240. * Gets the format of the texture (RGB, RGBA...)
  66241. */
  66242. format: number;
  66243. /**
  66244. * Observable called when the texture is loaded
  66245. */
  66246. onLoadedObservable: Observable<InternalTexture>;
  66247. /**
  66248. * Gets the width of the texture
  66249. */
  66250. width: number;
  66251. /**
  66252. * Gets the height of the texture
  66253. */
  66254. height: number;
  66255. /**
  66256. * Gets the depth of the texture
  66257. */
  66258. depth: number;
  66259. /**
  66260. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  66261. */
  66262. baseWidth: number;
  66263. /**
  66264. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  66265. */
  66266. baseHeight: number;
  66267. /**
  66268. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  66269. */
  66270. baseDepth: number;
  66271. /**
  66272. * Gets a boolean indicating if the texture is inverted on Y axis
  66273. */
  66274. invertY: boolean;
  66275. /** @hidden */
  66276. _invertVScale: boolean;
  66277. /** @hidden */
  66278. _associatedChannel: number;
  66279. /** @hidden */
  66280. _dataSource: number;
  66281. /** @hidden */
  66282. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  66283. /** @hidden */
  66284. _bufferView: Nullable<ArrayBufferView>;
  66285. /** @hidden */
  66286. _bufferViewArray: Nullable<ArrayBufferView[]>;
  66287. /** @hidden */
  66288. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  66289. /** @hidden */
  66290. _size: number;
  66291. /** @hidden */
  66292. _extension: string;
  66293. /** @hidden */
  66294. _files: Nullable<string[]>;
  66295. /** @hidden */
  66296. _workingCanvas: Nullable<HTMLCanvasElement>;
  66297. /** @hidden */
  66298. _workingContext: Nullable<CanvasRenderingContext2D>;
  66299. /** @hidden */
  66300. _framebuffer: Nullable<WebGLFramebuffer>;
  66301. /** @hidden */
  66302. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  66303. /** @hidden */
  66304. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  66305. /** @hidden */
  66306. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  66307. /** @hidden */
  66308. _attachments: Nullable<number[]>;
  66309. /** @hidden */
  66310. _cachedCoordinatesMode: Nullable<number>;
  66311. /** @hidden */
  66312. _cachedWrapU: Nullable<number>;
  66313. /** @hidden */
  66314. _cachedWrapV: Nullable<number>;
  66315. /** @hidden */
  66316. _cachedWrapR: Nullable<number>;
  66317. /** @hidden */
  66318. _cachedAnisotropicFilteringLevel: Nullable<number>;
  66319. /** @hidden */
  66320. _isDisabled: boolean;
  66321. /** @hidden */
  66322. _compression: Nullable<string>;
  66323. /** @hidden */
  66324. _generateStencilBuffer: boolean;
  66325. /** @hidden */
  66326. _generateDepthBuffer: boolean;
  66327. /** @hidden */
  66328. _comparisonFunction: number;
  66329. /** @hidden */
  66330. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66331. /** @hidden */
  66332. _lodGenerationScale: number;
  66333. /** @hidden */
  66334. _lodGenerationOffset: number;
  66335. /** @hidden */
  66336. _colorTextureArray: Nullable<WebGLTexture>;
  66337. /** @hidden */
  66338. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66339. /** @hidden */
  66340. _lodTextureHigh: Nullable<BaseTexture>;
  66341. /** @hidden */
  66342. _lodTextureMid: Nullable<BaseTexture>;
  66343. /** @hidden */
  66344. _lodTextureLow: Nullable<BaseTexture>;
  66345. /** @hidden */
  66346. _isRGBD: boolean;
  66347. /** @hidden */
  66348. _webGLTexture: Nullable<WebGLTexture>;
  66349. /** @hidden */
  66350. _references: number;
  66351. private _engine;
  66352. /**
  66353. * Gets the Engine the texture belongs to.
  66354. * @returns The babylon engine
  66355. */
  66356. getEngine(): Engine;
  66357. /**
  66358. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66359. */
  66360. readonly dataSource: number;
  66361. /**
  66362. * Creates a new InternalTexture
  66363. * @param engine defines the engine to use
  66364. * @param dataSource defines the type of data that will be used
  66365. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66366. */
  66367. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66368. /**
  66369. * Increments the number of references (ie. the number of Texture that point to it)
  66370. */
  66371. incrementReferences(): void;
  66372. /**
  66373. * Change the size of the texture (not the size of the content)
  66374. * @param width defines the new width
  66375. * @param height defines the new height
  66376. * @param depth defines the new depth (1 by default)
  66377. */
  66378. updateSize(width: int, height: int, depth?: int): void;
  66379. /** @hidden */
  66380. _rebuild(): void;
  66381. /** @hidden */
  66382. _swapAndDie(target: InternalTexture): void;
  66383. /**
  66384. * Dispose the current allocated resources
  66385. */
  66386. dispose(): void;
  66387. }
  66388. }
  66389. declare module BABYLON {
  66390. /**
  66391. * This represents the main contract an easing function should follow.
  66392. * Easing functions are used throughout the animation system.
  66393. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66394. */
  66395. export interface IEasingFunction {
  66396. /**
  66397. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66398. * of the easing function.
  66399. * The link below provides some of the most common examples of easing functions.
  66400. * @see https://easings.net/
  66401. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66402. * @returns the corresponding value on the curve defined by the easing function
  66403. */
  66404. ease(gradient: number): number;
  66405. }
  66406. /**
  66407. * Base class used for every default easing function.
  66408. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66409. */
  66410. export class EasingFunction implements IEasingFunction {
  66411. /**
  66412. * Interpolation follows the mathematical formula associated with the easing function.
  66413. */
  66414. static readonly EASINGMODE_EASEIN: number;
  66415. /**
  66416. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66417. */
  66418. static readonly EASINGMODE_EASEOUT: number;
  66419. /**
  66420. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66421. */
  66422. static readonly EASINGMODE_EASEINOUT: number;
  66423. private _easingMode;
  66424. /**
  66425. * Sets the easing mode of the current function.
  66426. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66427. */
  66428. setEasingMode(easingMode: number): void;
  66429. /**
  66430. * Gets the current easing mode.
  66431. * @returns the easing mode
  66432. */
  66433. getEasingMode(): number;
  66434. /**
  66435. * @hidden
  66436. */
  66437. easeInCore(gradient: number): number;
  66438. /**
  66439. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66440. * of the easing function.
  66441. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66442. * @returns the corresponding value on the curve defined by the easing function
  66443. */
  66444. ease(gradient: number): number;
  66445. }
  66446. /**
  66447. * Easing function with a circle shape (see link below).
  66448. * @see https://easings.net/#easeInCirc
  66449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66450. */
  66451. export class CircleEase extends EasingFunction implements IEasingFunction {
  66452. /** @hidden */
  66453. easeInCore(gradient: number): number;
  66454. }
  66455. /**
  66456. * Easing function with a ease back shape (see link below).
  66457. * @see https://easings.net/#easeInBack
  66458. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66459. */
  66460. export class BackEase extends EasingFunction implements IEasingFunction {
  66461. /** Defines the amplitude of the function */
  66462. amplitude: number;
  66463. /**
  66464. * Instantiates a back ease easing
  66465. * @see https://easings.net/#easeInBack
  66466. * @param amplitude Defines the amplitude of the function
  66467. */
  66468. constructor(
  66469. /** Defines the amplitude of the function */
  66470. amplitude?: number);
  66471. /** @hidden */
  66472. easeInCore(gradient: number): number;
  66473. }
  66474. /**
  66475. * Easing function with a bouncing shape (see link below).
  66476. * @see https://easings.net/#easeInBounce
  66477. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66478. */
  66479. export class BounceEase extends EasingFunction implements IEasingFunction {
  66480. /** Defines the number of bounces */
  66481. bounces: number;
  66482. /** Defines the amplitude of the bounce */
  66483. bounciness: number;
  66484. /**
  66485. * Instantiates a bounce easing
  66486. * @see https://easings.net/#easeInBounce
  66487. * @param bounces Defines the number of bounces
  66488. * @param bounciness Defines the amplitude of the bounce
  66489. */
  66490. constructor(
  66491. /** Defines the number of bounces */
  66492. bounces?: number,
  66493. /** Defines the amplitude of the bounce */
  66494. bounciness?: number);
  66495. /** @hidden */
  66496. easeInCore(gradient: number): number;
  66497. }
  66498. /**
  66499. * Easing function with a power of 3 shape (see link below).
  66500. * @see https://easings.net/#easeInCubic
  66501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66502. */
  66503. export class CubicEase extends EasingFunction implements IEasingFunction {
  66504. /** @hidden */
  66505. easeInCore(gradient: number): number;
  66506. }
  66507. /**
  66508. * Easing function with an elastic shape (see link below).
  66509. * @see https://easings.net/#easeInElastic
  66510. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66511. */
  66512. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66513. /** Defines the number of oscillations*/
  66514. oscillations: number;
  66515. /** Defines the amplitude of the oscillations*/
  66516. springiness: number;
  66517. /**
  66518. * Instantiates an elastic easing function
  66519. * @see https://easings.net/#easeInElastic
  66520. * @param oscillations Defines the number of oscillations
  66521. * @param springiness Defines the amplitude of the oscillations
  66522. */
  66523. constructor(
  66524. /** Defines the number of oscillations*/
  66525. oscillations?: number,
  66526. /** Defines the amplitude of the oscillations*/
  66527. springiness?: number);
  66528. /** @hidden */
  66529. easeInCore(gradient: number): number;
  66530. }
  66531. /**
  66532. * Easing function with an exponential shape (see link below).
  66533. * @see https://easings.net/#easeInExpo
  66534. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66535. */
  66536. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66537. /** Defines the exponent of the function */
  66538. exponent: number;
  66539. /**
  66540. * Instantiates an exponential easing function
  66541. * @see https://easings.net/#easeInExpo
  66542. * @param exponent Defines the exponent of the function
  66543. */
  66544. constructor(
  66545. /** Defines the exponent of the function */
  66546. exponent?: number);
  66547. /** @hidden */
  66548. easeInCore(gradient: number): number;
  66549. }
  66550. /**
  66551. * Easing function with a power shape (see link below).
  66552. * @see https://easings.net/#easeInQuad
  66553. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66554. */
  66555. export class PowerEase extends EasingFunction implements IEasingFunction {
  66556. /** Defines the power of the function */
  66557. power: number;
  66558. /**
  66559. * Instantiates an power base easing function
  66560. * @see https://easings.net/#easeInQuad
  66561. * @param power Defines the power of the function
  66562. */
  66563. constructor(
  66564. /** Defines the power of the function */
  66565. power?: number);
  66566. /** @hidden */
  66567. easeInCore(gradient: number): number;
  66568. }
  66569. /**
  66570. * Easing function with a power of 2 shape (see link below).
  66571. * @see https://easings.net/#easeInQuad
  66572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66573. */
  66574. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66575. /** @hidden */
  66576. easeInCore(gradient: number): number;
  66577. }
  66578. /**
  66579. * Easing function with a power of 4 shape (see link below).
  66580. * @see https://easings.net/#easeInQuart
  66581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66582. */
  66583. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66584. /** @hidden */
  66585. easeInCore(gradient: number): number;
  66586. }
  66587. /**
  66588. * Easing function with a power of 5 shape (see link below).
  66589. * @see https://easings.net/#easeInQuint
  66590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66591. */
  66592. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66593. /** @hidden */
  66594. easeInCore(gradient: number): number;
  66595. }
  66596. /**
  66597. * Easing function with a sin shape (see link below).
  66598. * @see https://easings.net/#easeInSine
  66599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66600. */
  66601. export class SineEase extends EasingFunction implements IEasingFunction {
  66602. /** @hidden */
  66603. easeInCore(gradient: number): number;
  66604. }
  66605. /**
  66606. * Easing function with a bezier shape (see link below).
  66607. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66608. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66609. */
  66610. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66611. /** Defines the x component of the start tangent in the bezier curve */
  66612. x1: number;
  66613. /** Defines the y component of the start tangent in the bezier curve */
  66614. y1: number;
  66615. /** Defines the x component of the end tangent in the bezier curve */
  66616. x2: number;
  66617. /** Defines the y component of the end tangent in the bezier curve */
  66618. y2: number;
  66619. /**
  66620. * Instantiates a bezier function
  66621. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66622. * @param x1 Defines the x component of the start tangent in the bezier curve
  66623. * @param y1 Defines the y component of the start tangent in the bezier curve
  66624. * @param x2 Defines the x component of the end tangent in the bezier curve
  66625. * @param y2 Defines the y component of the end tangent in the bezier curve
  66626. */
  66627. constructor(
  66628. /** Defines the x component of the start tangent in the bezier curve */
  66629. x1?: number,
  66630. /** Defines the y component of the start tangent in the bezier curve */
  66631. y1?: number,
  66632. /** Defines the x component of the end tangent in the bezier curve */
  66633. x2?: number,
  66634. /** Defines the y component of the end tangent in the bezier curve */
  66635. y2?: number);
  66636. /** @hidden */
  66637. easeInCore(gradient: number): number;
  66638. }
  66639. }
  66640. declare module BABYLON {
  66641. /**
  66642. * Defines an interface which represents an animation key frame
  66643. */
  66644. export interface IAnimationKey {
  66645. /**
  66646. * Frame of the key frame
  66647. */
  66648. frame: number;
  66649. /**
  66650. * Value at the specifies key frame
  66651. */
  66652. value: any;
  66653. /**
  66654. * The input tangent for the cubic hermite spline
  66655. */
  66656. inTangent?: any;
  66657. /**
  66658. * The output tangent for the cubic hermite spline
  66659. */
  66660. outTangent?: any;
  66661. /**
  66662. * The animation interpolation type
  66663. */
  66664. interpolation?: AnimationKeyInterpolation;
  66665. }
  66666. /**
  66667. * Enum for the animation key frame interpolation type
  66668. */
  66669. export enum AnimationKeyInterpolation {
  66670. /**
  66671. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66672. */
  66673. STEP = 1
  66674. }
  66675. }
  66676. declare module BABYLON {
  66677. /**
  66678. * Represents the range of an animation
  66679. */
  66680. export class AnimationRange {
  66681. /**The name of the animation range**/
  66682. name: string;
  66683. /**The starting frame of the animation */
  66684. from: number;
  66685. /**The ending frame of the animation*/
  66686. to: number;
  66687. /**
  66688. * Initializes the range of an animation
  66689. * @param name The name of the animation range
  66690. * @param from The starting frame of the animation
  66691. * @param to The ending frame of the animation
  66692. */
  66693. constructor(
  66694. /**The name of the animation range**/
  66695. name: string,
  66696. /**The starting frame of the animation */
  66697. from: number,
  66698. /**The ending frame of the animation*/
  66699. to: number);
  66700. /**
  66701. * Makes a copy of the animation range
  66702. * @returns A copy of the animation range
  66703. */
  66704. clone(): AnimationRange;
  66705. }
  66706. }
  66707. declare module BABYLON {
  66708. /**
  66709. * Composed of a frame, and an action function
  66710. */
  66711. export class AnimationEvent {
  66712. /** The frame for which the event is triggered **/
  66713. frame: number;
  66714. /** The event to perform when triggered **/
  66715. action: (currentFrame: number) => void;
  66716. /** Specifies if the event should be triggered only once**/
  66717. onlyOnce?: boolean | undefined;
  66718. /**
  66719. * Specifies if the animation event is done
  66720. */
  66721. isDone: boolean;
  66722. /**
  66723. * Initializes the animation event
  66724. * @param frame The frame for which the event is triggered
  66725. * @param action The event to perform when triggered
  66726. * @param onlyOnce Specifies if the event should be triggered only once
  66727. */
  66728. constructor(
  66729. /** The frame for which the event is triggered **/
  66730. frame: number,
  66731. /** The event to perform when triggered **/
  66732. action: (currentFrame: number) => void,
  66733. /** Specifies if the event should be triggered only once**/
  66734. onlyOnce?: boolean | undefined);
  66735. /** @hidden */
  66736. _clone(): AnimationEvent;
  66737. }
  66738. }
  66739. declare module BABYLON {
  66740. /**
  66741. * Interface used to define a behavior
  66742. */
  66743. export interface Behavior<T> {
  66744. /** gets or sets behavior's name */
  66745. name: string;
  66746. /**
  66747. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66748. */
  66749. init(): void;
  66750. /**
  66751. * Called when the behavior is attached to a target
  66752. * @param target defines the target where the behavior is attached to
  66753. */
  66754. attach(target: T): void;
  66755. /**
  66756. * Called when the behavior is detached from its target
  66757. */
  66758. detach(): void;
  66759. }
  66760. /**
  66761. * Interface implemented by classes supporting behaviors
  66762. */
  66763. export interface IBehaviorAware<T> {
  66764. /**
  66765. * Attach a behavior
  66766. * @param behavior defines the behavior to attach
  66767. * @returns the current host
  66768. */
  66769. addBehavior(behavior: Behavior<T>): T;
  66770. /**
  66771. * Remove a behavior from the current object
  66772. * @param behavior defines the behavior to detach
  66773. * @returns the current host
  66774. */
  66775. removeBehavior(behavior: Behavior<T>): T;
  66776. /**
  66777. * Gets a behavior using its name to search
  66778. * @param name defines the name to search
  66779. * @returns the behavior or null if not found
  66780. */
  66781. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66782. }
  66783. }
  66784. declare module BABYLON {
  66785. /**
  66786. * @hidden
  66787. */
  66788. export class IntersectionInfo {
  66789. bu: Nullable<number>;
  66790. bv: Nullable<number>;
  66791. distance: number;
  66792. faceId: number;
  66793. subMeshId: number;
  66794. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66795. }
  66796. }
  66797. declare module BABYLON {
  66798. /**
  66799. * Class used to store bounding sphere information
  66800. */
  66801. export class BoundingSphere {
  66802. /**
  66803. * Gets the center of the bounding sphere in local space
  66804. */
  66805. readonly center: Vector3;
  66806. /**
  66807. * Radius of the bounding sphere in local space
  66808. */
  66809. radius: number;
  66810. /**
  66811. * Gets the center of the bounding sphere in world space
  66812. */
  66813. readonly centerWorld: Vector3;
  66814. /**
  66815. * Radius of the bounding sphere in world space
  66816. */
  66817. radiusWorld: number;
  66818. /**
  66819. * Gets the minimum vector in local space
  66820. */
  66821. readonly minimum: Vector3;
  66822. /**
  66823. * Gets the maximum vector in local space
  66824. */
  66825. readonly maximum: Vector3;
  66826. private _worldMatrix;
  66827. private static readonly TmpVector3;
  66828. /**
  66829. * Creates a new bounding sphere
  66830. * @param min defines the minimum vector (in local space)
  66831. * @param max defines the maximum vector (in local space)
  66832. * @param worldMatrix defines the new world matrix
  66833. */
  66834. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66835. /**
  66836. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66837. * @param min defines the new minimum vector (in local space)
  66838. * @param max defines the new maximum vector (in local space)
  66839. * @param worldMatrix defines the new world matrix
  66840. */
  66841. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66842. /**
  66843. * Scale the current bounding sphere by applying a scale factor
  66844. * @param factor defines the scale factor to apply
  66845. * @returns the current bounding box
  66846. */
  66847. scale(factor: number): BoundingSphere;
  66848. /**
  66849. * Gets the world matrix of the bounding box
  66850. * @returns a matrix
  66851. */
  66852. getWorldMatrix(): DeepImmutable<Matrix>;
  66853. /** @hidden */
  66854. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66855. /**
  66856. * Tests if the bounding sphere is intersecting the frustum planes
  66857. * @param frustumPlanes defines the frustum planes to test
  66858. * @returns true if there is an intersection
  66859. */
  66860. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66861. /**
  66862. * Tests if the bounding sphere center is in between the frustum planes.
  66863. * Used for optimistic fast inclusion.
  66864. * @param frustumPlanes defines the frustum planes to test
  66865. * @returns true if the sphere center is in between the frustum planes
  66866. */
  66867. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66868. /**
  66869. * Tests if a point is inside the bounding sphere
  66870. * @param point defines the point to test
  66871. * @returns true if the point is inside the bounding sphere
  66872. */
  66873. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66874. /**
  66875. * Checks if two sphere intersct
  66876. * @param sphere0 sphere 0
  66877. * @param sphere1 sphere 1
  66878. * @returns true if the speres intersect
  66879. */
  66880. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66881. }
  66882. }
  66883. declare module BABYLON {
  66884. /**
  66885. * Class used to store bounding box information
  66886. */
  66887. export class BoundingBox implements ICullable {
  66888. /**
  66889. * Gets the 8 vectors representing the bounding box in local space
  66890. */
  66891. readonly vectors: Vector3[];
  66892. /**
  66893. * Gets the center of the bounding box in local space
  66894. */
  66895. readonly center: Vector3;
  66896. /**
  66897. * Gets the center of the bounding box in world space
  66898. */
  66899. readonly centerWorld: Vector3;
  66900. /**
  66901. * Gets the extend size in local space
  66902. */
  66903. readonly extendSize: Vector3;
  66904. /**
  66905. * Gets the extend size in world space
  66906. */
  66907. readonly extendSizeWorld: Vector3;
  66908. /**
  66909. * Gets the OBB (object bounding box) directions
  66910. */
  66911. readonly directions: Vector3[];
  66912. /**
  66913. * Gets the 8 vectors representing the bounding box in world space
  66914. */
  66915. readonly vectorsWorld: Vector3[];
  66916. /**
  66917. * Gets the minimum vector in world space
  66918. */
  66919. readonly minimumWorld: Vector3;
  66920. /**
  66921. * Gets the maximum vector in world space
  66922. */
  66923. readonly maximumWorld: Vector3;
  66924. /**
  66925. * Gets the minimum vector in local space
  66926. */
  66927. readonly minimum: Vector3;
  66928. /**
  66929. * Gets the maximum vector in local space
  66930. */
  66931. readonly maximum: Vector3;
  66932. private _worldMatrix;
  66933. private static readonly TmpVector3;
  66934. /**
  66935. * @hidden
  66936. */
  66937. _tag: number;
  66938. /**
  66939. * Creates a new bounding box
  66940. * @param min defines the minimum vector (in local space)
  66941. * @param max defines the maximum vector (in local space)
  66942. * @param worldMatrix defines the new world matrix
  66943. */
  66944. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66945. /**
  66946. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66947. * @param min defines the new minimum vector (in local space)
  66948. * @param max defines the new maximum vector (in local space)
  66949. * @param worldMatrix defines the new world matrix
  66950. */
  66951. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66952. /**
  66953. * Scale the current bounding box by applying a scale factor
  66954. * @param factor defines the scale factor to apply
  66955. * @returns the current bounding box
  66956. */
  66957. scale(factor: number): BoundingBox;
  66958. /**
  66959. * Gets the world matrix of the bounding box
  66960. * @returns a matrix
  66961. */
  66962. getWorldMatrix(): DeepImmutable<Matrix>;
  66963. /** @hidden */
  66964. _update(world: DeepImmutable<Matrix>): void;
  66965. /**
  66966. * Tests if the bounding box is intersecting the frustum planes
  66967. * @param frustumPlanes defines the frustum planes to test
  66968. * @returns true if there is an intersection
  66969. */
  66970. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66971. /**
  66972. * Tests if the bounding box is entirely inside the frustum planes
  66973. * @param frustumPlanes defines the frustum planes to test
  66974. * @returns true if there is an inclusion
  66975. */
  66976. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66977. /**
  66978. * Tests if a point is inside the bounding box
  66979. * @param point defines the point to test
  66980. * @returns true if the point is inside the bounding box
  66981. */
  66982. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66983. /**
  66984. * Tests if the bounding box intersects with a bounding sphere
  66985. * @param sphere defines the sphere to test
  66986. * @returns true if there is an intersection
  66987. */
  66988. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66989. /**
  66990. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66991. * @param min defines the min vector to use
  66992. * @param max defines the max vector to use
  66993. * @returns true if there is an intersection
  66994. */
  66995. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66996. /**
  66997. * Tests if two bounding boxes are intersections
  66998. * @param box0 defines the first box to test
  66999. * @param box1 defines the second box to test
  67000. * @returns true if there is an intersection
  67001. */
  67002. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  67003. /**
  67004. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  67005. * @param minPoint defines the minimum vector of the bounding box
  67006. * @param maxPoint defines the maximum vector of the bounding box
  67007. * @param sphereCenter defines the sphere center
  67008. * @param sphereRadius defines the sphere radius
  67009. * @returns true if there is an intersection
  67010. */
  67011. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  67012. /**
  67013. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  67014. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67015. * @param frustumPlanes defines the frustum planes to test
  67016. * @return true if there is an inclusion
  67017. */
  67018. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67019. /**
  67020. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  67021. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67022. * @param frustumPlanes defines the frustum planes to test
  67023. * @return true if there is an intersection
  67024. */
  67025. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67026. }
  67027. }
  67028. declare module BABYLON {
  67029. /** @hidden */
  67030. export class Collider {
  67031. /** Define if a collision was found */
  67032. collisionFound: boolean;
  67033. /**
  67034. * Define last intersection point in local space
  67035. */
  67036. intersectionPoint: Vector3;
  67037. /**
  67038. * Define last collided mesh
  67039. */
  67040. collidedMesh: Nullable<AbstractMesh>;
  67041. private _collisionPoint;
  67042. private _planeIntersectionPoint;
  67043. private _tempVector;
  67044. private _tempVector2;
  67045. private _tempVector3;
  67046. private _tempVector4;
  67047. private _edge;
  67048. private _baseToVertex;
  67049. private _destinationPoint;
  67050. private _slidePlaneNormal;
  67051. private _displacementVector;
  67052. /** @hidden */
  67053. _radius: Vector3;
  67054. /** @hidden */
  67055. _retry: number;
  67056. private _velocity;
  67057. private _basePoint;
  67058. private _epsilon;
  67059. /** @hidden */
  67060. _velocityWorldLength: number;
  67061. /** @hidden */
  67062. _basePointWorld: Vector3;
  67063. private _velocityWorld;
  67064. private _normalizedVelocity;
  67065. /** @hidden */
  67066. _initialVelocity: Vector3;
  67067. /** @hidden */
  67068. _initialPosition: Vector3;
  67069. private _nearestDistance;
  67070. private _collisionMask;
  67071. collisionMask: number;
  67072. /**
  67073. * Gets the plane normal used to compute the sliding response (in local space)
  67074. */
  67075. readonly slidePlaneNormal: Vector3;
  67076. /** @hidden */
  67077. _initialize(source: Vector3, dir: Vector3, e: number): void;
  67078. /** @hidden */
  67079. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  67080. /** @hidden */
  67081. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  67082. /** @hidden */
  67083. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  67084. /** @hidden */
  67085. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  67086. /** @hidden */
  67087. _getResponse(pos: Vector3, vel: Vector3): void;
  67088. }
  67089. }
  67090. declare module BABYLON {
  67091. /**
  67092. * Interface for cullable objects
  67093. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  67094. */
  67095. export interface ICullable {
  67096. /**
  67097. * Checks if the object or part of the object is in the frustum
  67098. * @param frustumPlanes Camera near/planes
  67099. * @returns true if the object is in frustum otherwise false
  67100. */
  67101. isInFrustum(frustumPlanes: Plane[]): boolean;
  67102. /**
  67103. * Checks if a cullable object (mesh...) is in the camera frustum
  67104. * Unlike isInFrustum this cheks the full bounding box
  67105. * @param frustumPlanes Camera near/planes
  67106. * @returns true if the object is in frustum otherwise false
  67107. */
  67108. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  67109. }
  67110. /**
  67111. * Info for a bounding data of a mesh
  67112. */
  67113. export class BoundingInfo implements ICullable {
  67114. /**
  67115. * Bounding box for the mesh
  67116. */
  67117. readonly boundingBox: BoundingBox;
  67118. /**
  67119. * Bounding sphere for the mesh
  67120. */
  67121. readonly boundingSphere: BoundingSphere;
  67122. private _isLocked;
  67123. private static readonly TmpVector3;
  67124. /**
  67125. * Constructs bounding info
  67126. * @param minimum min vector of the bounding box/sphere
  67127. * @param maximum max vector of the bounding box/sphere
  67128. * @param worldMatrix defines the new world matrix
  67129. */
  67130. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67131. /**
  67132. * Recreates the entire bounding info from scratch as if we call the constructor in place
  67133. * @param min defines the new minimum vector (in local space)
  67134. * @param max defines the new maximum vector (in local space)
  67135. * @param worldMatrix defines the new world matrix
  67136. */
  67137. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67138. /**
  67139. * min vector of the bounding box/sphere
  67140. */
  67141. readonly minimum: Vector3;
  67142. /**
  67143. * max vector of the bounding box/sphere
  67144. */
  67145. readonly maximum: Vector3;
  67146. /**
  67147. * If the info is locked and won't be updated to avoid perf overhead
  67148. */
  67149. isLocked: boolean;
  67150. /**
  67151. * Updates the bounding sphere and box
  67152. * @param world world matrix to be used to update
  67153. */
  67154. update(world: DeepImmutable<Matrix>): void;
  67155. /**
  67156. * Recreate the bounding info to be centered around a specific point given a specific extend.
  67157. * @param center New center of the bounding info
  67158. * @param extend New extend of the bounding info
  67159. * @returns the current bounding info
  67160. */
  67161. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  67162. /**
  67163. * Scale the current bounding info by applying a scale factor
  67164. * @param factor defines the scale factor to apply
  67165. * @returns the current bounding info
  67166. */
  67167. scale(factor: number): BoundingInfo;
  67168. /**
  67169. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  67170. * @param frustumPlanes defines the frustum to test
  67171. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  67172. * @returns true if the bounding info is in the frustum planes
  67173. */
  67174. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  67175. /**
  67176. * Gets the world distance between the min and max points of the bounding box
  67177. */
  67178. readonly diagonalLength: number;
  67179. /**
  67180. * Checks if a cullable object (mesh...) is in the camera frustum
  67181. * Unlike isInFrustum this cheks the full bounding box
  67182. * @param frustumPlanes Camera near/planes
  67183. * @returns true if the object is in frustum otherwise false
  67184. */
  67185. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67186. /** @hidden */
  67187. _checkCollision(collider: Collider): boolean;
  67188. /**
  67189. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  67190. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67191. * @param point the point to check intersection with
  67192. * @returns if the point intersects
  67193. */
  67194. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67195. /**
  67196. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  67197. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67198. * @param boundingInfo the bounding info to check intersection with
  67199. * @param precise if the intersection should be done using OBB
  67200. * @returns if the bounding info intersects
  67201. */
  67202. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  67203. }
  67204. }
  67205. declare module BABYLON {
  67206. /**
  67207. * Defines an array and its length.
  67208. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  67209. */
  67210. export interface ISmartArrayLike<T> {
  67211. /**
  67212. * The data of the array.
  67213. */
  67214. data: Array<T>;
  67215. /**
  67216. * The active length of the array.
  67217. */
  67218. length: number;
  67219. }
  67220. /**
  67221. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67222. */
  67223. export class SmartArray<T> implements ISmartArrayLike<T> {
  67224. /**
  67225. * The full set of data from the array.
  67226. */
  67227. data: Array<T>;
  67228. /**
  67229. * The active length of the array.
  67230. */
  67231. length: number;
  67232. protected _id: number;
  67233. /**
  67234. * Instantiates a Smart Array.
  67235. * @param capacity defines the default capacity of the array.
  67236. */
  67237. constructor(capacity: number);
  67238. /**
  67239. * Pushes a value at the end of the active data.
  67240. * @param value defines the object to push in the array.
  67241. */
  67242. push(value: T): void;
  67243. /**
  67244. * Iterates over the active data and apply the lambda to them.
  67245. * @param func defines the action to apply on each value.
  67246. */
  67247. forEach(func: (content: T) => void): void;
  67248. /**
  67249. * Sorts the full sets of data.
  67250. * @param compareFn defines the comparison function to apply.
  67251. */
  67252. sort(compareFn: (a: T, b: T) => number): void;
  67253. /**
  67254. * Resets the active data to an empty array.
  67255. */
  67256. reset(): void;
  67257. /**
  67258. * Releases all the data from the array as well as the array.
  67259. */
  67260. dispose(): void;
  67261. /**
  67262. * Concats the active data with a given array.
  67263. * @param array defines the data to concatenate with.
  67264. */
  67265. concat(array: any): void;
  67266. /**
  67267. * Returns the position of a value in the active data.
  67268. * @param value defines the value to find the index for
  67269. * @returns the index if found in the active data otherwise -1
  67270. */
  67271. indexOf(value: T): number;
  67272. /**
  67273. * Returns whether an element is part of the active data.
  67274. * @param value defines the value to look for
  67275. * @returns true if found in the active data otherwise false
  67276. */
  67277. contains(value: T): boolean;
  67278. private static _GlobalId;
  67279. }
  67280. /**
  67281. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67282. * The data in this array can only be present once
  67283. */
  67284. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  67285. private _duplicateId;
  67286. /**
  67287. * Pushes a value at the end of the active data.
  67288. * THIS DOES NOT PREVENT DUPPLICATE DATA
  67289. * @param value defines the object to push in the array.
  67290. */
  67291. push(value: T): void;
  67292. /**
  67293. * Pushes a value at the end of the active data.
  67294. * If the data is already present, it won t be added again
  67295. * @param value defines the object to push in the array.
  67296. * @returns true if added false if it was already present
  67297. */
  67298. pushNoDuplicate(value: T): boolean;
  67299. /**
  67300. * Resets the active data to an empty array.
  67301. */
  67302. reset(): void;
  67303. /**
  67304. * Concats the active data with a given array.
  67305. * This ensures no dupplicate will be present in the result.
  67306. * @param array defines the data to concatenate with.
  67307. */
  67308. concatWithNoDuplicate(array: any): void;
  67309. }
  67310. }
  67311. declare module BABYLON {
  67312. /**
  67313. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67314. * separate meshes. This can be use to improve performances.
  67315. * @see http://doc.babylonjs.com/how_to/multi_materials
  67316. */
  67317. export class MultiMaterial extends Material {
  67318. private _subMaterials;
  67319. /**
  67320. * Gets or Sets the list of Materials used within the multi material.
  67321. * They need to be ordered according to the submeshes order in the associated mesh
  67322. */
  67323. subMaterials: Nullable<Material>[];
  67324. /**
  67325. * Function used to align with Node.getChildren()
  67326. * @returns the list of Materials used within the multi material
  67327. */
  67328. getChildren(): Nullable<Material>[];
  67329. /**
  67330. * Instantiates a new Multi Material
  67331. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67332. * separate meshes. This can be use to improve performances.
  67333. * @see http://doc.babylonjs.com/how_to/multi_materials
  67334. * @param name Define the name in the scene
  67335. * @param scene Define the scene the material belongs to
  67336. */
  67337. constructor(name: string, scene: Scene);
  67338. private _hookArray;
  67339. /**
  67340. * Get one of the submaterial by its index in the submaterials array
  67341. * @param index The index to look the sub material at
  67342. * @returns The Material if the index has been defined
  67343. */
  67344. getSubMaterial(index: number): Nullable<Material>;
  67345. /**
  67346. * Get the list of active textures for the whole sub materials list.
  67347. * @returns All the textures that will be used during the rendering
  67348. */
  67349. getActiveTextures(): BaseTexture[];
  67350. /**
  67351. * Gets the current class name of the material e.g. "MultiMaterial"
  67352. * Mainly use in serialization.
  67353. * @returns the class name
  67354. */
  67355. getClassName(): string;
  67356. /**
  67357. * Checks if the material is ready to render the requested sub mesh
  67358. * @param mesh Define the mesh the submesh belongs to
  67359. * @param subMesh Define the sub mesh to look readyness for
  67360. * @param useInstances Define whether or not the material is used with instances
  67361. * @returns true if ready, otherwise false
  67362. */
  67363. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67364. /**
  67365. * Clones the current material and its related sub materials
  67366. * @param name Define the name of the newly cloned material
  67367. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67368. * @returns the cloned material
  67369. */
  67370. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67371. /**
  67372. * Serializes the materials into a JSON representation.
  67373. * @returns the JSON representation
  67374. */
  67375. serialize(): any;
  67376. /**
  67377. * Dispose the material and release its associated resources
  67378. * @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)
  67379. * @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)
  67380. * @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)
  67381. */
  67382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67383. /**
  67384. * Creates a MultiMaterial from parsed MultiMaterial data.
  67385. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67386. * @param scene defines the hosting scene
  67387. * @returns a new MultiMaterial
  67388. */
  67389. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67390. }
  67391. }
  67392. declare module BABYLON {
  67393. /**
  67394. * Class used to represent data loading progression
  67395. */
  67396. export class SceneLoaderFlags {
  67397. private static _ForceFullSceneLoadingForIncremental;
  67398. private static _ShowLoadingScreen;
  67399. private static _CleanBoneMatrixWeights;
  67400. private static _loggingLevel;
  67401. /**
  67402. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67403. */
  67404. static ForceFullSceneLoadingForIncremental: boolean;
  67405. /**
  67406. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67407. */
  67408. static ShowLoadingScreen: boolean;
  67409. /**
  67410. * Defines the current logging level (while loading the scene)
  67411. * @ignorenaming
  67412. */
  67413. static loggingLevel: number;
  67414. /**
  67415. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67416. */
  67417. static CleanBoneMatrixWeights: boolean;
  67418. }
  67419. }
  67420. declare module BABYLON {
  67421. /**
  67422. * 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.
  67423. * @see https://doc.babylonjs.com/how_to/transformnode
  67424. */
  67425. export class TransformNode extends Node {
  67426. /**
  67427. * Object will not rotate to face the camera
  67428. */
  67429. static BILLBOARDMODE_NONE: number;
  67430. /**
  67431. * Object will rotate to face the camera but only on the x axis
  67432. */
  67433. static BILLBOARDMODE_X: number;
  67434. /**
  67435. * Object will rotate to face the camera but only on the y axis
  67436. */
  67437. static BILLBOARDMODE_Y: number;
  67438. /**
  67439. * Object will rotate to face the camera but only on the z axis
  67440. */
  67441. static BILLBOARDMODE_Z: number;
  67442. /**
  67443. * Object will rotate to face the camera
  67444. */
  67445. static BILLBOARDMODE_ALL: number;
  67446. private _forward;
  67447. private _forwardInverted;
  67448. private _up;
  67449. private _right;
  67450. private _rightInverted;
  67451. private _position;
  67452. private _rotation;
  67453. private _rotationQuaternion;
  67454. protected _scaling: Vector3;
  67455. protected _isDirty: boolean;
  67456. private _transformToBoneReferal;
  67457. private _billboardMode;
  67458. /**
  67459. * Gets or sets the billboard mode. Default is 0.
  67460. *
  67461. * | Value | Type | Description |
  67462. * | --- | --- | --- |
  67463. * | 0 | BILLBOARDMODE_NONE | |
  67464. * | 1 | BILLBOARDMODE_X | |
  67465. * | 2 | BILLBOARDMODE_Y | |
  67466. * | 4 | BILLBOARDMODE_Z | |
  67467. * | 7 | BILLBOARDMODE_ALL | |
  67468. *
  67469. */
  67470. billboardMode: number;
  67471. private _preserveParentRotationForBillboard;
  67472. /**
  67473. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67474. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67475. */
  67476. preserveParentRotationForBillboard: boolean;
  67477. /**
  67478. * 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
  67479. */
  67480. scalingDeterminant: number;
  67481. private _infiniteDistance;
  67482. /**
  67483. * Gets or sets the distance of the object to max, often used by skybox
  67484. */
  67485. infiniteDistance: boolean;
  67486. /**
  67487. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67488. * By default the system will update normals to compensate
  67489. */
  67490. ignoreNonUniformScaling: boolean;
  67491. /**
  67492. * 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
  67493. */
  67494. reIntegrateRotationIntoRotationQuaternion: boolean;
  67495. /** @hidden */
  67496. _poseMatrix: Nullable<Matrix>;
  67497. /** @hidden */
  67498. _localMatrix: Matrix;
  67499. private _usePivotMatrix;
  67500. private _absolutePosition;
  67501. private _pivotMatrix;
  67502. private _pivotMatrixInverse;
  67503. protected _postMultiplyPivotMatrix: boolean;
  67504. protected _isWorldMatrixFrozen: boolean;
  67505. /** @hidden */
  67506. _indexInSceneTransformNodesArray: number;
  67507. /**
  67508. * An event triggered after the world matrix is updated
  67509. */
  67510. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67511. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67512. /**
  67513. * Gets a string identifying the name of the class
  67514. * @returns "TransformNode" string
  67515. */
  67516. getClassName(): string;
  67517. /**
  67518. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67519. */
  67520. position: Vector3;
  67521. /**
  67522. * 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)).
  67523. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67524. */
  67525. rotation: Vector3;
  67526. /**
  67527. * 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)).
  67528. */
  67529. scaling: Vector3;
  67530. /**
  67531. * 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).
  67532. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67533. */
  67534. rotationQuaternion: Nullable<Quaternion>;
  67535. /**
  67536. * The forward direction of that transform in world space.
  67537. */
  67538. readonly forward: Vector3;
  67539. /**
  67540. * The up direction of that transform in world space.
  67541. */
  67542. readonly up: Vector3;
  67543. /**
  67544. * The right direction of that transform in world space.
  67545. */
  67546. readonly right: Vector3;
  67547. /**
  67548. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67549. * @param matrix the matrix to copy the pose from
  67550. * @returns this TransformNode.
  67551. */
  67552. updatePoseMatrix(matrix: Matrix): TransformNode;
  67553. /**
  67554. * Returns the mesh Pose matrix.
  67555. * @returns the pose matrix
  67556. */
  67557. getPoseMatrix(): Matrix;
  67558. /** @hidden */
  67559. _isSynchronized(): boolean;
  67560. /** @hidden */
  67561. _initCache(): void;
  67562. /**
  67563. * Flag the transform node as dirty (Forcing it to update everything)
  67564. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67565. * @returns this transform node
  67566. */
  67567. markAsDirty(property: string): TransformNode;
  67568. /**
  67569. * Returns the current mesh absolute position.
  67570. * Returns a Vector3.
  67571. */
  67572. readonly absolutePosition: Vector3;
  67573. /**
  67574. * Sets a new matrix to apply before all other transformation
  67575. * @param matrix defines the transform matrix
  67576. * @returns the current TransformNode
  67577. */
  67578. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67579. /**
  67580. * Sets a new pivot matrix to the current node
  67581. * @param matrix defines the new pivot matrix to use
  67582. * @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
  67583. * @returns the current TransformNode
  67584. */
  67585. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67586. /**
  67587. * Returns the mesh pivot matrix.
  67588. * Default : Identity.
  67589. * @returns the matrix
  67590. */
  67591. getPivotMatrix(): Matrix;
  67592. /**
  67593. * Prevents the World matrix to be computed any longer.
  67594. * @returns the TransformNode.
  67595. */
  67596. freezeWorldMatrix(): TransformNode;
  67597. /**
  67598. * Allows back the World matrix computation.
  67599. * @returns the TransformNode.
  67600. */
  67601. unfreezeWorldMatrix(): this;
  67602. /**
  67603. * True if the World matrix has been frozen.
  67604. */
  67605. readonly isWorldMatrixFrozen: boolean;
  67606. /**
  67607. * Retuns the mesh absolute position in the World.
  67608. * @returns a Vector3.
  67609. */
  67610. getAbsolutePosition(): Vector3;
  67611. /**
  67612. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67613. * @param absolutePosition the absolute position to set
  67614. * @returns the TransformNode.
  67615. */
  67616. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67617. /**
  67618. * Sets the mesh position in its local space.
  67619. * @param vector3 the position to set in localspace
  67620. * @returns the TransformNode.
  67621. */
  67622. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67623. /**
  67624. * Returns the mesh position in the local space from the current World matrix values.
  67625. * @returns a new Vector3.
  67626. */
  67627. getPositionExpressedInLocalSpace(): Vector3;
  67628. /**
  67629. * Translates the mesh along the passed Vector3 in its local space.
  67630. * @param vector3 the distance to translate in localspace
  67631. * @returns the TransformNode.
  67632. */
  67633. locallyTranslate(vector3: Vector3): TransformNode;
  67634. private static _lookAtVectorCache;
  67635. /**
  67636. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67637. * @param targetPoint the position (must be in same space as current mesh) to look at
  67638. * @param yawCor optional yaw (y-axis) correction in radians
  67639. * @param pitchCor optional pitch (x-axis) correction in radians
  67640. * @param rollCor optional roll (z-axis) correction in radians
  67641. * @param space the choosen space of the target
  67642. * @returns the TransformNode.
  67643. */
  67644. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67645. /**
  67646. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67647. * This Vector3 is expressed in the World space.
  67648. * @param localAxis axis to rotate
  67649. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67650. */
  67651. getDirection(localAxis: Vector3): Vector3;
  67652. /**
  67653. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67654. * localAxis is expressed in the mesh local space.
  67655. * result is computed in the Wordl space from the mesh World matrix.
  67656. * @param localAxis axis to rotate
  67657. * @param result the resulting transformnode
  67658. * @returns this TransformNode.
  67659. */
  67660. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67661. /**
  67662. * Sets this transform node rotation to the given local axis.
  67663. * @param localAxis the axis in local space
  67664. * @param yawCor optional yaw (y-axis) correction in radians
  67665. * @param pitchCor optional pitch (x-axis) correction in radians
  67666. * @param rollCor optional roll (z-axis) correction in radians
  67667. * @returns this TransformNode
  67668. */
  67669. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67670. /**
  67671. * Sets a new pivot point to the current node
  67672. * @param point defines the new pivot point to use
  67673. * @param space defines if the point is in world or local space (local by default)
  67674. * @returns the current TransformNode
  67675. */
  67676. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67677. /**
  67678. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67679. * @returns the pivot point
  67680. */
  67681. getPivotPoint(): Vector3;
  67682. /**
  67683. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67684. * @param result the vector3 to store the result
  67685. * @returns this TransformNode.
  67686. */
  67687. getPivotPointToRef(result: Vector3): TransformNode;
  67688. /**
  67689. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67690. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67691. */
  67692. getAbsolutePivotPoint(): Vector3;
  67693. /**
  67694. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67695. * @param result vector3 to store the result
  67696. * @returns this TransformNode.
  67697. */
  67698. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67699. /**
  67700. * Defines the passed node as the parent of the current node.
  67701. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67702. * @see https://doc.babylonjs.com/how_to/parenting
  67703. * @param node the node ot set as the parent
  67704. * @returns this TransformNode.
  67705. */
  67706. setParent(node: Nullable<Node>): TransformNode;
  67707. private _nonUniformScaling;
  67708. /**
  67709. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67710. */
  67711. readonly nonUniformScaling: boolean;
  67712. /** @hidden */
  67713. _updateNonUniformScalingState(value: boolean): boolean;
  67714. /**
  67715. * Attach the current TransformNode to another TransformNode associated with a bone
  67716. * @param bone Bone affecting the TransformNode
  67717. * @param affectedTransformNode TransformNode associated with the bone
  67718. * @returns this object
  67719. */
  67720. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67721. /**
  67722. * Detach the transform node if its associated with a bone
  67723. * @returns this object
  67724. */
  67725. detachFromBone(): TransformNode;
  67726. private static _rotationAxisCache;
  67727. /**
  67728. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67729. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67730. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67731. * The passed axis is also normalized.
  67732. * @param axis the axis to rotate around
  67733. * @param amount the amount to rotate in radians
  67734. * @param space Space to rotate in (Default: local)
  67735. * @returns the TransformNode.
  67736. */
  67737. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67738. /**
  67739. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67740. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67741. * The passed axis is also normalized. .
  67742. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67743. * @param point the point to rotate around
  67744. * @param axis the axis to rotate around
  67745. * @param amount the amount to rotate in radians
  67746. * @returns the TransformNode
  67747. */
  67748. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67749. /**
  67750. * Translates the mesh along the axis vector for the passed distance in the given space.
  67751. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67752. * @param axis the axis to translate in
  67753. * @param distance the distance to translate
  67754. * @param space Space to rotate in (Default: local)
  67755. * @returns the TransformNode.
  67756. */
  67757. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67758. /**
  67759. * Adds a rotation step to the mesh current rotation.
  67760. * x, y, z are Euler angles expressed in radians.
  67761. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67762. * This means this rotation is made in the mesh local space only.
  67763. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67764. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67765. * ```javascript
  67766. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67767. * ```
  67768. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67769. * 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.
  67770. * @param x Rotation to add
  67771. * @param y Rotation to add
  67772. * @param z Rotation to add
  67773. * @returns the TransformNode.
  67774. */
  67775. addRotation(x: number, y: number, z: number): TransformNode;
  67776. /**
  67777. * @hidden
  67778. */
  67779. protected _getEffectiveParent(): Nullable<Node>;
  67780. /**
  67781. * Computes the world matrix of the node
  67782. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67783. * @returns the world matrix
  67784. */
  67785. computeWorldMatrix(force?: boolean): Matrix;
  67786. protected _afterComputeWorldMatrix(): void;
  67787. /**
  67788. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67789. * @param func callback function to add
  67790. *
  67791. * @returns the TransformNode.
  67792. */
  67793. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67794. /**
  67795. * Removes a registered callback function.
  67796. * @param func callback function to remove
  67797. * @returns the TransformNode.
  67798. */
  67799. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67800. /**
  67801. * Gets the position of the current mesh in camera space
  67802. * @param camera defines the camera to use
  67803. * @returns a position
  67804. */
  67805. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67806. /**
  67807. * Returns the distance from the mesh to the active camera
  67808. * @param camera defines the camera to use
  67809. * @returns the distance
  67810. */
  67811. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67812. /**
  67813. * Clone the current transform node
  67814. * @param name Name of the new clone
  67815. * @param newParent New parent for the clone
  67816. * @param doNotCloneChildren Do not clone children hierarchy
  67817. * @returns the new transform node
  67818. */
  67819. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67820. /**
  67821. * Serializes the objects information.
  67822. * @param currentSerializationObject defines the object to serialize in
  67823. * @returns the serialized object
  67824. */
  67825. serialize(currentSerializationObject?: any): any;
  67826. /**
  67827. * Returns a new TransformNode object parsed from the source provided.
  67828. * @param parsedTransformNode is the source.
  67829. * @param scene the scne the object belongs to
  67830. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67831. * @returns a new TransformNode object parsed from the source provided.
  67832. */
  67833. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67834. /**
  67835. * Get all child-transformNodes of this node
  67836. * @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
  67837. * @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
  67838. * @returns an array of TransformNode
  67839. */
  67840. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67841. /**
  67842. * Releases resources associated with this transform node.
  67843. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67844. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67845. */
  67846. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67847. }
  67848. }
  67849. declare module BABYLON {
  67850. /**
  67851. * Class used to override all child animations of a given target
  67852. */
  67853. export class AnimationPropertiesOverride {
  67854. /**
  67855. * Gets or sets a value indicating if animation blending must be used
  67856. */
  67857. enableBlending: boolean;
  67858. /**
  67859. * Gets or sets the blending speed to use when enableBlending is true
  67860. */
  67861. blendingSpeed: number;
  67862. /**
  67863. * Gets or sets the default loop mode to use
  67864. */
  67865. loopMode: number;
  67866. }
  67867. }
  67868. declare module BABYLON {
  67869. /**
  67870. * Class used to store bone information
  67871. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67872. */
  67873. export class Bone extends Node {
  67874. /**
  67875. * defines the bone name
  67876. */
  67877. name: string;
  67878. private static _tmpVecs;
  67879. private static _tmpQuat;
  67880. private static _tmpMats;
  67881. /**
  67882. * Gets the list of child bones
  67883. */
  67884. children: Bone[];
  67885. /** Gets the animations associated with this bone */
  67886. animations: Animation[];
  67887. /**
  67888. * Gets or sets bone length
  67889. */
  67890. length: number;
  67891. /**
  67892. * @hidden Internal only
  67893. * Set this value to map this bone to a different index in the transform matrices
  67894. * Set this value to -1 to exclude the bone from the transform matrices
  67895. */
  67896. _index: Nullable<number>;
  67897. private _skeleton;
  67898. private _localMatrix;
  67899. private _restPose;
  67900. private _baseMatrix;
  67901. private _absoluteTransform;
  67902. private _invertedAbsoluteTransform;
  67903. private _parent;
  67904. private _scalingDeterminant;
  67905. private _worldTransform;
  67906. private _localScaling;
  67907. private _localRotation;
  67908. private _localPosition;
  67909. private _needToDecompose;
  67910. private _needToCompose;
  67911. /** @hidden */
  67912. _linkedTransformNode: Nullable<TransformNode>;
  67913. /** @hidden */
  67914. /** @hidden */
  67915. _matrix: Matrix;
  67916. /**
  67917. * Create a new bone
  67918. * @param name defines the bone name
  67919. * @param skeleton defines the parent skeleton
  67920. * @param parentBone defines the parent (can be null if the bone is the root)
  67921. * @param localMatrix defines the local matrix
  67922. * @param restPose defines the rest pose matrix
  67923. * @param baseMatrix defines the base matrix
  67924. * @param index defines index of the bone in the hiearchy
  67925. */
  67926. constructor(
  67927. /**
  67928. * defines the bone name
  67929. */
  67930. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67931. /**
  67932. * Gets the current object class name.
  67933. * @return the class name
  67934. */
  67935. getClassName(): string;
  67936. /**
  67937. * Gets the parent skeleton
  67938. * @returns a skeleton
  67939. */
  67940. getSkeleton(): Skeleton;
  67941. /**
  67942. * Gets parent bone
  67943. * @returns a bone or null if the bone is the root of the bone hierarchy
  67944. */
  67945. getParent(): Nullable<Bone>;
  67946. /**
  67947. * Returns an array containing the root bones
  67948. * @returns an array containing the root bones
  67949. */
  67950. getChildren(): Array<Bone>;
  67951. /**
  67952. * Sets the parent bone
  67953. * @param parent defines the parent (can be null if the bone is the root)
  67954. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67955. */
  67956. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67957. /**
  67958. * Gets the local matrix
  67959. * @returns a matrix
  67960. */
  67961. getLocalMatrix(): Matrix;
  67962. /**
  67963. * Gets the base matrix (initial matrix which remains unchanged)
  67964. * @returns a matrix
  67965. */
  67966. getBaseMatrix(): Matrix;
  67967. /**
  67968. * Gets the rest pose matrix
  67969. * @returns a matrix
  67970. */
  67971. getRestPose(): Matrix;
  67972. /**
  67973. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67974. */
  67975. getWorldMatrix(): Matrix;
  67976. /**
  67977. * Sets the local matrix to rest pose matrix
  67978. */
  67979. returnToRest(): void;
  67980. /**
  67981. * Gets the inverse of the absolute transform matrix.
  67982. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67983. * @returns a matrix
  67984. */
  67985. getInvertedAbsoluteTransform(): Matrix;
  67986. /**
  67987. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67988. * @returns a matrix
  67989. */
  67990. getAbsoluteTransform(): Matrix;
  67991. /**
  67992. * Links with the given transform node.
  67993. * The local matrix of this bone is copied from the transform node every frame.
  67994. * @param transformNode defines the transform node to link to
  67995. */
  67996. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67997. /** Gets or sets current position (in local space) */
  67998. position: Vector3;
  67999. /** Gets or sets current rotation (in local space) */
  68000. rotation: Vector3;
  68001. /** Gets or sets current rotation quaternion (in local space) */
  68002. rotationQuaternion: Quaternion;
  68003. /** Gets or sets current scaling (in local space) */
  68004. scaling: Vector3;
  68005. /**
  68006. * Gets the animation properties override
  68007. */
  68008. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  68009. private _decompose;
  68010. private _compose;
  68011. /**
  68012. * Update the base and local matrices
  68013. * @param matrix defines the new base or local matrix
  68014. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68015. * @param updateLocalMatrix defines if the local matrix should be updated
  68016. */
  68017. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  68018. /** @hidden */
  68019. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  68020. /**
  68021. * Flag the bone as dirty (Forcing it to update everything)
  68022. */
  68023. markAsDirty(): void;
  68024. private _markAsDirtyAndCompose;
  68025. private _markAsDirtyAndDecompose;
  68026. /**
  68027. * Translate the bone in local or world space
  68028. * @param vec The amount to translate the bone
  68029. * @param space The space that the translation is in
  68030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68031. */
  68032. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68033. /**
  68034. * Set the postion of the bone in local or world space
  68035. * @param position The position to set the bone
  68036. * @param space The space that the position is in
  68037. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68038. */
  68039. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68040. /**
  68041. * Set the absolute position of the bone (world space)
  68042. * @param position The position to set the bone
  68043. * @param mesh The mesh that this bone is attached to
  68044. */
  68045. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  68046. /**
  68047. * Scale the bone on the x, y and z axes (in local space)
  68048. * @param x The amount to scale the bone on the x axis
  68049. * @param y The amount to scale the bone on the y axis
  68050. * @param z The amount to scale the bone on the z axis
  68051. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  68052. */
  68053. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  68054. /**
  68055. * Set the bone scaling in local space
  68056. * @param scale defines the scaling vector
  68057. */
  68058. setScale(scale: Vector3): void;
  68059. /**
  68060. * Gets the current scaling in local space
  68061. * @returns the current scaling vector
  68062. */
  68063. getScale(): Vector3;
  68064. /**
  68065. * Gets the current scaling in local space and stores it in a target vector
  68066. * @param result defines the target vector
  68067. */
  68068. getScaleToRef(result: Vector3): void;
  68069. /**
  68070. * Set the yaw, pitch, and roll of the bone in local or world space
  68071. * @param yaw The rotation of the bone on the y axis
  68072. * @param pitch The rotation of the bone on the x axis
  68073. * @param roll The rotation of the bone on the z axis
  68074. * @param space The space that the axes of rotation are in
  68075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68076. */
  68077. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  68078. /**
  68079. * Add a rotation to the bone on an axis in local or world space
  68080. * @param axis The axis to rotate the bone on
  68081. * @param amount The amount to rotate the bone
  68082. * @param space The space that the axis is in
  68083. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68084. */
  68085. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  68086. /**
  68087. * Set the rotation of the bone to a particular axis angle in local or world space
  68088. * @param axis The axis to rotate the bone on
  68089. * @param angle The angle that the bone should be rotated to
  68090. * @param space The space that the axis is in
  68091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68092. */
  68093. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  68094. /**
  68095. * Set the euler rotation of the bone in local of world space
  68096. * @param rotation The euler rotation that the bone should be set to
  68097. * @param space The space that the rotation is in
  68098. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68099. */
  68100. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68101. /**
  68102. * Set the quaternion rotation of the bone in local of world space
  68103. * @param quat The quaternion rotation that the bone should be set to
  68104. * @param space The space that the rotation is in
  68105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68106. */
  68107. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  68108. /**
  68109. * Set the rotation matrix of the bone in local of world space
  68110. * @param rotMat The rotation matrix that the bone should be set to
  68111. * @param space The space that the rotation is in
  68112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68113. */
  68114. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  68115. private _rotateWithMatrix;
  68116. private _getNegativeRotationToRef;
  68117. /**
  68118. * Get the position of the bone in local or world space
  68119. * @param space The space that the returned position is in
  68120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68121. * @returns The position of the bone
  68122. */
  68123. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68124. /**
  68125. * Copy the position of the bone to a vector3 in local or world space
  68126. * @param space The space that the returned position is in
  68127. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68128. * @param result The vector3 to copy the position to
  68129. */
  68130. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  68131. /**
  68132. * Get the absolute position of the bone (world space)
  68133. * @param mesh The mesh that this bone is attached to
  68134. * @returns The absolute position of the bone
  68135. */
  68136. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  68137. /**
  68138. * Copy the absolute position of the bone (world space) to the result param
  68139. * @param mesh The mesh that this bone is attached to
  68140. * @param result The vector3 to copy the absolute position to
  68141. */
  68142. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  68143. /**
  68144. * Compute the absolute transforms of this bone and its children
  68145. */
  68146. computeAbsoluteTransforms(): void;
  68147. /**
  68148. * Get the world direction from an axis that is in the local space of the bone
  68149. * @param localAxis The local direction that is used to compute the world direction
  68150. * @param mesh The mesh that this bone is attached to
  68151. * @returns The world direction
  68152. */
  68153. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68154. /**
  68155. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  68156. * @param localAxis The local direction that is used to compute the world direction
  68157. * @param mesh The mesh that this bone is attached to
  68158. * @param result The vector3 that the world direction will be copied to
  68159. */
  68160. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68161. /**
  68162. * Get the euler rotation of the bone in local or world space
  68163. * @param space The space that the rotation should be in
  68164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68165. * @returns The euler rotation
  68166. */
  68167. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68168. /**
  68169. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  68170. * @param space The space that the rotation should be in
  68171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68172. * @param result The vector3 that the rotation should be copied to
  68173. */
  68174. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68175. /**
  68176. * Get the quaternion rotation of the bone in either local or world space
  68177. * @param space The space that the rotation should be in
  68178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68179. * @returns The quaternion rotation
  68180. */
  68181. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  68182. /**
  68183. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  68184. * @param space The space that the rotation should be in
  68185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68186. * @param result The quaternion that the rotation should be copied to
  68187. */
  68188. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  68189. /**
  68190. * Get the rotation matrix of the bone in local or world space
  68191. * @param space The space that the rotation should be in
  68192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68193. * @returns The rotation matrix
  68194. */
  68195. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  68196. /**
  68197. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  68198. * @param space The space that the rotation should be in
  68199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68200. * @param result The quaternion that the rotation should be copied to
  68201. */
  68202. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  68203. /**
  68204. * Get the world position of a point that is in the local space of the bone
  68205. * @param position The local position
  68206. * @param mesh The mesh that this bone is attached to
  68207. * @returns The world position
  68208. */
  68209. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68210. /**
  68211. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  68212. * @param position The local position
  68213. * @param mesh The mesh that this bone is attached to
  68214. * @param result The vector3 that the world position should be copied to
  68215. */
  68216. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68217. /**
  68218. * Get the local position of a point that is in world space
  68219. * @param position The world position
  68220. * @param mesh The mesh that this bone is attached to
  68221. * @returns The local position
  68222. */
  68223. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68224. /**
  68225. * Get the local position of a point that is in world space and copy it to the result param
  68226. * @param position The world position
  68227. * @param mesh The mesh that this bone is attached to
  68228. * @param result The vector3 that the local position should be copied to
  68229. */
  68230. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68231. }
  68232. }
  68233. declare module BABYLON {
  68234. /**
  68235. * Enum that determines the text-wrapping mode to use.
  68236. */
  68237. export enum InspectableType {
  68238. /**
  68239. * Checkbox for booleans
  68240. */
  68241. Checkbox = 0,
  68242. /**
  68243. * Sliders for numbers
  68244. */
  68245. Slider = 1,
  68246. /**
  68247. * Vector3
  68248. */
  68249. Vector3 = 2,
  68250. /**
  68251. * Quaternions
  68252. */
  68253. Quaternion = 3,
  68254. /**
  68255. * Color3
  68256. */
  68257. Color3 = 4
  68258. }
  68259. /**
  68260. * Interface used to define custom inspectable properties.
  68261. * This interface is used by the inspector to display custom property grids
  68262. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68263. */
  68264. export interface IInspectable {
  68265. /**
  68266. * Gets the label to display
  68267. */
  68268. label: string;
  68269. /**
  68270. * Gets the name of the property to edit
  68271. */
  68272. propertyName: string;
  68273. /**
  68274. * Gets the type of the editor to use
  68275. */
  68276. type: InspectableType;
  68277. /**
  68278. * Gets the minimum value of the property when using in "slider" mode
  68279. */
  68280. min?: number;
  68281. /**
  68282. * Gets the maximum value of the property when using in "slider" mode
  68283. */
  68284. max?: number;
  68285. /**
  68286. * Gets the setp to use when using in "slider" mode
  68287. */
  68288. step?: number;
  68289. }
  68290. }
  68291. declare module BABYLON {
  68292. /**
  68293. * This represents the required contract to create a new type of texture loader.
  68294. */
  68295. export interface IInternalTextureLoader {
  68296. /**
  68297. * Defines wether the loader supports cascade loading the different faces.
  68298. */
  68299. supportCascades: boolean;
  68300. /**
  68301. * This returns if the loader support the current file information.
  68302. * @param extension defines the file extension of the file being loaded
  68303. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68304. * @param fallback defines the fallback internal texture if any
  68305. * @param isBase64 defines whether the texture is encoded as a base64
  68306. * @param isBuffer defines whether the texture data are stored as a buffer
  68307. * @returns true if the loader can load the specified file
  68308. */
  68309. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68310. /**
  68311. * Transform the url before loading if required.
  68312. * @param rootUrl the url of the texture
  68313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68314. * @returns the transformed texture
  68315. */
  68316. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68317. /**
  68318. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68319. * @param rootUrl the url of the texture
  68320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68321. * @returns the fallback texture
  68322. */
  68323. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68324. /**
  68325. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68326. * @param data contains the texture data
  68327. * @param texture defines the BabylonJS internal texture
  68328. * @param createPolynomials will be true if polynomials have been requested
  68329. * @param onLoad defines the callback to trigger once the texture is ready
  68330. * @param onError defines the callback to trigger in case of error
  68331. */
  68332. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68333. /**
  68334. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68335. * @param data contains the texture data
  68336. * @param texture defines the BabylonJS internal texture
  68337. * @param callback defines the method to call once ready to upload
  68338. */
  68339. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68340. }
  68341. }
  68342. declare module BABYLON {
  68343. interface Engine {
  68344. /**
  68345. * Creates a depth stencil cube texture.
  68346. * This is only available in WebGL 2.
  68347. * @param size The size of face edge in the cube texture.
  68348. * @param options The options defining the cube texture.
  68349. * @returns The cube texture
  68350. */
  68351. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68352. /**
  68353. * Creates a cube texture
  68354. * @param rootUrl defines the url where the files to load is located
  68355. * @param scene defines the current scene
  68356. * @param files defines the list of files to load (1 per face)
  68357. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68358. * @param onLoad defines an optional callback raised when the texture is loaded
  68359. * @param onError defines an optional callback raised if there is an issue to load the texture
  68360. * @param format defines the format of the data
  68361. * @param forcedExtension defines the extension to use to pick the right loader
  68362. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68363. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68364. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68365. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68366. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68367. * @returns the cube texture as an InternalTexture
  68368. */
  68369. 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;
  68370. /**
  68371. * Creates a cube texture
  68372. * @param rootUrl defines the url where the files to load is located
  68373. * @param scene defines the current scene
  68374. * @param files defines the list of files to load (1 per face)
  68375. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68376. * @param onLoad defines an optional callback raised when the texture is loaded
  68377. * @param onError defines an optional callback raised if there is an issue to load the texture
  68378. * @param format defines the format of the data
  68379. * @param forcedExtension defines the extension to use to pick the right loader
  68380. * @returns the cube texture as an InternalTexture
  68381. */
  68382. 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;
  68383. /**
  68384. * Creates a cube texture
  68385. * @param rootUrl defines the url where the files to load is located
  68386. * @param scene defines the current scene
  68387. * @param files defines the list of files to load (1 per face)
  68388. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68389. * @param onLoad defines an optional callback raised when the texture is loaded
  68390. * @param onError defines an optional callback raised if there is an issue to load the texture
  68391. * @param format defines the format of the data
  68392. * @param forcedExtension defines the extension to use to pick the right loader
  68393. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68394. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68395. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68396. * @returns the cube texture as an InternalTexture
  68397. */
  68398. 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;
  68399. /** @hidden */
  68400. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68401. /** @hidden */
  68402. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68403. /** @hidden */
  68404. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68405. /** @hidden */
  68406. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68407. }
  68408. }
  68409. declare module BABYLON {
  68410. /**
  68411. * Class for creating a cube texture
  68412. */
  68413. export class CubeTexture extends BaseTexture {
  68414. private _delayedOnLoad;
  68415. /**
  68416. * The url of the texture
  68417. */
  68418. url: string;
  68419. /**
  68420. * Gets or sets the center of the bounding box associated with the cube texture.
  68421. * It must define where the camera used to render the texture was set
  68422. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68423. */
  68424. boundingBoxPosition: Vector3;
  68425. private _boundingBoxSize;
  68426. /**
  68427. * Gets or sets the size of the bounding box associated with the cube texture
  68428. * When defined, the cubemap will switch to local mode
  68429. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68430. * @example https://www.babylonjs-playground.com/#RNASML
  68431. */
  68432. /**
  68433. * Returns the bounding box size
  68434. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68435. */
  68436. boundingBoxSize: Vector3;
  68437. protected _rotationY: number;
  68438. /**
  68439. * Sets texture matrix rotation angle around Y axis in radians.
  68440. */
  68441. /**
  68442. * Gets texture matrix rotation angle around Y axis radians.
  68443. */
  68444. rotationY: number;
  68445. /**
  68446. * Are mip maps generated for this texture or not.
  68447. */
  68448. readonly noMipmap: boolean;
  68449. private _noMipmap;
  68450. private _files;
  68451. private _extensions;
  68452. private _textureMatrix;
  68453. private _format;
  68454. private _createPolynomials;
  68455. /** @hidden */
  68456. _prefiltered: boolean;
  68457. /**
  68458. * Creates a cube texture from an array of image urls
  68459. * @param files defines an array of image urls
  68460. * @param scene defines the hosting scene
  68461. * @param noMipmap specifies if mip maps are not used
  68462. * @returns a cube texture
  68463. */
  68464. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68465. /**
  68466. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68467. * @param url defines the url of the prefiltered texture
  68468. * @param scene defines the scene the texture is attached to
  68469. * @param forcedExtension defines the extension of the file if different from the url
  68470. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68471. * @return the prefiltered texture
  68472. */
  68473. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68474. /**
  68475. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68476. * as prefiltered data.
  68477. * @param rootUrl defines the url of the texture or the root name of the six images
  68478. * @param scene defines the scene the texture is attached to
  68479. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68480. * @param noMipmap defines if mipmaps should be created or not
  68481. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68482. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68483. * @param onError defines a callback triggered in case of error during load
  68484. * @param format defines the internal format to use for the texture once loaded
  68485. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68486. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68487. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68488. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68489. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68490. * @return the cube texture
  68491. */
  68492. 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);
  68493. /**
  68494. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  68495. */
  68496. readonly isPrefiltered: boolean;
  68497. /**
  68498. * Get the current class name of the texture useful for serialization or dynamic coding.
  68499. * @returns "CubeTexture"
  68500. */
  68501. getClassName(): string;
  68502. /**
  68503. * Update the url (and optional buffer) of this texture if url was null during construction.
  68504. * @param url the url of the texture
  68505. * @param forcedExtension defines the extension to use
  68506. * @param onLoad callback called when the texture is loaded (defaults to null)
  68507. */
  68508. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68509. /**
  68510. * Delays loading of the cube texture
  68511. * @param forcedExtension defines the extension to use
  68512. */
  68513. delayLoad(forcedExtension?: string): void;
  68514. /**
  68515. * Returns the reflection texture matrix
  68516. * @returns the reflection texture matrix
  68517. */
  68518. getReflectionTextureMatrix(): Matrix;
  68519. /**
  68520. * Sets the reflection texture matrix
  68521. * @param value Reflection texture matrix
  68522. */
  68523. setReflectionTextureMatrix(value: Matrix): void;
  68524. /**
  68525. * Parses text to create a cube texture
  68526. * @param parsedTexture define the serialized text to read from
  68527. * @param scene defines the hosting scene
  68528. * @param rootUrl defines the root url of the cube texture
  68529. * @returns a cube texture
  68530. */
  68531. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68532. /**
  68533. * Makes a clone, or deep copy, of the cube texture
  68534. * @returns a new cube texture
  68535. */
  68536. clone(): CubeTexture;
  68537. }
  68538. }
  68539. declare module BABYLON {
  68540. /** @hidden */
  68541. export var postprocessVertexShader: {
  68542. name: string;
  68543. shader: string;
  68544. };
  68545. }
  68546. declare module BABYLON {
  68547. /**
  68548. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68549. * This is the base of the follow, arc rotate cameras and Free camera
  68550. * @see http://doc.babylonjs.com/features/cameras
  68551. */
  68552. export class TargetCamera extends Camera {
  68553. private static _RigCamTransformMatrix;
  68554. private static _TargetTransformMatrix;
  68555. private static _TargetFocalPoint;
  68556. /**
  68557. * Define the current direction the camera is moving to
  68558. */
  68559. cameraDirection: Vector3;
  68560. /**
  68561. * Define the current rotation the camera is rotating to
  68562. */
  68563. cameraRotation: Vector2;
  68564. /**
  68565. * When set, the up vector of the camera will be updated by the rotation of the camera
  68566. */
  68567. updateUpVectorFromRotation: boolean;
  68568. private _tmpQuaternion;
  68569. /**
  68570. * Define the current rotation of the camera
  68571. */
  68572. rotation: Vector3;
  68573. /**
  68574. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68575. */
  68576. rotationQuaternion: Quaternion;
  68577. /**
  68578. * Define the current speed of the camera
  68579. */
  68580. speed: number;
  68581. /**
  68582. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68583. * around all axis.
  68584. */
  68585. noRotationConstraint: boolean;
  68586. /**
  68587. * Define the current target of the camera as an object or a position.
  68588. */
  68589. lockedTarget: any;
  68590. /** @hidden */
  68591. _currentTarget: Vector3;
  68592. /** @hidden */
  68593. _initialFocalDistance: number;
  68594. /** @hidden */
  68595. _viewMatrix: Matrix;
  68596. /** @hidden */
  68597. _camMatrix: Matrix;
  68598. /** @hidden */
  68599. _cameraTransformMatrix: Matrix;
  68600. /** @hidden */
  68601. _cameraRotationMatrix: Matrix;
  68602. /** @hidden */
  68603. _referencePoint: Vector3;
  68604. /** @hidden */
  68605. _transformedReferencePoint: Vector3;
  68606. protected _globalCurrentTarget: Vector3;
  68607. protected _globalCurrentUpVector: Vector3;
  68608. /** @hidden */
  68609. _reset: () => void;
  68610. private _defaultUp;
  68611. /**
  68612. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68613. * This is the base of the follow, arc rotate cameras and Free camera
  68614. * @see http://doc.babylonjs.com/features/cameras
  68615. * @param name Defines the name of the camera in the scene
  68616. * @param position Defines the start position of the camera in the scene
  68617. * @param scene Defines the scene the camera belongs to
  68618. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68619. */
  68620. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68621. /**
  68622. * Gets the position in front of the camera at a given distance.
  68623. * @param distance The distance from the camera we want the position to be
  68624. * @returns the position
  68625. */
  68626. getFrontPosition(distance: number): Vector3;
  68627. /** @hidden */
  68628. _getLockedTargetPosition(): Nullable<Vector3>;
  68629. private _storedPosition;
  68630. private _storedRotation;
  68631. private _storedRotationQuaternion;
  68632. /**
  68633. * Store current camera state of the camera (fov, position, rotation, etc..)
  68634. * @returns the camera
  68635. */
  68636. storeState(): Camera;
  68637. /**
  68638. * Restored camera state. You must call storeState() first
  68639. * @returns whether it was successful or not
  68640. * @hidden
  68641. */
  68642. _restoreStateValues(): boolean;
  68643. /** @hidden */
  68644. _initCache(): void;
  68645. /** @hidden */
  68646. _updateCache(ignoreParentClass?: boolean): void;
  68647. /** @hidden */
  68648. _isSynchronizedViewMatrix(): boolean;
  68649. /** @hidden */
  68650. _computeLocalCameraSpeed(): number;
  68651. /**
  68652. * Defines the target the camera should look at.
  68653. * This will automatically adapt alpha beta and radius to fit within the new target.
  68654. * @param target Defines the new target as a Vector or a mesh
  68655. */
  68656. setTarget(target: Vector3): void;
  68657. /**
  68658. * Return the current target position of the camera. This value is expressed in local space.
  68659. * @returns the target position
  68660. */
  68661. getTarget(): Vector3;
  68662. /** @hidden */
  68663. _decideIfNeedsToMove(): boolean;
  68664. /** @hidden */
  68665. _updatePosition(): void;
  68666. /** @hidden */
  68667. _checkInputs(): void;
  68668. protected _updateCameraRotationMatrix(): void;
  68669. /**
  68670. * 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)
  68671. * @returns the current camera
  68672. */
  68673. private _rotateUpVectorWithCameraRotationMatrix;
  68674. private _cachedRotationZ;
  68675. private _cachedQuaternionRotationZ;
  68676. /** @hidden */
  68677. _getViewMatrix(): Matrix;
  68678. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68679. /**
  68680. * @hidden
  68681. */
  68682. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68683. /**
  68684. * @hidden
  68685. */
  68686. _updateRigCameras(): void;
  68687. private _getRigCamPositionAndTarget;
  68688. /**
  68689. * Gets the current object class name.
  68690. * @return the class name
  68691. */
  68692. getClassName(): string;
  68693. }
  68694. }
  68695. declare module BABYLON {
  68696. /**
  68697. * @ignore
  68698. * This is a list of all the different input types that are available in the application.
  68699. * Fo instance: ArcRotateCameraGamepadInput...
  68700. */
  68701. export var CameraInputTypes: {};
  68702. /**
  68703. * This is the contract to implement in order to create a new input class.
  68704. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68705. */
  68706. export interface ICameraInput<TCamera extends Camera> {
  68707. /**
  68708. * Defines the camera the input is attached to.
  68709. */
  68710. camera: Nullable<TCamera>;
  68711. /**
  68712. * Gets the class name of the current intput.
  68713. * @returns the class name
  68714. */
  68715. getClassName(): string;
  68716. /**
  68717. * Get the friendly name associated with the input class.
  68718. * @returns the input friendly name
  68719. */
  68720. getSimpleName(): string;
  68721. /**
  68722. * Attach the input controls to a specific dom element to get the input from.
  68723. * @param element Defines the element the controls should be listened from
  68724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68725. */
  68726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68727. /**
  68728. * Detach the current controls from the specified dom element.
  68729. * @param element Defines the element to stop listening the inputs from
  68730. */
  68731. detachControl(element: Nullable<HTMLElement>): void;
  68732. /**
  68733. * Update the current camera state depending on the inputs that have been used this frame.
  68734. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68735. */
  68736. checkInputs?: () => void;
  68737. }
  68738. /**
  68739. * Represents a map of input types to input instance or input index to input instance.
  68740. */
  68741. export interface CameraInputsMap<TCamera extends Camera> {
  68742. /**
  68743. * Accessor to the input by input type.
  68744. */
  68745. [name: string]: ICameraInput<TCamera>;
  68746. /**
  68747. * Accessor to the input by input index.
  68748. */
  68749. [idx: number]: ICameraInput<TCamera>;
  68750. }
  68751. /**
  68752. * This represents the input manager used within a camera.
  68753. * It helps dealing with all the different kind of input attached to a camera.
  68754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68755. */
  68756. export class CameraInputsManager<TCamera extends Camera> {
  68757. /**
  68758. * Defines the list of inputs attahed to the camera.
  68759. */
  68760. attached: CameraInputsMap<TCamera>;
  68761. /**
  68762. * Defines the dom element the camera is collecting inputs from.
  68763. * This is null if the controls have not been attached.
  68764. */
  68765. attachedElement: Nullable<HTMLElement>;
  68766. /**
  68767. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68768. */
  68769. noPreventDefault: boolean;
  68770. /**
  68771. * Defined the camera the input manager belongs to.
  68772. */
  68773. camera: TCamera;
  68774. /**
  68775. * Update the current camera state depending on the inputs that have been used this frame.
  68776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68777. */
  68778. checkInputs: () => void;
  68779. /**
  68780. * Instantiate a new Camera Input Manager.
  68781. * @param camera Defines the camera the input manager blongs to
  68782. */
  68783. constructor(camera: TCamera);
  68784. /**
  68785. * Add an input method to a camera
  68786. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68787. * @param input camera input method
  68788. */
  68789. add(input: ICameraInput<TCamera>): void;
  68790. /**
  68791. * Remove a specific input method from a camera
  68792. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68793. * @param inputToRemove camera input method
  68794. */
  68795. remove(inputToRemove: ICameraInput<TCamera>): void;
  68796. /**
  68797. * Remove a specific input type from a camera
  68798. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68799. * @param inputType the type of the input to remove
  68800. */
  68801. removeByType(inputType: string): void;
  68802. private _addCheckInputs;
  68803. /**
  68804. * Attach the input controls to the currently attached dom element to listen the events from.
  68805. * @param input Defines the input to attach
  68806. */
  68807. attachInput(input: ICameraInput<TCamera>): void;
  68808. /**
  68809. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68810. * @param element Defines the dom element to collect the events from
  68811. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68812. */
  68813. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68814. /**
  68815. * Detach the current manager inputs controls from a specific dom element.
  68816. * @param element Defines the dom element to collect the events from
  68817. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68818. */
  68819. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68820. /**
  68821. * Rebuild the dynamic inputCheck function from the current list of
  68822. * defined inputs in the manager.
  68823. */
  68824. rebuildInputCheck(): void;
  68825. /**
  68826. * Remove all attached input methods from a camera
  68827. */
  68828. clear(): void;
  68829. /**
  68830. * Serialize the current input manager attached to a camera.
  68831. * This ensures than once parsed,
  68832. * the input associated to the camera will be identical to the current ones
  68833. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68834. */
  68835. serialize(serializedCamera: any): void;
  68836. /**
  68837. * Parses an input manager serialized JSON to restore the previous list of inputs
  68838. * and states associated to a camera.
  68839. * @param parsedCamera Defines the JSON to parse
  68840. */
  68841. parse(parsedCamera: any): void;
  68842. }
  68843. }
  68844. declare module BABYLON {
  68845. /**
  68846. * Gather the list of keyboard event types as constants.
  68847. */
  68848. export class KeyboardEventTypes {
  68849. /**
  68850. * The keydown event is fired when a key becomes active (pressed).
  68851. */
  68852. static readonly KEYDOWN: number;
  68853. /**
  68854. * The keyup event is fired when a key has been released.
  68855. */
  68856. static readonly KEYUP: number;
  68857. }
  68858. /**
  68859. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68860. */
  68861. export class KeyboardInfo {
  68862. /**
  68863. * Defines the type of event (KeyboardEventTypes)
  68864. */
  68865. type: number;
  68866. /**
  68867. * Defines the related dom event
  68868. */
  68869. event: KeyboardEvent;
  68870. /**
  68871. * Instantiates a new keyboard info.
  68872. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68873. * @param type Defines the type of event (KeyboardEventTypes)
  68874. * @param event Defines the related dom event
  68875. */
  68876. constructor(
  68877. /**
  68878. * Defines the type of event (KeyboardEventTypes)
  68879. */
  68880. type: number,
  68881. /**
  68882. * Defines the related dom event
  68883. */
  68884. event: KeyboardEvent);
  68885. }
  68886. /**
  68887. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68888. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68889. */
  68890. export class KeyboardInfoPre extends KeyboardInfo {
  68891. /**
  68892. * Defines the type of event (KeyboardEventTypes)
  68893. */
  68894. type: number;
  68895. /**
  68896. * Defines the related dom event
  68897. */
  68898. event: KeyboardEvent;
  68899. /**
  68900. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68901. */
  68902. skipOnPointerObservable: boolean;
  68903. /**
  68904. * Instantiates a new keyboard pre info.
  68905. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68906. * @param type Defines the type of event (KeyboardEventTypes)
  68907. * @param event Defines the related dom event
  68908. */
  68909. constructor(
  68910. /**
  68911. * Defines the type of event (KeyboardEventTypes)
  68912. */
  68913. type: number,
  68914. /**
  68915. * Defines the related dom event
  68916. */
  68917. event: KeyboardEvent);
  68918. }
  68919. }
  68920. declare module BABYLON {
  68921. /**
  68922. * Manage the keyboard inputs to control the movement of a free camera.
  68923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68924. */
  68925. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68926. /**
  68927. * Defines the camera the input is attached to.
  68928. */
  68929. camera: FreeCamera;
  68930. /**
  68931. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68932. */
  68933. keysUp: number[];
  68934. /**
  68935. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68936. */
  68937. keysDown: number[];
  68938. /**
  68939. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68940. */
  68941. keysLeft: number[];
  68942. /**
  68943. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68944. */
  68945. keysRight: number[];
  68946. private _keys;
  68947. private _onCanvasBlurObserver;
  68948. private _onKeyboardObserver;
  68949. private _engine;
  68950. private _scene;
  68951. /**
  68952. * Attach the input controls to a specific dom element to get the input from.
  68953. * @param element Defines the element the controls should be listened from
  68954. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68955. */
  68956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68957. /**
  68958. * Detach the current controls from the specified dom element.
  68959. * @param element Defines the element to stop listening the inputs from
  68960. */
  68961. detachControl(element: Nullable<HTMLElement>): void;
  68962. /**
  68963. * Update the current camera state depending on the inputs that have been used this frame.
  68964. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68965. */
  68966. checkInputs(): void;
  68967. /**
  68968. * Gets the class name of the current intput.
  68969. * @returns the class name
  68970. */
  68971. getClassName(): string;
  68972. /** @hidden */
  68973. _onLostFocus(): void;
  68974. /**
  68975. * Get the friendly name associated with the input class.
  68976. * @returns the input friendly name
  68977. */
  68978. getSimpleName(): string;
  68979. }
  68980. }
  68981. declare module BABYLON {
  68982. /**
  68983. * Interface describing all the common properties and methods a shadow light needs to implement.
  68984. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68985. * as well as binding the different shadow properties to the effects.
  68986. */
  68987. export interface IShadowLight extends Light {
  68988. /**
  68989. * The light id in the scene (used in scene.findLighById for instance)
  68990. */
  68991. id: string;
  68992. /**
  68993. * The position the shdow will be casted from.
  68994. */
  68995. position: Vector3;
  68996. /**
  68997. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68998. */
  68999. direction: Vector3;
  69000. /**
  69001. * The transformed position. Position of the light in world space taking parenting in account.
  69002. */
  69003. transformedPosition: Vector3;
  69004. /**
  69005. * The transformed direction. Direction of the light in world space taking parenting in account.
  69006. */
  69007. transformedDirection: Vector3;
  69008. /**
  69009. * The friendly name of the light in the scene.
  69010. */
  69011. name: string;
  69012. /**
  69013. * Defines the shadow projection clipping minimum z value.
  69014. */
  69015. shadowMinZ: number;
  69016. /**
  69017. * Defines the shadow projection clipping maximum z value.
  69018. */
  69019. shadowMaxZ: number;
  69020. /**
  69021. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69022. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69023. */
  69024. computeTransformedInformation(): boolean;
  69025. /**
  69026. * Gets the scene the light belongs to.
  69027. * @returns The scene
  69028. */
  69029. getScene(): Scene;
  69030. /**
  69031. * Callback defining a custom Projection Matrix Builder.
  69032. * This can be used to override the default projection matrix computation.
  69033. */
  69034. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69035. /**
  69036. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69037. * @param matrix The materix to updated with the projection information
  69038. * @param viewMatrix The transform matrix of the light
  69039. * @param renderList The list of mesh to render in the map
  69040. * @returns The current light
  69041. */
  69042. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69043. /**
  69044. * Gets the current depth scale used in ESM.
  69045. * @returns The scale
  69046. */
  69047. getDepthScale(): number;
  69048. /**
  69049. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69050. * @returns true if a cube texture needs to be use
  69051. */
  69052. needCube(): boolean;
  69053. /**
  69054. * Detects if the projection matrix requires to be recomputed this frame.
  69055. * @returns true if it requires to be recomputed otherwise, false.
  69056. */
  69057. needProjectionMatrixCompute(): boolean;
  69058. /**
  69059. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69060. */
  69061. forceProjectionMatrixCompute(): void;
  69062. /**
  69063. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69064. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69065. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69066. */
  69067. getShadowDirection(faceIndex?: number): Vector3;
  69068. /**
  69069. * Gets the minZ used for shadow according to both the scene and the light.
  69070. * @param activeCamera The camera we are returning the min for
  69071. * @returns the depth min z
  69072. */
  69073. getDepthMinZ(activeCamera: Camera): number;
  69074. /**
  69075. * Gets the maxZ used for shadow according to both the scene and the light.
  69076. * @param activeCamera The camera we are returning the max for
  69077. * @returns the depth max z
  69078. */
  69079. getDepthMaxZ(activeCamera: Camera): number;
  69080. }
  69081. /**
  69082. * Base implementation IShadowLight
  69083. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  69084. */
  69085. export abstract class ShadowLight extends Light implements IShadowLight {
  69086. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  69087. protected _position: Vector3;
  69088. protected _setPosition(value: Vector3): void;
  69089. /**
  69090. * Sets the position the shadow will be casted from. Also use as the light position for both
  69091. * point and spot lights.
  69092. */
  69093. /**
  69094. * Sets the position the shadow will be casted from. Also use as the light position for both
  69095. * point and spot lights.
  69096. */
  69097. position: Vector3;
  69098. protected _direction: Vector3;
  69099. protected _setDirection(value: Vector3): void;
  69100. /**
  69101. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  69102. * Also use as the light direction on spot and directional lights.
  69103. */
  69104. /**
  69105. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  69106. * Also use as the light direction on spot and directional lights.
  69107. */
  69108. direction: Vector3;
  69109. private _shadowMinZ;
  69110. /**
  69111. * Gets the shadow projection clipping minimum z value.
  69112. */
  69113. /**
  69114. * Sets the shadow projection clipping minimum z value.
  69115. */
  69116. shadowMinZ: number;
  69117. private _shadowMaxZ;
  69118. /**
  69119. * Sets the shadow projection clipping maximum z value.
  69120. */
  69121. /**
  69122. * Gets the shadow projection clipping maximum z value.
  69123. */
  69124. shadowMaxZ: number;
  69125. /**
  69126. * Callback defining a custom Projection Matrix Builder.
  69127. * This can be used to override the default projection matrix computation.
  69128. */
  69129. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69130. /**
  69131. * The transformed position. Position of the light in world space taking parenting in account.
  69132. */
  69133. transformedPosition: Vector3;
  69134. /**
  69135. * The transformed direction. Direction of the light in world space taking parenting in account.
  69136. */
  69137. transformedDirection: Vector3;
  69138. private _needProjectionMatrixCompute;
  69139. /**
  69140. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69141. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69142. */
  69143. computeTransformedInformation(): boolean;
  69144. /**
  69145. * Return the depth scale used for the shadow map.
  69146. * @returns the depth scale.
  69147. */
  69148. getDepthScale(): number;
  69149. /**
  69150. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69151. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69152. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69153. */
  69154. getShadowDirection(faceIndex?: number): Vector3;
  69155. /**
  69156. * Returns the ShadowLight absolute position in the World.
  69157. * @returns the position vector in world space
  69158. */
  69159. getAbsolutePosition(): Vector3;
  69160. /**
  69161. * Sets the ShadowLight direction toward the passed target.
  69162. * @param target The point to target in local space
  69163. * @returns the updated ShadowLight direction
  69164. */
  69165. setDirectionToTarget(target: Vector3): Vector3;
  69166. /**
  69167. * Returns the light rotation in euler definition.
  69168. * @returns the x y z rotation in local space.
  69169. */
  69170. getRotation(): Vector3;
  69171. /**
  69172. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69173. * @returns true if a cube texture needs to be use
  69174. */
  69175. needCube(): boolean;
  69176. /**
  69177. * Detects if the projection matrix requires to be recomputed this frame.
  69178. * @returns true if it requires to be recomputed otherwise, false.
  69179. */
  69180. needProjectionMatrixCompute(): boolean;
  69181. /**
  69182. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69183. */
  69184. forceProjectionMatrixCompute(): void;
  69185. /** @hidden */
  69186. _initCache(): void;
  69187. /** @hidden */
  69188. _isSynchronized(): boolean;
  69189. /**
  69190. * Computes the world matrix of the node
  69191. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69192. * @returns the world matrix
  69193. */
  69194. computeWorldMatrix(force?: boolean): Matrix;
  69195. /**
  69196. * Gets the minZ used for shadow according to both the scene and the light.
  69197. * @param activeCamera The camera we are returning the min for
  69198. * @returns the depth min z
  69199. */
  69200. getDepthMinZ(activeCamera: Camera): number;
  69201. /**
  69202. * Gets the maxZ used for shadow according to both the scene and the light.
  69203. * @param activeCamera The camera we are returning the max for
  69204. * @returns the depth max z
  69205. */
  69206. getDepthMaxZ(activeCamera: Camera): number;
  69207. /**
  69208. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69209. * @param matrix The materix to updated with the projection information
  69210. * @param viewMatrix The transform matrix of the light
  69211. * @param renderList The list of mesh to render in the map
  69212. * @returns The current light
  69213. */
  69214. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69215. }
  69216. }
  69217. declare module BABYLON {
  69218. /**
  69219. * "Static Class" containing the most commonly used helper while dealing with material for
  69220. * rendering purpose.
  69221. *
  69222. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  69223. *
  69224. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  69225. */
  69226. export class MaterialHelper {
  69227. /**
  69228. * Bind the current view position to an effect.
  69229. * @param effect The effect to be bound
  69230. * @param scene The scene the eyes position is used from
  69231. */
  69232. static BindEyePosition(effect: Effect, scene: Scene): void;
  69233. /**
  69234. * Helps preparing the defines values about the UVs in used in the effect.
  69235. * UVs are shared as much as we can accross channels in the shaders.
  69236. * @param texture The texture we are preparing the UVs for
  69237. * @param defines The defines to update
  69238. * @param key The channel key "diffuse", "specular"... used in the shader
  69239. */
  69240. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  69241. /**
  69242. * Binds a texture matrix value to its corrsponding uniform
  69243. * @param texture The texture to bind the matrix for
  69244. * @param uniformBuffer The uniform buffer receivin the data
  69245. * @param key The channel key "diffuse", "specular"... used in the shader
  69246. */
  69247. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  69248. /**
  69249. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  69250. * @param mesh defines the current mesh
  69251. * @param scene defines the current scene
  69252. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  69253. * @param pointsCloud defines if point cloud rendering has to be turned on
  69254. * @param fogEnabled defines if fog has to be turned on
  69255. * @param alphaTest defines if alpha testing has to be turned on
  69256. * @param defines defines the current list of defines
  69257. */
  69258. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  69259. /**
  69260. * Helper used to prepare the list of defines associated with frame values for shader compilation
  69261. * @param scene defines the current scene
  69262. * @param engine defines the current engine
  69263. * @param defines specifies the list of active defines
  69264. * @param useInstances defines if instances have to be turned on
  69265. * @param useClipPlane defines if clip plane have to be turned on
  69266. */
  69267. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  69268. /**
  69269. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  69270. * @param mesh The mesh containing the geometry data we will draw
  69271. * @param defines The defines to update
  69272. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  69273. * @param useBones Precise whether bones should be used or not (override mesh info)
  69274. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  69275. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  69276. * @returns false if defines are considered not dirty and have not been checked
  69277. */
  69278. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  69279. /**
  69280. * Prepares the defines related to multiview
  69281. * @param scene The scene we are intending to draw
  69282. * @param defines The defines to update
  69283. */
  69284. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  69285. /**
  69286. * Prepares the defines related to the light information passed in parameter
  69287. * @param scene The scene we are intending to draw
  69288. * @param mesh The mesh the effect is compiling for
  69289. * @param defines The defines to update
  69290. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  69291. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  69292. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  69293. * @returns true if normals will be required for the rest of the effect
  69294. */
  69295. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  69296. /**
  69297. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  69298. * that won t be acctive due to defines being turned off.
  69299. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  69300. * @param samplersList The samplers list
  69301. * @param defines The defines helping in the list generation
  69302. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  69303. */
  69304. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  69305. /**
  69306. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  69307. * @param defines The defines to update while falling back
  69308. * @param fallbacks The authorized effect fallbacks
  69309. * @param maxSimultaneousLights The maximum number of lights allowed
  69310. * @param rank the current rank of the Effect
  69311. * @returns The newly affected rank
  69312. */
  69313. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  69314. /**
  69315. * Prepares the list of attributes required for morph targets according to the effect defines.
  69316. * @param attribs The current list of supported attribs
  69317. * @param mesh The mesh to prepare the morph targets attributes for
  69318. * @param defines The current Defines of the effect
  69319. */
  69320. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  69321. /**
  69322. * Prepares the list of attributes required for bones according to the effect defines.
  69323. * @param attribs The current list of supported attribs
  69324. * @param mesh The mesh to prepare the bones attributes for
  69325. * @param defines The current Defines of the effect
  69326. * @param fallbacks The current efffect fallback strategy
  69327. */
  69328. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  69329. /**
  69330. * Prepares the list of attributes required for instances according to the effect defines.
  69331. * @param attribs The current list of supported attribs
  69332. * @param defines The current Defines of the effect
  69333. */
  69334. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69335. /**
  69336. * Binds the light shadow information to the effect for the given mesh.
  69337. * @param light The light containing the generator
  69338. * @param scene The scene the lights belongs to
  69339. * @param mesh The mesh we are binding the information to render
  69340. * @param lightIndex The light index in the effect used to render the mesh
  69341. * @param effect The effect we are binding the data to
  69342. */
  69343. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69344. /**
  69345. * Binds the light information to the effect.
  69346. * @param light The light containing the generator
  69347. * @param effect The effect we are binding the data to
  69348. * @param lightIndex The light index in the effect used to render
  69349. */
  69350. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69351. /**
  69352. * Binds the lights information from the scene to the effect for the given mesh.
  69353. * @param scene The scene the lights belongs to
  69354. * @param mesh The mesh we are binding the information to render
  69355. * @param effect The effect we are binding the data to
  69356. * @param defines The generated defines for the effect
  69357. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69358. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69359. */
  69360. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69361. private static _tempFogColor;
  69362. /**
  69363. * Binds the fog information from the scene to the effect for the given mesh.
  69364. * @param scene The scene the lights belongs to
  69365. * @param mesh The mesh we are binding the information to render
  69366. * @param effect The effect we are binding the data to
  69367. * @param linearSpace Defines if the fog effect is applied in linear space
  69368. */
  69369. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69370. /**
  69371. * Binds the bones information from the mesh to the effect.
  69372. * @param mesh The mesh we are binding the information to render
  69373. * @param effect The effect we are binding the data to
  69374. */
  69375. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69376. /**
  69377. * Binds the morph targets information from the mesh to the effect.
  69378. * @param abstractMesh The mesh we are binding the information to render
  69379. * @param effect The effect we are binding the data to
  69380. */
  69381. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69382. /**
  69383. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69384. * @param defines The generated defines used in the effect
  69385. * @param effect The effect we are binding the data to
  69386. * @param scene The scene we are willing to render with logarithmic scale for
  69387. */
  69388. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69389. /**
  69390. * Binds the clip plane information from the scene to the effect.
  69391. * @param scene The scene the clip plane information are extracted from
  69392. * @param effect The effect we are binding the data to
  69393. */
  69394. static BindClipPlane(effect: Effect, scene: Scene): void;
  69395. }
  69396. }
  69397. declare module BABYLON {
  69398. /** @hidden */
  69399. export var kernelBlurVaryingDeclaration: {
  69400. name: string;
  69401. shader: string;
  69402. };
  69403. }
  69404. declare module BABYLON {
  69405. /** @hidden */
  69406. export var kernelBlurFragment: {
  69407. name: string;
  69408. shader: string;
  69409. };
  69410. }
  69411. declare module BABYLON {
  69412. /** @hidden */
  69413. export var kernelBlurFragment2: {
  69414. name: string;
  69415. shader: string;
  69416. };
  69417. }
  69418. declare module BABYLON {
  69419. /** @hidden */
  69420. export var kernelBlurPixelShader: {
  69421. name: string;
  69422. shader: string;
  69423. };
  69424. }
  69425. declare module BABYLON {
  69426. /** @hidden */
  69427. export var kernelBlurVertex: {
  69428. name: string;
  69429. shader: string;
  69430. };
  69431. }
  69432. declare module BABYLON {
  69433. /** @hidden */
  69434. export var kernelBlurVertexShader: {
  69435. name: string;
  69436. shader: string;
  69437. };
  69438. }
  69439. declare module BABYLON {
  69440. /**
  69441. * The Blur Post Process which blurs an image based on a kernel and direction.
  69442. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69443. */
  69444. export class BlurPostProcess extends PostProcess {
  69445. /** The direction in which to blur the image. */
  69446. direction: Vector2;
  69447. private blockCompilation;
  69448. protected _kernel: number;
  69449. protected _idealKernel: number;
  69450. protected _packedFloat: boolean;
  69451. private _staticDefines;
  69452. /**
  69453. * Sets the length in pixels of the blur sample region
  69454. */
  69455. /**
  69456. * Gets the length in pixels of the blur sample region
  69457. */
  69458. kernel: number;
  69459. /**
  69460. * Sets wether or not the blur needs to unpack/repack floats
  69461. */
  69462. /**
  69463. * Gets wether or not the blur is unpacking/repacking floats
  69464. */
  69465. packedFloat: boolean;
  69466. /**
  69467. * Creates a new instance BlurPostProcess
  69468. * @param name The name of the effect.
  69469. * @param direction The direction in which to blur the image.
  69470. * @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.
  69471. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69472. * @param camera The camera to apply the render pass to.
  69473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69474. * @param engine The engine which the post process will be applied. (default: current engine)
  69475. * @param reusable If the post process can be reused on the same frame. (default: false)
  69476. * @param textureType Type of textures used when performing the post process. (default: 0)
  69477. * @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)
  69478. */
  69479. constructor(name: string,
  69480. /** The direction in which to blur the image. */
  69481. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69482. /**
  69483. * Updates the effect with the current post process compile time values and recompiles the shader.
  69484. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69485. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69486. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69487. * @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
  69488. * @param onCompiled Called when the shader has been compiled.
  69489. * @param onError Called if there is an error when compiling a shader.
  69490. */
  69491. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69492. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69493. /**
  69494. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69495. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69496. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69497. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69498. * The gaps between physical kernels are compensated for in the weighting of the samples
  69499. * @param idealKernel Ideal blur kernel.
  69500. * @return Nearest best kernel.
  69501. */
  69502. protected _nearestBestKernel(idealKernel: number): number;
  69503. /**
  69504. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69505. * @param x The point on the Gaussian distribution to sample.
  69506. * @return the value of the Gaussian function at x.
  69507. */
  69508. protected _gaussianWeight(x: number): number;
  69509. /**
  69510. * Generates a string that can be used as a floating point number in GLSL.
  69511. * @param x Value to print.
  69512. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69513. * @return GLSL float string.
  69514. */
  69515. protected _glslFloat(x: number, decimalFigures?: number): string;
  69516. }
  69517. }
  69518. declare module BABYLON {
  69519. /** @hidden */
  69520. export var shadowMapPixelShader: {
  69521. name: string;
  69522. shader: string;
  69523. };
  69524. }
  69525. declare module BABYLON {
  69526. /** @hidden */
  69527. export var bonesDeclaration: {
  69528. name: string;
  69529. shader: string;
  69530. };
  69531. }
  69532. declare module BABYLON {
  69533. /** @hidden */
  69534. export var morphTargetsVertexGlobalDeclaration: {
  69535. name: string;
  69536. shader: string;
  69537. };
  69538. }
  69539. declare module BABYLON {
  69540. /** @hidden */
  69541. export var morphTargetsVertexDeclaration: {
  69542. name: string;
  69543. shader: string;
  69544. };
  69545. }
  69546. declare module BABYLON {
  69547. /** @hidden */
  69548. export var instancesDeclaration: {
  69549. name: string;
  69550. shader: string;
  69551. };
  69552. }
  69553. declare module BABYLON {
  69554. /** @hidden */
  69555. export var helperFunctions: {
  69556. name: string;
  69557. shader: string;
  69558. };
  69559. }
  69560. declare module BABYLON {
  69561. /** @hidden */
  69562. export var morphTargetsVertex: {
  69563. name: string;
  69564. shader: string;
  69565. };
  69566. }
  69567. declare module BABYLON {
  69568. /** @hidden */
  69569. export var instancesVertex: {
  69570. name: string;
  69571. shader: string;
  69572. };
  69573. }
  69574. declare module BABYLON {
  69575. /** @hidden */
  69576. export var bonesVertex: {
  69577. name: string;
  69578. shader: string;
  69579. };
  69580. }
  69581. declare module BABYLON {
  69582. /** @hidden */
  69583. export var shadowMapVertexShader: {
  69584. name: string;
  69585. shader: string;
  69586. };
  69587. }
  69588. declare module BABYLON {
  69589. /** @hidden */
  69590. export var depthBoxBlurPixelShader: {
  69591. name: string;
  69592. shader: string;
  69593. };
  69594. }
  69595. declare module BABYLON {
  69596. /**
  69597. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69598. */
  69599. export interface ICustomShaderOptions {
  69600. /**
  69601. * Gets or sets the custom shader name to use
  69602. */
  69603. shaderName: string;
  69604. /**
  69605. * The list of attribute names used in the shader
  69606. */
  69607. attributes?: string[];
  69608. /**
  69609. * The list of unifrom names used in the shader
  69610. */
  69611. uniforms?: string[];
  69612. /**
  69613. * The list of sampler names used in the shader
  69614. */
  69615. samplers?: string[];
  69616. /**
  69617. * The list of defines used in the shader
  69618. */
  69619. defines?: string[];
  69620. }
  69621. /**
  69622. * Interface to implement to create a shadow generator compatible with BJS.
  69623. */
  69624. export interface IShadowGenerator {
  69625. /**
  69626. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69627. * @returns The render target texture if present otherwise, null
  69628. */
  69629. getShadowMap(): Nullable<RenderTargetTexture>;
  69630. /**
  69631. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69632. * @returns The render target texture if the shadow map is present otherwise, null
  69633. */
  69634. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69635. /**
  69636. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69637. * @param subMesh The submesh we want to render in the shadow map
  69638. * @param useInstances Defines wether will draw in the map using instances
  69639. * @returns true if ready otherwise, false
  69640. */
  69641. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69642. /**
  69643. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69644. * @param defines Defines of the material we want to update
  69645. * @param lightIndex Index of the light in the enabled light list of the material
  69646. */
  69647. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69648. /**
  69649. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69650. * defined in the generator but impacting the effect).
  69651. * It implies the unifroms available on the materials are the standard BJS ones.
  69652. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69653. * @param effect The effect we are binfing the information for
  69654. */
  69655. bindShadowLight(lightIndex: string, effect: Effect): void;
  69656. /**
  69657. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69658. * (eq to shadow prjection matrix * light transform matrix)
  69659. * @returns The transform matrix used to create the shadow map
  69660. */
  69661. getTransformMatrix(): Matrix;
  69662. /**
  69663. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69664. * Cube and 2D textures for instance.
  69665. */
  69666. recreateShadowMap(): void;
  69667. /**
  69668. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69669. * @param onCompiled Callback triggered at the and of the effects compilation
  69670. * @param options Sets of optional options forcing the compilation with different modes
  69671. */
  69672. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69673. useInstances: boolean;
  69674. }>): void;
  69675. /**
  69676. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69677. * @param options Sets of optional options forcing the compilation with different modes
  69678. * @returns A promise that resolves when the compilation completes
  69679. */
  69680. forceCompilationAsync(options?: Partial<{
  69681. useInstances: boolean;
  69682. }>): Promise<void>;
  69683. /**
  69684. * Serializes the shadow generator setup to a json object.
  69685. * @returns The serialized JSON object
  69686. */
  69687. serialize(): any;
  69688. /**
  69689. * Disposes the Shadow map and related Textures and effects.
  69690. */
  69691. dispose(): void;
  69692. }
  69693. /**
  69694. * Default implementation IShadowGenerator.
  69695. * This is the main object responsible of generating shadows in the framework.
  69696. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69697. */
  69698. export class ShadowGenerator implements IShadowGenerator {
  69699. /**
  69700. * Shadow generator mode None: no filtering applied.
  69701. */
  69702. static readonly FILTER_NONE: number;
  69703. /**
  69704. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69705. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69706. */
  69707. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69708. /**
  69709. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69710. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69711. */
  69712. static readonly FILTER_POISSONSAMPLING: number;
  69713. /**
  69714. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69715. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69716. */
  69717. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69718. /**
  69719. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69720. * edge artifacts on steep falloff.
  69721. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69722. */
  69723. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69724. /**
  69725. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69726. * edge artifacts on steep falloff.
  69727. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69728. */
  69729. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69730. /**
  69731. * Shadow generator mode PCF: Percentage Closer Filtering
  69732. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69733. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69734. */
  69735. static readonly FILTER_PCF: number;
  69736. /**
  69737. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69738. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69739. * Contact Hardening
  69740. */
  69741. static readonly FILTER_PCSS: number;
  69742. /**
  69743. * Reserved for PCF and PCSS
  69744. * Highest Quality.
  69745. *
  69746. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69747. *
  69748. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69749. */
  69750. static readonly QUALITY_HIGH: number;
  69751. /**
  69752. * Reserved for PCF and PCSS
  69753. * Good tradeoff for quality/perf cross devices
  69754. *
  69755. * Execute PCF on a 3*3 kernel.
  69756. *
  69757. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69758. */
  69759. static readonly QUALITY_MEDIUM: number;
  69760. /**
  69761. * Reserved for PCF and PCSS
  69762. * The lowest quality but the fastest.
  69763. *
  69764. * Execute PCF on a 1*1 kernel.
  69765. *
  69766. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69767. */
  69768. static readonly QUALITY_LOW: number;
  69769. /** Gets or sets the custom shader name to use */
  69770. customShaderOptions: ICustomShaderOptions;
  69771. /**
  69772. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69773. */
  69774. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69775. /**
  69776. * Observable triggered before a mesh is rendered in the shadow map.
  69777. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69778. */
  69779. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69780. private _bias;
  69781. /**
  69782. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69783. */
  69784. /**
  69785. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69786. */
  69787. bias: number;
  69788. private _normalBias;
  69789. /**
  69790. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69791. */
  69792. /**
  69793. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69794. */
  69795. normalBias: number;
  69796. private _blurBoxOffset;
  69797. /**
  69798. * Gets the blur box offset: offset applied during the blur pass.
  69799. * Only useful if useKernelBlur = false
  69800. */
  69801. /**
  69802. * Sets the blur box offset: offset applied during the blur pass.
  69803. * Only useful if useKernelBlur = false
  69804. */
  69805. blurBoxOffset: number;
  69806. private _blurScale;
  69807. /**
  69808. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69809. * 2 means half of the size.
  69810. */
  69811. /**
  69812. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69813. * 2 means half of the size.
  69814. */
  69815. blurScale: number;
  69816. private _blurKernel;
  69817. /**
  69818. * Gets the blur kernel: kernel size of the blur pass.
  69819. * Only useful if useKernelBlur = true
  69820. */
  69821. /**
  69822. * Sets the blur kernel: kernel size of the blur pass.
  69823. * Only useful if useKernelBlur = true
  69824. */
  69825. blurKernel: number;
  69826. private _useKernelBlur;
  69827. /**
  69828. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69829. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69830. */
  69831. /**
  69832. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69833. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69834. */
  69835. useKernelBlur: boolean;
  69836. private _depthScale;
  69837. /**
  69838. * Gets the depth scale used in ESM mode.
  69839. */
  69840. /**
  69841. * Sets the depth scale used in ESM mode.
  69842. * This can override the scale stored on the light.
  69843. */
  69844. depthScale: number;
  69845. private _filter;
  69846. /**
  69847. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69848. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69849. */
  69850. /**
  69851. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69852. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69853. */
  69854. filter: number;
  69855. /**
  69856. * Gets if the current filter is set to Poisson Sampling.
  69857. */
  69858. /**
  69859. * Sets the current filter to Poisson Sampling.
  69860. */
  69861. usePoissonSampling: boolean;
  69862. /**
  69863. * Gets if the current filter is set to ESM.
  69864. */
  69865. /**
  69866. * Sets the current filter is to ESM.
  69867. */
  69868. useExponentialShadowMap: boolean;
  69869. /**
  69870. * Gets if the current filter is set to filtered ESM.
  69871. */
  69872. /**
  69873. * Gets if the current filter is set to filtered ESM.
  69874. */
  69875. useBlurExponentialShadowMap: boolean;
  69876. /**
  69877. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69878. * exponential to prevent steep falloff artifacts).
  69879. */
  69880. /**
  69881. * Sets the current filter to "close ESM" (using the inverse of the
  69882. * exponential to prevent steep falloff artifacts).
  69883. */
  69884. useCloseExponentialShadowMap: boolean;
  69885. /**
  69886. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69887. * exponential to prevent steep falloff artifacts).
  69888. */
  69889. /**
  69890. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69891. * exponential to prevent steep falloff artifacts).
  69892. */
  69893. useBlurCloseExponentialShadowMap: boolean;
  69894. /**
  69895. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69896. */
  69897. /**
  69898. * Sets the current filter to "PCF" (percentage closer filtering).
  69899. */
  69900. usePercentageCloserFiltering: boolean;
  69901. private _filteringQuality;
  69902. /**
  69903. * Gets the PCF or PCSS Quality.
  69904. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69905. */
  69906. /**
  69907. * Sets the PCF or PCSS Quality.
  69908. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69909. */
  69910. filteringQuality: number;
  69911. /**
  69912. * Gets if the current filter is set to "PCSS" (contact hardening).
  69913. */
  69914. /**
  69915. * Sets the current filter to "PCSS" (contact hardening).
  69916. */
  69917. useContactHardeningShadow: boolean;
  69918. private _contactHardeningLightSizeUVRatio;
  69919. /**
  69920. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69921. * Using a ratio helps keeping shape stability independently of the map size.
  69922. *
  69923. * It does not account for the light projection as it was having too much
  69924. * instability during the light setup or during light position changes.
  69925. *
  69926. * Only valid if useContactHardeningShadow is true.
  69927. */
  69928. /**
  69929. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69930. * Using a ratio helps keeping shape stability independently of the map size.
  69931. *
  69932. * It does not account for the light projection as it was having too much
  69933. * instability during the light setup or during light position changes.
  69934. *
  69935. * Only valid if useContactHardeningShadow is true.
  69936. */
  69937. contactHardeningLightSizeUVRatio: number;
  69938. private _darkness;
  69939. /**
  69940. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69941. * 0 means strongest and 1 would means no shadow.
  69942. * @returns the darkness.
  69943. */
  69944. getDarkness(): number;
  69945. /**
  69946. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69947. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69948. * @returns the shadow generator allowing fluent coding.
  69949. */
  69950. setDarkness(darkness: number): ShadowGenerator;
  69951. private _transparencyShadow;
  69952. /**
  69953. * Sets the ability to have transparent shadow (boolean).
  69954. * @param transparent True if transparent else False
  69955. * @returns the shadow generator allowing fluent coding
  69956. */
  69957. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69958. private _shadowMap;
  69959. private _shadowMap2;
  69960. /**
  69961. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69962. * @returns The render target texture if present otherwise, null
  69963. */
  69964. getShadowMap(): Nullable<RenderTargetTexture>;
  69965. /**
  69966. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69967. * @returns The render target texture if the shadow map is present otherwise, null
  69968. */
  69969. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69970. /**
  69971. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69972. * @param mesh Mesh to add
  69973. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69974. * @returns the Shadow Generator itself
  69975. */
  69976. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69977. /**
  69978. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69979. * @param mesh Mesh to remove
  69980. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69981. * @returns the Shadow Generator itself
  69982. */
  69983. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69984. /**
  69985. * Controls the extent to which the shadows fade out at the edge of the frustum
  69986. * Used only by directionals and spots
  69987. */
  69988. frustumEdgeFalloff: number;
  69989. private _light;
  69990. /**
  69991. * Returns the associated light object.
  69992. * @returns the light generating the shadow
  69993. */
  69994. getLight(): IShadowLight;
  69995. /**
  69996. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69997. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69998. * It might on the other hand introduce peter panning.
  69999. */
  70000. forceBackFacesOnly: boolean;
  70001. private _scene;
  70002. private _lightDirection;
  70003. private _effect;
  70004. private _viewMatrix;
  70005. private _projectionMatrix;
  70006. private _transformMatrix;
  70007. private _cachedPosition;
  70008. private _cachedDirection;
  70009. private _cachedDefines;
  70010. private _currentRenderID;
  70011. private _boxBlurPostprocess;
  70012. private _kernelBlurXPostprocess;
  70013. private _kernelBlurYPostprocess;
  70014. private _blurPostProcesses;
  70015. private _mapSize;
  70016. private _currentFaceIndex;
  70017. private _currentFaceIndexCache;
  70018. private _textureType;
  70019. private _defaultTextureMatrix;
  70020. /** @hidden */
  70021. static _SceneComponentInitialization: (scene: Scene) => void;
  70022. /**
  70023. * Creates a ShadowGenerator object.
  70024. * A ShadowGenerator is the required tool to use the shadows.
  70025. * Each light casting shadows needs to use its own ShadowGenerator.
  70026. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  70027. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  70028. * @param light The light object generating the shadows.
  70029. * @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.
  70030. */
  70031. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  70032. private _initializeGenerator;
  70033. private _initializeShadowMap;
  70034. private _initializeBlurRTTAndPostProcesses;
  70035. private _renderForShadowMap;
  70036. private _renderSubMeshForShadowMap;
  70037. private _applyFilterValues;
  70038. /**
  70039. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70040. * @param onCompiled Callback triggered at the and of the effects compilation
  70041. * @param options Sets of optional options forcing the compilation with different modes
  70042. */
  70043. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  70044. useInstances: boolean;
  70045. }>): void;
  70046. /**
  70047. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70048. * @param options Sets of optional options forcing the compilation with different modes
  70049. * @returns A promise that resolves when the compilation completes
  70050. */
  70051. forceCompilationAsync(options?: Partial<{
  70052. useInstances: boolean;
  70053. }>): Promise<void>;
  70054. /**
  70055. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  70056. * @param subMesh The submesh we want to render in the shadow map
  70057. * @param useInstances Defines wether will draw in the map using instances
  70058. * @returns true if ready otherwise, false
  70059. */
  70060. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70061. /**
  70062. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  70063. * @param defines Defines of the material we want to update
  70064. * @param lightIndex Index of the light in the enabled light list of the material
  70065. */
  70066. prepareDefines(defines: any, lightIndex: number): void;
  70067. /**
  70068. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  70069. * defined in the generator but impacting the effect).
  70070. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  70071. * @param effect The effect we are binfing the information for
  70072. */
  70073. bindShadowLight(lightIndex: string, effect: Effect): void;
  70074. /**
  70075. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  70076. * (eq to shadow prjection matrix * light transform matrix)
  70077. * @returns The transform matrix used to create the shadow map
  70078. */
  70079. getTransformMatrix(): Matrix;
  70080. /**
  70081. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  70082. * Cube and 2D textures for instance.
  70083. */
  70084. recreateShadowMap(): void;
  70085. private _disposeBlurPostProcesses;
  70086. private _disposeRTTandPostProcesses;
  70087. /**
  70088. * Disposes the ShadowGenerator.
  70089. * Returns nothing.
  70090. */
  70091. dispose(): void;
  70092. /**
  70093. * Serializes the shadow generator setup to a json object.
  70094. * @returns The serialized JSON object
  70095. */
  70096. serialize(): any;
  70097. /**
  70098. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  70099. * @param parsedShadowGenerator The JSON object to parse
  70100. * @param scene The scene to create the shadow map for
  70101. * @returns The parsed shadow generator
  70102. */
  70103. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  70104. }
  70105. }
  70106. declare module BABYLON {
  70107. /**
  70108. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  70109. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  70110. * 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.
  70111. */
  70112. export abstract class Light extends Node {
  70113. /**
  70114. * Falloff Default: light is falling off following the material specification:
  70115. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  70116. */
  70117. static readonly FALLOFF_DEFAULT: number;
  70118. /**
  70119. * Falloff Physical: light is falling off following the inverse squared distance law.
  70120. */
  70121. static readonly FALLOFF_PHYSICAL: number;
  70122. /**
  70123. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  70124. * to enhance interoperability with other engines.
  70125. */
  70126. static readonly FALLOFF_GLTF: number;
  70127. /**
  70128. * Falloff Standard: light is falling off like in the standard material
  70129. * to enhance interoperability with other materials.
  70130. */
  70131. static readonly FALLOFF_STANDARD: number;
  70132. /**
  70133. * If every light affecting the material is in this lightmapMode,
  70134. * material.lightmapTexture adds or multiplies
  70135. * (depends on material.useLightmapAsShadowmap)
  70136. * after every other light calculations.
  70137. */
  70138. static readonly LIGHTMAP_DEFAULT: number;
  70139. /**
  70140. * material.lightmapTexture as only diffuse lighting from this light
  70141. * adds only specular lighting from this light
  70142. * adds dynamic shadows
  70143. */
  70144. static readonly LIGHTMAP_SPECULAR: number;
  70145. /**
  70146. * material.lightmapTexture as only lighting
  70147. * no light calculation from this light
  70148. * only adds dynamic shadows from this light
  70149. */
  70150. static readonly LIGHTMAP_SHADOWSONLY: number;
  70151. /**
  70152. * Each light type uses the default quantity according to its type:
  70153. * point/spot lights use luminous intensity
  70154. * directional lights use illuminance
  70155. */
  70156. static readonly INTENSITYMODE_AUTOMATIC: number;
  70157. /**
  70158. * lumen (lm)
  70159. */
  70160. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  70161. /**
  70162. * candela (lm/sr)
  70163. */
  70164. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  70165. /**
  70166. * lux (lm/m^2)
  70167. */
  70168. static readonly INTENSITYMODE_ILLUMINANCE: number;
  70169. /**
  70170. * nit (cd/m^2)
  70171. */
  70172. static readonly INTENSITYMODE_LUMINANCE: number;
  70173. /**
  70174. * Light type const id of the point light.
  70175. */
  70176. static readonly LIGHTTYPEID_POINTLIGHT: number;
  70177. /**
  70178. * Light type const id of the directional light.
  70179. */
  70180. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  70181. /**
  70182. * Light type const id of the spot light.
  70183. */
  70184. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  70185. /**
  70186. * Light type const id of the hemispheric light.
  70187. */
  70188. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  70189. /**
  70190. * Diffuse gives the basic color to an object.
  70191. */
  70192. diffuse: Color3;
  70193. /**
  70194. * Specular produces a highlight color on an object.
  70195. * Note: This is note affecting PBR materials.
  70196. */
  70197. specular: Color3;
  70198. /**
  70199. * Defines the falloff type for this light. This lets overrriding how punctual light are
  70200. * falling off base on range or angle.
  70201. * This can be set to any values in Light.FALLOFF_x.
  70202. *
  70203. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  70204. * other types of materials.
  70205. */
  70206. falloffType: number;
  70207. /**
  70208. * Strength of the light.
  70209. * Note: By default it is define in the framework own unit.
  70210. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  70211. */
  70212. intensity: number;
  70213. private _range;
  70214. protected _inverseSquaredRange: number;
  70215. /**
  70216. * Defines how far from the source the light is impacting in scene units.
  70217. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70218. */
  70219. /**
  70220. * Defines how far from the source the light is impacting in scene units.
  70221. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70222. */
  70223. range: number;
  70224. /**
  70225. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  70226. * of light.
  70227. */
  70228. private _photometricScale;
  70229. private _intensityMode;
  70230. /**
  70231. * Gets the photometric scale used to interpret the intensity.
  70232. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70233. */
  70234. /**
  70235. * Sets the photometric scale used to interpret the intensity.
  70236. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70237. */
  70238. intensityMode: number;
  70239. private _radius;
  70240. /**
  70241. * Gets the light radius used by PBR Materials to simulate soft area lights.
  70242. */
  70243. /**
  70244. * sets the light radius used by PBR Materials to simulate soft area lights.
  70245. */
  70246. radius: number;
  70247. private _renderPriority;
  70248. /**
  70249. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  70250. * exceeding the number allowed of the materials.
  70251. */
  70252. renderPriority: number;
  70253. private _shadowEnabled;
  70254. /**
  70255. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70256. * the current shadow generator.
  70257. */
  70258. /**
  70259. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70260. * the current shadow generator.
  70261. */
  70262. shadowEnabled: boolean;
  70263. private _includedOnlyMeshes;
  70264. /**
  70265. * Gets the only meshes impacted by this light.
  70266. */
  70267. /**
  70268. * Sets the only meshes impacted by this light.
  70269. */
  70270. includedOnlyMeshes: AbstractMesh[];
  70271. private _excludedMeshes;
  70272. /**
  70273. * Gets the meshes not impacted by this light.
  70274. */
  70275. /**
  70276. * Sets the meshes not impacted by this light.
  70277. */
  70278. excludedMeshes: AbstractMesh[];
  70279. private _excludeWithLayerMask;
  70280. /**
  70281. * Gets the layer id use to find what meshes are not impacted by the light.
  70282. * Inactive if 0
  70283. */
  70284. /**
  70285. * Sets the layer id use to find what meshes are not impacted by the light.
  70286. * Inactive if 0
  70287. */
  70288. excludeWithLayerMask: number;
  70289. private _includeOnlyWithLayerMask;
  70290. /**
  70291. * Gets the layer id use to find what meshes are impacted by the light.
  70292. * Inactive if 0
  70293. */
  70294. /**
  70295. * Sets the layer id use to find what meshes are impacted by the light.
  70296. * Inactive if 0
  70297. */
  70298. includeOnlyWithLayerMask: number;
  70299. private _lightmapMode;
  70300. /**
  70301. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70302. */
  70303. /**
  70304. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70305. */
  70306. lightmapMode: number;
  70307. /**
  70308. * Shadow generator associted to the light.
  70309. * @hidden Internal use only.
  70310. */
  70311. _shadowGenerator: Nullable<IShadowGenerator>;
  70312. /**
  70313. * @hidden Internal use only.
  70314. */
  70315. _excludedMeshesIds: string[];
  70316. /**
  70317. * @hidden Internal use only.
  70318. */
  70319. _includedOnlyMeshesIds: string[];
  70320. /**
  70321. * The current light unifom buffer.
  70322. * @hidden Internal use only.
  70323. */
  70324. _uniformBuffer: UniformBuffer;
  70325. /**
  70326. * Creates a Light object in the scene.
  70327. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70328. * @param name The firendly name of the light
  70329. * @param scene The scene the light belongs too
  70330. */
  70331. constructor(name: string, scene: Scene);
  70332. protected abstract _buildUniformLayout(): void;
  70333. /**
  70334. * Sets the passed Effect "effect" with the Light information.
  70335. * @param effect The effect to update
  70336. * @param lightIndex The index of the light in the effect to update
  70337. * @returns The light
  70338. */
  70339. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70340. /**
  70341. * Returns the string "Light".
  70342. * @returns the class name
  70343. */
  70344. getClassName(): string;
  70345. /** @hidden */
  70346. readonly _isLight: boolean;
  70347. /**
  70348. * Converts the light information to a readable string for debug purpose.
  70349. * @param fullDetails Supports for multiple levels of logging within scene loading
  70350. * @returns the human readable light info
  70351. */
  70352. toString(fullDetails?: boolean): string;
  70353. /** @hidden */
  70354. protected _syncParentEnabledState(): void;
  70355. /**
  70356. * Set the enabled state of this node.
  70357. * @param value - the new enabled state
  70358. */
  70359. setEnabled(value: boolean): void;
  70360. /**
  70361. * Returns the Light associated shadow generator if any.
  70362. * @return the associated shadow generator.
  70363. */
  70364. getShadowGenerator(): Nullable<IShadowGenerator>;
  70365. /**
  70366. * Returns a Vector3, the absolute light position in the World.
  70367. * @returns the world space position of the light
  70368. */
  70369. getAbsolutePosition(): Vector3;
  70370. /**
  70371. * Specifies if the light will affect the passed mesh.
  70372. * @param mesh The mesh to test against the light
  70373. * @return true the mesh is affected otherwise, false.
  70374. */
  70375. canAffectMesh(mesh: AbstractMesh): boolean;
  70376. /**
  70377. * Sort function to order lights for rendering.
  70378. * @param a First Light object to compare to second.
  70379. * @param b Second Light object to compare first.
  70380. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70381. */
  70382. static CompareLightsPriority(a: Light, b: Light): number;
  70383. /**
  70384. * Releases resources associated with this node.
  70385. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70386. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70387. */
  70388. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70389. /**
  70390. * Returns the light type ID (integer).
  70391. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70392. */
  70393. getTypeID(): number;
  70394. /**
  70395. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70396. * @returns the scaled intensity in intensity mode unit
  70397. */
  70398. getScaledIntensity(): number;
  70399. /**
  70400. * Returns a new Light object, named "name", from the current one.
  70401. * @param name The name of the cloned light
  70402. * @returns the new created light
  70403. */
  70404. clone(name: string): Nullable<Light>;
  70405. /**
  70406. * Serializes the current light into a Serialization object.
  70407. * @returns the serialized object.
  70408. */
  70409. serialize(): any;
  70410. /**
  70411. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70412. * This new light is named "name" and added to the passed scene.
  70413. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70414. * @param name The friendly name of the light
  70415. * @param scene The scene the new light will belong to
  70416. * @returns the constructor function
  70417. */
  70418. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70419. /**
  70420. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70421. * @param parsedLight The JSON representation of the light
  70422. * @param scene The scene to create the parsed light in
  70423. * @returns the created light after parsing
  70424. */
  70425. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70426. private _hookArrayForExcluded;
  70427. private _hookArrayForIncludedOnly;
  70428. private _resyncMeshes;
  70429. /**
  70430. * Forces the meshes to update their light related information in their rendering used effects
  70431. * @hidden Internal Use Only
  70432. */
  70433. _markMeshesAsLightDirty(): void;
  70434. /**
  70435. * Recomputes the cached photometric scale if needed.
  70436. */
  70437. private _computePhotometricScale;
  70438. /**
  70439. * Returns the Photometric Scale according to the light type and intensity mode.
  70440. */
  70441. private _getPhotometricScale;
  70442. /**
  70443. * Reorder the light in the scene according to their defined priority.
  70444. * @hidden Internal Use Only
  70445. */
  70446. _reorderLightsInScene(): void;
  70447. /**
  70448. * Prepares the list of defines specific to the light type.
  70449. * @param defines the list of defines
  70450. * @param lightIndex defines the index of the light for the effect
  70451. */
  70452. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70453. }
  70454. }
  70455. declare module BABYLON {
  70456. /**
  70457. * Interface used to define Action
  70458. */
  70459. export interface IAction {
  70460. /**
  70461. * Trigger for the action
  70462. */
  70463. trigger: number;
  70464. /** Options of the trigger */
  70465. triggerOptions: any;
  70466. /**
  70467. * Gets the trigger parameters
  70468. * @returns the trigger parameters
  70469. */
  70470. getTriggerParameter(): any;
  70471. /**
  70472. * Internal only - executes current action event
  70473. * @hidden
  70474. */
  70475. _executeCurrent(evt?: ActionEvent): void;
  70476. /**
  70477. * Serialize placeholder for child classes
  70478. * @param parent of child
  70479. * @returns the serialized object
  70480. */
  70481. serialize(parent: any): any;
  70482. /**
  70483. * Internal only
  70484. * @hidden
  70485. */
  70486. _prepare(): void;
  70487. /**
  70488. * Internal only - manager for action
  70489. * @hidden
  70490. */
  70491. _actionManager: AbstractActionManager;
  70492. }
  70493. /**
  70494. * The action to be carried out following a trigger
  70495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70496. */
  70497. export class Action implements IAction {
  70498. /** the trigger, with or without parameters, for the action */
  70499. triggerOptions: any;
  70500. /**
  70501. * Trigger for the action
  70502. */
  70503. trigger: number;
  70504. /**
  70505. * Internal only - manager for action
  70506. * @hidden
  70507. */
  70508. _actionManager: ActionManager;
  70509. private _nextActiveAction;
  70510. private _child;
  70511. private _condition?;
  70512. private _triggerParameter;
  70513. /**
  70514. * An event triggered prior to action being executed.
  70515. */
  70516. onBeforeExecuteObservable: Observable<Action>;
  70517. /**
  70518. * Creates a new Action
  70519. * @param triggerOptions the trigger, with or without parameters, for the action
  70520. * @param condition an optional determinant of action
  70521. */
  70522. constructor(
  70523. /** the trigger, with or without parameters, for the action */
  70524. triggerOptions: any, condition?: Condition);
  70525. /**
  70526. * Internal only
  70527. * @hidden
  70528. */
  70529. _prepare(): void;
  70530. /**
  70531. * Gets the trigger parameters
  70532. * @returns the trigger parameters
  70533. */
  70534. getTriggerParameter(): any;
  70535. /**
  70536. * Internal only - executes current action event
  70537. * @hidden
  70538. */
  70539. _executeCurrent(evt?: ActionEvent): void;
  70540. /**
  70541. * Execute placeholder for child classes
  70542. * @param evt optional action event
  70543. */
  70544. execute(evt?: ActionEvent): void;
  70545. /**
  70546. * Skips to next active action
  70547. */
  70548. skipToNextActiveAction(): void;
  70549. /**
  70550. * Adds action to chain of actions, may be a DoNothingAction
  70551. * @param action defines the next action to execute
  70552. * @returns The action passed in
  70553. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70554. */
  70555. then(action: Action): Action;
  70556. /**
  70557. * Internal only
  70558. * @hidden
  70559. */
  70560. _getProperty(propertyPath: string): string;
  70561. /**
  70562. * Internal only
  70563. * @hidden
  70564. */
  70565. _getEffectiveTarget(target: any, propertyPath: string): any;
  70566. /**
  70567. * Serialize placeholder for child classes
  70568. * @param parent of child
  70569. * @returns the serialized object
  70570. */
  70571. serialize(parent: any): any;
  70572. /**
  70573. * Internal only called by serialize
  70574. * @hidden
  70575. */
  70576. protected _serialize(serializedAction: any, parent?: any): any;
  70577. /**
  70578. * Internal only
  70579. * @hidden
  70580. */
  70581. static _SerializeValueAsString: (value: any) => string;
  70582. /**
  70583. * Internal only
  70584. * @hidden
  70585. */
  70586. static _GetTargetProperty: (target: Scene | Node) => {
  70587. name: string;
  70588. targetType: string;
  70589. value: string;
  70590. };
  70591. }
  70592. }
  70593. declare module BABYLON {
  70594. /**
  70595. * A Condition applied to an Action
  70596. */
  70597. export class Condition {
  70598. /**
  70599. * Internal only - manager for action
  70600. * @hidden
  70601. */
  70602. _actionManager: ActionManager;
  70603. /**
  70604. * Internal only
  70605. * @hidden
  70606. */
  70607. _evaluationId: number;
  70608. /**
  70609. * Internal only
  70610. * @hidden
  70611. */
  70612. _currentResult: boolean;
  70613. /**
  70614. * Creates a new Condition
  70615. * @param actionManager the manager of the action the condition is applied to
  70616. */
  70617. constructor(actionManager: ActionManager);
  70618. /**
  70619. * Check if the current condition is valid
  70620. * @returns a boolean
  70621. */
  70622. isValid(): boolean;
  70623. /**
  70624. * Internal only
  70625. * @hidden
  70626. */
  70627. _getProperty(propertyPath: string): string;
  70628. /**
  70629. * Internal only
  70630. * @hidden
  70631. */
  70632. _getEffectiveTarget(target: any, propertyPath: string): any;
  70633. /**
  70634. * Serialize placeholder for child classes
  70635. * @returns the serialized object
  70636. */
  70637. serialize(): any;
  70638. /**
  70639. * Internal only
  70640. * @hidden
  70641. */
  70642. protected _serialize(serializedCondition: any): any;
  70643. }
  70644. /**
  70645. * Defines specific conditional operators as extensions of Condition
  70646. */
  70647. export class ValueCondition extends Condition {
  70648. /** path to specify the property of the target the conditional operator uses */
  70649. propertyPath: string;
  70650. /** the value compared by the conditional operator against the current value of the property */
  70651. value: any;
  70652. /** the conditional operator, default ValueCondition.IsEqual */
  70653. operator: number;
  70654. /**
  70655. * Internal only
  70656. * @hidden
  70657. */
  70658. private static _IsEqual;
  70659. /**
  70660. * Internal only
  70661. * @hidden
  70662. */
  70663. private static _IsDifferent;
  70664. /**
  70665. * Internal only
  70666. * @hidden
  70667. */
  70668. private static _IsGreater;
  70669. /**
  70670. * Internal only
  70671. * @hidden
  70672. */
  70673. private static _IsLesser;
  70674. /**
  70675. * returns the number for IsEqual
  70676. */
  70677. static readonly IsEqual: number;
  70678. /**
  70679. * Returns the number for IsDifferent
  70680. */
  70681. static readonly IsDifferent: number;
  70682. /**
  70683. * Returns the number for IsGreater
  70684. */
  70685. static readonly IsGreater: number;
  70686. /**
  70687. * Returns the number for IsLesser
  70688. */
  70689. static readonly IsLesser: number;
  70690. /**
  70691. * Internal only The action manager for the condition
  70692. * @hidden
  70693. */
  70694. _actionManager: ActionManager;
  70695. /**
  70696. * Internal only
  70697. * @hidden
  70698. */
  70699. private _target;
  70700. /**
  70701. * Internal only
  70702. * @hidden
  70703. */
  70704. private _effectiveTarget;
  70705. /**
  70706. * Internal only
  70707. * @hidden
  70708. */
  70709. private _property;
  70710. /**
  70711. * Creates a new ValueCondition
  70712. * @param actionManager manager for the action the condition applies to
  70713. * @param target for the action
  70714. * @param propertyPath path to specify the property of the target the conditional operator uses
  70715. * @param value the value compared by the conditional operator against the current value of the property
  70716. * @param operator the conditional operator, default ValueCondition.IsEqual
  70717. */
  70718. constructor(actionManager: ActionManager, target: any,
  70719. /** path to specify the property of the target the conditional operator uses */
  70720. propertyPath: string,
  70721. /** the value compared by the conditional operator against the current value of the property */
  70722. value: any,
  70723. /** the conditional operator, default ValueCondition.IsEqual */
  70724. operator?: number);
  70725. /**
  70726. * Compares the given value with the property value for the specified conditional operator
  70727. * @returns the result of the comparison
  70728. */
  70729. isValid(): boolean;
  70730. /**
  70731. * Serialize the ValueCondition into a JSON compatible object
  70732. * @returns serialization object
  70733. */
  70734. serialize(): any;
  70735. /**
  70736. * Gets the name of the conditional operator for the ValueCondition
  70737. * @param operator the conditional operator
  70738. * @returns the name
  70739. */
  70740. static GetOperatorName(operator: number): string;
  70741. }
  70742. /**
  70743. * Defines a predicate condition as an extension of Condition
  70744. */
  70745. export class PredicateCondition extends Condition {
  70746. /** defines the predicate function used to validate the condition */
  70747. predicate: () => boolean;
  70748. /**
  70749. * Internal only - manager for action
  70750. * @hidden
  70751. */
  70752. _actionManager: ActionManager;
  70753. /**
  70754. * Creates a new PredicateCondition
  70755. * @param actionManager manager for the action the condition applies to
  70756. * @param predicate defines the predicate function used to validate the condition
  70757. */
  70758. constructor(actionManager: ActionManager,
  70759. /** defines the predicate function used to validate the condition */
  70760. predicate: () => boolean);
  70761. /**
  70762. * @returns the validity of the predicate condition
  70763. */
  70764. isValid(): boolean;
  70765. }
  70766. /**
  70767. * Defines a state condition as an extension of Condition
  70768. */
  70769. export class StateCondition extends Condition {
  70770. /** Value to compare with target state */
  70771. value: string;
  70772. /**
  70773. * Internal only - manager for action
  70774. * @hidden
  70775. */
  70776. _actionManager: ActionManager;
  70777. /**
  70778. * Internal only
  70779. * @hidden
  70780. */
  70781. private _target;
  70782. /**
  70783. * Creates a new StateCondition
  70784. * @param actionManager manager for the action the condition applies to
  70785. * @param target of the condition
  70786. * @param value to compare with target state
  70787. */
  70788. constructor(actionManager: ActionManager, target: any,
  70789. /** Value to compare with target state */
  70790. value: string);
  70791. /**
  70792. * Gets a boolean indicating if the current condition is met
  70793. * @returns the validity of the state
  70794. */
  70795. isValid(): boolean;
  70796. /**
  70797. * Serialize the StateCondition into a JSON compatible object
  70798. * @returns serialization object
  70799. */
  70800. serialize(): any;
  70801. }
  70802. }
  70803. declare module BABYLON {
  70804. /**
  70805. * This defines an action responsible to toggle a boolean once triggered.
  70806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70807. */
  70808. export class SwitchBooleanAction extends Action {
  70809. /**
  70810. * The path to the boolean property in the target object
  70811. */
  70812. propertyPath: string;
  70813. private _target;
  70814. private _effectiveTarget;
  70815. private _property;
  70816. /**
  70817. * Instantiate the action
  70818. * @param triggerOptions defines the trigger options
  70819. * @param target defines the object containing the boolean
  70820. * @param propertyPath defines the path to the boolean property in the target object
  70821. * @param condition defines the trigger related conditions
  70822. */
  70823. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70824. /** @hidden */
  70825. _prepare(): void;
  70826. /**
  70827. * Execute the action toggle the boolean value.
  70828. */
  70829. execute(): void;
  70830. /**
  70831. * Serializes the actions and its related information.
  70832. * @param parent defines the object to serialize in
  70833. * @returns the serialized object
  70834. */
  70835. serialize(parent: any): any;
  70836. }
  70837. /**
  70838. * This defines an action responsible to set a the state field of the target
  70839. * to a desired value once triggered.
  70840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70841. */
  70842. export class SetStateAction extends Action {
  70843. /**
  70844. * The value to store in the state field.
  70845. */
  70846. value: string;
  70847. private _target;
  70848. /**
  70849. * Instantiate the action
  70850. * @param triggerOptions defines the trigger options
  70851. * @param target defines the object containing the state property
  70852. * @param value defines the value to store in the state field
  70853. * @param condition defines the trigger related conditions
  70854. */
  70855. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70856. /**
  70857. * Execute the action and store the value on the target state property.
  70858. */
  70859. execute(): void;
  70860. /**
  70861. * Serializes the actions and its related information.
  70862. * @param parent defines the object to serialize in
  70863. * @returns the serialized object
  70864. */
  70865. serialize(parent: any): any;
  70866. }
  70867. /**
  70868. * This defines an action responsible to set a property of the target
  70869. * to a desired value once triggered.
  70870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70871. */
  70872. export class SetValueAction extends Action {
  70873. /**
  70874. * The path of the property to set in the target.
  70875. */
  70876. propertyPath: string;
  70877. /**
  70878. * The value to set in the property
  70879. */
  70880. value: any;
  70881. private _target;
  70882. private _effectiveTarget;
  70883. private _property;
  70884. /**
  70885. * Instantiate the action
  70886. * @param triggerOptions defines the trigger options
  70887. * @param target defines the object containing the property
  70888. * @param propertyPath defines the path of the property to set in the target
  70889. * @param value defines the value to set in the property
  70890. * @param condition defines the trigger related conditions
  70891. */
  70892. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70893. /** @hidden */
  70894. _prepare(): void;
  70895. /**
  70896. * Execute the action and set the targetted property to the desired value.
  70897. */
  70898. execute(): void;
  70899. /**
  70900. * Serializes the actions and its related information.
  70901. * @param parent defines the object to serialize in
  70902. * @returns the serialized object
  70903. */
  70904. serialize(parent: any): any;
  70905. }
  70906. /**
  70907. * This defines an action responsible to increment the target value
  70908. * to a desired value once triggered.
  70909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70910. */
  70911. export class IncrementValueAction extends Action {
  70912. /**
  70913. * The path of the property to increment in the target.
  70914. */
  70915. propertyPath: string;
  70916. /**
  70917. * The value we should increment the property by.
  70918. */
  70919. value: any;
  70920. private _target;
  70921. private _effectiveTarget;
  70922. private _property;
  70923. /**
  70924. * Instantiate the action
  70925. * @param triggerOptions defines the trigger options
  70926. * @param target defines the object containing the property
  70927. * @param propertyPath defines the path of the property to increment in the target
  70928. * @param value defines the value value we should increment the property by
  70929. * @param condition defines the trigger related conditions
  70930. */
  70931. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70932. /** @hidden */
  70933. _prepare(): void;
  70934. /**
  70935. * Execute the action and increment the target of the value amount.
  70936. */
  70937. execute(): void;
  70938. /**
  70939. * Serializes the actions and its related information.
  70940. * @param parent defines the object to serialize in
  70941. * @returns the serialized object
  70942. */
  70943. serialize(parent: any): any;
  70944. }
  70945. /**
  70946. * This defines an action responsible to start an animation once triggered.
  70947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70948. */
  70949. export class PlayAnimationAction extends Action {
  70950. /**
  70951. * Where the animation should start (animation frame)
  70952. */
  70953. from: number;
  70954. /**
  70955. * Where the animation should stop (animation frame)
  70956. */
  70957. to: number;
  70958. /**
  70959. * Define if the animation should loop or stop after the first play.
  70960. */
  70961. loop?: boolean;
  70962. private _target;
  70963. /**
  70964. * Instantiate the action
  70965. * @param triggerOptions defines the trigger options
  70966. * @param target defines the target animation or animation name
  70967. * @param from defines from where the animation should start (animation frame)
  70968. * @param end defines where the animation should stop (animation frame)
  70969. * @param loop defines if the animation should loop or stop after the first play
  70970. * @param condition defines the trigger related conditions
  70971. */
  70972. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70973. /** @hidden */
  70974. _prepare(): void;
  70975. /**
  70976. * Execute the action and play the animation.
  70977. */
  70978. execute(): void;
  70979. /**
  70980. * Serializes the actions and its related information.
  70981. * @param parent defines the object to serialize in
  70982. * @returns the serialized object
  70983. */
  70984. serialize(parent: any): any;
  70985. }
  70986. /**
  70987. * This defines an action responsible to stop an animation once triggered.
  70988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70989. */
  70990. export class StopAnimationAction extends Action {
  70991. private _target;
  70992. /**
  70993. * Instantiate the action
  70994. * @param triggerOptions defines the trigger options
  70995. * @param target defines the target animation or animation name
  70996. * @param condition defines the trigger related conditions
  70997. */
  70998. constructor(triggerOptions: any, target: any, condition?: Condition);
  70999. /** @hidden */
  71000. _prepare(): void;
  71001. /**
  71002. * Execute the action and stop the animation.
  71003. */
  71004. execute(): void;
  71005. /**
  71006. * Serializes the actions and its related information.
  71007. * @param parent defines the object to serialize in
  71008. * @returns the serialized object
  71009. */
  71010. serialize(parent: any): any;
  71011. }
  71012. /**
  71013. * This defines an action responsible that does nothing once triggered.
  71014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71015. */
  71016. export class DoNothingAction extends Action {
  71017. /**
  71018. * Instantiate the action
  71019. * @param triggerOptions defines the trigger options
  71020. * @param condition defines the trigger related conditions
  71021. */
  71022. constructor(triggerOptions?: any, condition?: Condition);
  71023. /**
  71024. * Execute the action and do nothing.
  71025. */
  71026. execute(): void;
  71027. /**
  71028. * Serializes the actions and its related information.
  71029. * @param parent defines the object to serialize in
  71030. * @returns the serialized object
  71031. */
  71032. serialize(parent: any): any;
  71033. }
  71034. /**
  71035. * This defines an action responsible to trigger several actions once triggered.
  71036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71037. */
  71038. export class CombineAction extends Action {
  71039. /**
  71040. * The list of aggregated animations to run.
  71041. */
  71042. children: Action[];
  71043. /**
  71044. * Instantiate the action
  71045. * @param triggerOptions defines the trigger options
  71046. * @param children defines the list of aggregated animations to run
  71047. * @param condition defines the trigger related conditions
  71048. */
  71049. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  71050. /** @hidden */
  71051. _prepare(): void;
  71052. /**
  71053. * Execute the action and executes all the aggregated actions.
  71054. */
  71055. execute(evt: ActionEvent): void;
  71056. /**
  71057. * Serializes the actions and its related information.
  71058. * @param parent defines the object to serialize in
  71059. * @returns the serialized object
  71060. */
  71061. serialize(parent: any): any;
  71062. }
  71063. /**
  71064. * This defines an action responsible to run code (external event) once triggered.
  71065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71066. */
  71067. export class ExecuteCodeAction extends Action {
  71068. /**
  71069. * The callback function to run.
  71070. */
  71071. func: (evt: ActionEvent) => void;
  71072. /**
  71073. * Instantiate the action
  71074. * @param triggerOptions defines the trigger options
  71075. * @param func defines the callback function to run
  71076. * @param condition defines the trigger related conditions
  71077. */
  71078. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  71079. /**
  71080. * Execute the action and run the attached code.
  71081. */
  71082. execute(evt: ActionEvent): void;
  71083. }
  71084. /**
  71085. * This defines an action responsible to set the parent property of the target once triggered.
  71086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71087. */
  71088. export class SetParentAction extends Action {
  71089. private _parent;
  71090. private _target;
  71091. /**
  71092. * Instantiate the action
  71093. * @param triggerOptions defines the trigger options
  71094. * @param target defines the target containing the parent property
  71095. * @param parent defines from where the animation should start (animation frame)
  71096. * @param condition defines the trigger related conditions
  71097. */
  71098. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  71099. /** @hidden */
  71100. _prepare(): void;
  71101. /**
  71102. * Execute the action and set the parent property.
  71103. */
  71104. execute(): void;
  71105. /**
  71106. * Serializes the actions and its related information.
  71107. * @param parent defines the object to serialize in
  71108. * @returns the serialized object
  71109. */
  71110. serialize(parent: any): any;
  71111. }
  71112. }
  71113. declare module BABYLON {
  71114. /**
  71115. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  71116. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  71117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71118. */
  71119. export class ActionManager extends AbstractActionManager {
  71120. /**
  71121. * Nothing
  71122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71123. */
  71124. static readonly NothingTrigger: number;
  71125. /**
  71126. * On pick
  71127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71128. */
  71129. static readonly OnPickTrigger: number;
  71130. /**
  71131. * On left pick
  71132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71133. */
  71134. static readonly OnLeftPickTrigger: number;
  71135. /**
  71136. * On right pick
  71137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71138. */
  71139. static readonly OnRightPickTrigger: number;
  71140. /**
  71141. * On center pick
  71142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71143. */
  71144. static readonly OnCenterPickTrigger: number;
  71145. /**
  71146. * On pick down
  71147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71148. */
  71149. static readonly OnPickDownTrigger: number;
  71150. /**
  71151. * On double pick
  71152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71153. */
  71154. static readonly OnDoublePickTrigger: number;
  71155. /**
  71156. * On pick up
  71157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71158. */
  71159. static readonly OnPickUpTrigger: number;
  71160. /**
  71161. * On pick out.
  71162. * This trigger will only be raised if you also declared a OnPickDown
  71163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71164. */
  71165. static readonly OnPickOutTrigger: number;
  71166. /**
  71167. * On long press
  71168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71169. */
  71170. static readonly OnLongPressTrigger: number;
  71171. /**
  71172. * On pointer over
  71173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71174. */
  71175. static readonly OnPointerOverTrigger: number;
  71176. /**
  71177. * On pointer out
  71178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71179. */
  71180. static readonly OnPointerOutTrigger: number;
  71181. /**
  71182. * On every frame
  71183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71184. */
  71185. static readonly OnEveryFrameTrigger: number;
  71186. /**
  71187. * On intersection enter
  71188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71189. */
  71190. static readonly OnIntersectionEnterTrigger: number;
  71191. /**
  71192. * On intersection exit
  71193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71194. */
  71195. static readonly OnIntersectionExitTrigger: number;
  71196. /**
  71197. * On key down
  71198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71199. */
  71200. static readonly OnKeyDownTrigger: number;
  71201. /**
  71202. * On key up
  71203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71204. */
  71205. static readonly OnKeyUpTrigger: number;
  71206. private _scene;
  71207. /**
  71208. * Creates a new action manager
  71209. * @param scene defines the hosting scene
  71210. */
  71211. constructor(scene: Scene);
  71212. /**
  71213. * Releases all associated resources
  71214. */
  71215. dispose(): void;
  71216. /**
  71217. * Gets hosting scene
  71218. * @returns the hosting scene
  71219. */
  71220. getScene(): Scene;
  71221. /**
  71222. * Does this action manager handles actions of any of the given triggers
  71223. * @param triggers defines the triggers to be tested
  71224. * @return a boolean indicating whether one (or more) of the triggers is handled
  71225. */
  71226. hasSpecificTriggers(triggers: number[]): boolean;
  71227. /**
  71228. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  71229. * speed.
  71230. * @param triggerA defines the trigger to be tested
  71231. * @param triggerB defines the trigger to be tested
  71232. * @return a boolean indicating whether one (or more) of the triggers is handled
  71233. */
  71234. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  71235. /**
  71236. * Does this action manager handles actions of a given trigger
  71237. * @param trigger defines the trigger to be tested
  71238. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  71239. * @return whether the trigger is handled
  71240. */
  71241. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  71242. /**
  71243. * Does this action manager has pointer triggers
  71244. */
  71245. readonly hasPointerTriggers: boolean;
  71246. /**
  71247. * Does this action manager has pick triggers
  71248. */
  71249. readonly hasPickTriggers: boolean;
  71250. /**
  71251. * Registers an action to this action manager
  71252. * @param action defines the action to be registered
  71253. * @return the action amended (prepared) after registration
  71254. */
  71255. registerAction(action: IAction): Nullable<IAction>;
  71256. /**
  71257. * Unregisters an action to this action manager
  71258. * @param action defines the action to be unregistered
  71259. * @return a boolean indicating whether the action has been unregistered
  71260. */
  71261. unregisterAction(action: IAction): Boolean;
  71262. /**
  71263. * Process a specific trigger
  71264. * @param trigger defines the trigger to process
  71265. * @param evt defines the event details to be processed
  71266. */
  71267. processTrigger(trigger: number, evt?: IActionEvent): void;
  71268. /** @hidden */
  71269. _getEffectiveTarget(target: any, propertyPath: string): any;
  71270. /** @hidden */
  71271. _getProperty(propertyPath: string): string;
  71272. /**
  71273. * Serialize this manager to a JSON object
  71274. * @param name defines the property name to store this manager
  71275. * @returns a JSON representation of this manager
  71276. */
  71277. serialize(name: string): any;
  71278. /**
  71279. * Creates a new ActionManager from a JSON data
  71280. * @param parsedActions defines the JSON data to read from
  71281. * @param object defines the hosting mesh
  71282. * @param scene defines the hosting scene
  71283. */
  71284. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  71285. /**
  71286. * Get a trigger name by index
  71287. * @param trigger defines the trigger index
  71288. * @returns a trigger name
  71289. */
  71290. static GetTriggerName(trigger: number): string;
  71291. }
  71292. }
  71293. declare module BABYLON {
  71294. /**
  71295. * Class representing a ray with position and direction
  71296. */
  71297. export class Ray {
  71298. /** origin point */
  71299. origin: Vector3;
  71300. /** direction */
  71301. direction: Vector3;
  71302. /** length of the ray */
  71303. length: number;
  71304. private static readonly TmpVector3;
  71305. private _tmpRay;
  71306. /**
  71307. * Creates a new ray
  71308. * @param origin origin point
  71309. * @param direction direction
  71310. * @param length length of the ray
  71311. */
  71312. constructor(
  71313. /** origin point */
  71314. origin: Vector3,
  71315. /** direction */
  71316. direction: Vector3,
  71317. /** length of the ray */
  71318. length?: number);
  71319. /**
  71320. * Checks if the ray intersects a box
  71321. * @param minimum bound of the box
  71322. * @param maximum bound of the box
  71323. * @param intersectionTreshold extra extend to be added to the box in all direction
  71324. * @returns if the box was hit
  71325. */
  71326. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  71327. /**
  71328. * Checks if the ray intersects a box
  71329. * @param box the bounding box to check
  71330. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  71331. * @returns if the box was hit
  71332. */
  71333. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  71334. /**
  71335. * If the ray hits a sphere
  71336. * @param sphere the bounding sphere to check
  71337. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71338. * @returns true if it hits the sphere
  71339. */
  71340. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71341. /**
  71342. * If the ray hits a triange
  71343. * @param vertex0 triangle vertex
  71344. * @param vertex1 triangle vertex
  71345. * @param vertex2 triangle vertex
  71346. * @returns intersection information if hit
  71347. */
  71348. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71349. /**
  71350. * Checks if ray intersects a plane
  71351. * @param plane the plane to check
  71352. * @returns the distance away it was hit
  71353. */
  71354. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71355. /**
  71356. * Checks if ray intersects a mesh
  71357. * @param mesh the mesh to check
  71358. * @param fastCheck if only the bounding box should checked
  71359. * @returns picking info of the intersecton
  71360. */
  71361. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71362. /**
  71363. * Checks if ray intersects a mesh
  71364. * @param meshes the meshes to check
  71365. * @param fastCheck if only the bounding box should checked
  71366. * @param results array to store result in
  71367. * @returns Array of picking infos
  71368. */
  71369. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71370. private _comparePickingInfo;
  71371. private static smallnum;
  71372. private static rayl;
  71373. /**
  71374. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71375. * @param sega the first point of the segment to test the intersection against
  71376. * @param segb the second point of the segment to test the intersection against
  71377. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71378. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71379. */
  71380. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71381. /**
  71382. * Update the ray from viewport position
  71383. * @param x position
  71384. * @param y y position
  71385. * @param viewportWidth viewport width
  71386. * @param viewportHeight viewport height
  71387. * @param world world matrix
  71388. * @param view view matrix
  71389. * @param projection projection matrix
  71390. * @returns this ray updated
  71391. */
  71392. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71393. /**
  71394. * Creates a ray with origin and direction of 0,0,0
  71395. * @returns the new ray
  71396. */
  71397. static Zero(): Ray;
  71398. /**
  71399. * Creates a new ray from screen space and viewport
  71400. * @param x position
  71401. * @param y y position
  71402. * @param viewportWidth viewport width
  71403. * @param viewportHeight viewport height
  71404. * @param world world matrix
  71405. * @param view view matrix
  71406. * @param projection projection matrix
  71407. * @returns new ray
  71408. */
  71409. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71410. /**
  71411. * 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
  71412. * transformed to the given world matrix.
  71413. * @param origin The origin point
  71414. * @param end The end point
  71415. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71416. * @returns the new ray
  71417. */
  71418. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71419. /**
  71420. * Transforms a ray by a matrix
  71421. * @param ray ray to transform
  71422. * @param matrix matrix to apply
  71423. * @returns the resulting new ray
  71424. */
  71425. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71426. /**
  71427. * Transforms a ray by a matrix
  71428. * @param ray ray to transform
  71429. * @param matrix matrix to apply
  71430. * @param result ray to store result in
  71431. */
  71432. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71433. /**
  71434. * Unproject a ray from screen space to object space
  71435. * @param sourceX defines the screen space x coordinate to use
  71436. * @param sourceY defines the screen space y coordinate to use
  71437. * @param viewportWidth defines the current width of the viewport
  71438. * @param viewportHeight defines the current height of the viewport
  71439. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71440. * @param view defines the view matrix to use
  71441. * @param projection defines the projection matrix to use
  71442. */
  71443. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71444. }
  71445. /**
  71446. * Type used to define predicate used to select faces when a mesh intersection is detected
  71447. */
  71448. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71449. interface Scene {
  71450. /** @hidden */
  71451. _tempPickingRay: Nullable<Ray>;
  71452. /** @hidden */
  71453. _cachedRayForTransform: Ray;
  71454. /** @hidden */
  71455. _pickWithRayInverseMatrix: Matrix;
  71456. /** @hidden */
  71457. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71458. /** @hidden */
  71459. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71460. }
  71461. }
  71462. declare module BABYLON {
  71463. /**
  71464. * Groups all the scene component constants in one place to ease maintenance.
  71465. * @hidden
  71466. */
  71467. export class SceneComponentConstants {
  71468. static readonly NAME_EFFECTLAYER: string;
  71469. static readonly NAME_LAYER: string;
  71470. static readonly NAME_LENSFLARESYSTEM: string;
  71471. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71472. static readonly NAME_PARTICLESYSTEM: string;
  71473. static readonly NAME_GAMEPAD: string;
  71474. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71475. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71476. static readonly NAME_DEPTHRENDERER: string;
  71477. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71478. static readonly NAME_SPRITE: string;
  71479. static readonly NAME_OUTLINERENDERER: string;
  71480. static readonly NAME_PROCEDURALTEXTURE: string;
  71481. static readonly NAME_SHADOWGENERATOR: string;
  71482. static readonly NAME_OCTREE: string;
  71483. static readonly NAME_PHYSICSENGINE: string;
  71484. static readonly NAME_AUDIO: string;
  71485. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71486. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71487. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71488. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71489. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71490. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71491. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71492. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71493. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71494. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71495. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71496. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71497. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71498. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71499. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71500. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71501. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71502. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71503. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71504. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71505. static readonly STEP_AFTERRENDER_AUDIO: number;
  71506. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71507. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71508. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71509. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71510. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71511. static readonly STEP_POINTERMOVE_SPRITE: number;
  71512. static readonly STEP_POINTERDOWN_SPRITE: number;
  71513. static readonly STEP_POINTERUP_SPRITE: number;
  71514. }
  71515. /**
  71516. * This represents a scene component.
  71517. *
  71518. * This is used to decouple the dependency the scene is having on the different workloads like
  71519. * layers, post processes...
  71520. */
  71521. export interface ISceneComponent {
  71522. /**
  71523. * The name of the component. Each component must have a unique name.
  71524. */
  71525. name: string;
  71526. /**
  71527. * The scene the component belongs to.
  71528. */
  71529. scene: Scene;
  71530. /**
  71531. * Register the component to one instance of a scene.
  71532. */
  71533. register(): void;
  71534. /**
  71535. * Rebuilds the elements related to this component in case of
  71536. * context lost for instance.
  71537. */
  71538. rebuild(): void;
  71539. /**
  71540. * Disposes the component and the associated ressources.
  71541. */
  71542. dispose(): void;
  71543. }
  71544. /**
  71545. * This represents a SERIALIZABLE scene component.
  71546. *
  71547. * This extends Scene Component to add Serialization methods on top.
  71548. */
  71549. export interface ISceneSerializableComponent extends ISceneComponent {
  71550. /**
  71551. * Adds all the element from the container to the scene
  71552. * @param container the container holding the elements
  71553. */
  71554. addFromContainer(container: AbstractScene): void;
  71555. /**
  71556. * Removes all the elements in the container from the scene
  71557. * @param container contains the elements to remove
  71558. * @param dispose if the removed element should be disposed (default: false)
  71559. */
  71560. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71561. /**
  71562. * Serializes the component data to the specified json object
  71563. * @param serializationObject The object to serialize to
  71564. */
  71565. serialize(serializationObject: any): void;
  71566. }
  71567. /**
  71568. * Strong typing of a Mesh related stage step action
  71569. */
  71570. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71571. /**
  71572. * Strong typing of a Evaluate Sub Mesh related stage step action
  71573. */
  71574. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71575. /**
  71576. * Strong typing of a Active Mesh related stage step action
  71577. */
  71578. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71579. /**
  71580. * Strong typing of a Camera related stage step action
  71581. */
  71582. export type CameraStageAction = (camera: Camera) => void;
  71583. /**
  71584. * Strong typing of a Camera Frame buffer related stage step action
  71585. */
  71586. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71587. /**
  71588. * Strong typing of a Render Target related stage step action
  71589. */
  71590. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71591. /**
  71592. * Strong typing of a RenderingGroup related stage step action
  71593. */
  71594. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71595. /**
  71596. * Strong typing of a Mesh Render related stage step action
  71597. */
  71598. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71599. /**
  71600. * Strong typing of a simple stage step action
  71601. */
  71602. export type SimpleStageAction = () => void;
  71603. /**
  71604. * Strong typing of a render target action.
  71605. */
  71606. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71607. /**
  71608. * Strong typing of a pointer move action.
  71609. */
  71610. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71611. /**
  71612. * Strong typing of a pointer up/down action.
  71613. */
  71614. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71615. /**
  71616. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71617. * @hidden
  71618. */
  71619. export class Stage<T extends Function> extends Array<{
  71620. index: number;
  71621. component: ISceneComponent;
  71622. action: T;
  71623. }> {
  71624. /**
  71625. * Hide ctor from the rest of the world.
  71626. * @param items The items to add.
  71627. */
  71628. private constructor();
  71629. /**
  71630. * Creates a new Stage.
  71631. * @returns A new instance of a Stage
  71632. */
  71633. static Create<T extends Function>(): Stage<T>;
  71634. /**
  71635. * Registers a step in an ordered way in the targeted stage.
  71636. * @param index Defines the position to register the step in
  71637. * @param component Defines the component attached to the step
  71638. * @param action Defines the action to launch during the step
  71639. */
  71640. registerStep(index: number, component: ISceneComponent, action: T): void;
  71641. /**
  71642. * Clears all the steps from the stage.
  71643. */
  71644. clear(): void;
  71645. }
  71646. }
  71647. declare module BABYLON {
  71648. interface Scene {
  71649. /** @hidden */
  71650. _pointerOverSprite: Nullable<Sprite>;
  71651. /** @hidden */
  71652. _pickedDownSprite: Nullable<Sprite>;
  71653. /** @hidden */
  71654. _tempSpritePickingRay: Nullable<Ray>;
  71655. /**
  71656. * All of the sprite managers added to this scene
  71657. * @see http://doc.babylonjs.com/babylon101/sprites
  71658. */
  71659. spriteManagers: Array<ISpriteManager>;
  71660. /**
  71661. * An event triggered when sprites rendering is about to start
  71662. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71663. */
  71664. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71665. /**
  71666. * An event triggered when sprites rendering is done
  71667. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71668. */
  71669. onAfterSpritesRenderingObservable: Observable<Scene>;
  71670. /** @hidden */
  71671. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71672. /** Launch a ray to try to pick a sprite in the scene
  71673. * @param x position on screen
  71674. * @param y position on screen
  71675. * @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
  71676. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71677. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71678. * @returns a PickingInfo
  71679. */
  71680. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71681. /** Use the given ray to pick a sprite in the scene
  71682. * @param ray The ray (in world space) to use to pick meshes
  71683. * @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
  71684. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71685. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71686. * @returns a PickingInfo
  71687. */
  71688. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71689. /**
  71690. * Force the sprite under the pointer
  71691. * @param sprite defines the sprite to use
  71692. */
  71693. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71694. /**
  71695. * Gets the sprite under the pointer
  71696. * @returns a Sprite or null if no sprite is under the pointer
  71697. */
  71698. getPointerOverSprite(): Nullable<Sprite>;
  71699. }
  71700. /**
  71701. * Defines the sprite scene component responsible to manage sprites
  71702. * in a given scene.
  71703. */
  71704. export class SpriteSceneComponent implements ISceneComponent {
  71705. /**
  71706. * The component name helpfull to identify the component in the list of scene components.
  71707. */
  71708. readonly name: string;
  71709. /**
  71710. * The scene the component belongs to.
  71711. */
  71712. scene: Scene;
  71713. /** @hidden */
  71714. private _spritePredicate;
  71715. /**
  71716. * Creates a new instance of the component for the given scene
  71717. * @param scene Defines the scene to register the component in
  71718. */
  71719. constructor(scene: Scene);
  71720. /**
  71721. * Registers the component in a given scene
  71722. */
  71723. register(): void;
  71724. /**
  71725. * Rebuilds the elements related to this component in case of
  71726. * context lost for instance.
  71727. */
  71728. rebuild(): void;
  71729. /**
  71730. * Disposes the component and the associated ressources.
  71731. */
  71732. dispose(): void;
  71733. private _pickSpriteButKeepRay;
  71734. private _pointerMove;
  71735. private _pointerDown;
  71736. private _pointerUp;
  71737. }
  71738. }
  71739. declare module BABYLON {
  71740. /** @hidden */
  71741. export var fogFragmentDeclaration: {
  71742. name: string;
  71743. shader: string;
  71744. };
  71745. }
  71746. declare module BABYLON {
  71747. /** @hidden */
  71748. export var fogFragment: {
  71749. name: string;
  71750. shader: string;
  71751. };
  71752. }
  71753. declare module BABYLON {
  71754. /** @hidden */
  71755. export var spritesPixelShader: {
  71756. name: string;
  71757. shader: string;
  71758. };
  71759. }
  71760. declare module BABYLON {
  71761. /** @hidden */
  71762. export var fogVertexDeclaration: {
  71763. name: string;
  71764. shader: string;
  71765. };
  71766. }
  71767. declare module BABYLON {
  71768. /** @hidden */
  71769. export var spritesVertexShader: {
  71770. name: string;
  71771. shader: string;
  71772. };
  71773. }
  71774. declare module BABYLON {
  71775. /**
  71776. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71777. */
  71778. export interface ISpriteManager extends IDisposable {
  71779. /**
  71780. * Restricts the camera to viewing objects with the same layerMask.
  71781. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71782. */
  71783. layerMask: number;
  71784. /**
  71785. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71786. */
  71787. isPickable: boolean;
  71788. /**
  71789. * Specifies the rendering group id for this mesh (0 by default)
  71790. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71791. */
  71792. renderingGroupId: number;
  71793. /**
  71794. * Defines the list of sprites managed by the manager.
  71795. */
  71796. sprites: Array<Sprite>;
  71797. /**
  71798. * Tests the intersection of a sprite with a specific ray.
  71799. * @param ray The ray we are sending to test the collision
  71800. * @param camera The camera space we are sending rays in
  71801. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71802. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71803. * @returns picking info or null.
  71804. */
  71805. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71806. /**
  71807. * Renders the list of sprites on screen.
  71808. */
  71809. render(): void;
  71810. }
  71811. /**
  71812. * Class used to manage multiple sprites on the same spritesheet
  71813. * @see http://doc.babylonjs.com/babylon101/sprites
  71814. */
  71815. export class SpriteManager implements ISpriteManager {
  71816. /** defines the manager's name */
  71817. name: string;
  71818. /** Gets the list of sprites */
  71819. sprites: Sprite[];
  71820. /** Gets or sets the rendering group id (0 by default) */
  71821. renderingGroupId: number;
  71822. /** Gets or sets camera layer mask */
  71823. layerMask: number;
  71824. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71825. fogEnabled: boolean;
  71826. /** Gets or sets a boolean indicating if the sprites are pickable */
  71827. isPickable: boolean;
  71828. /** Defines the default width of a cell in the spritesheet */
  71829. cellWidth: number;
  71830. /** Defines the default height of a cell in the spritesheet */
  71831. cellHeight: number;
  71832. /**
  71833. * An event triggered when the manager is disposed.
  71834. */
  71835. onDisposeObservable: Observable<SpriteManager>;
  71836. private _onDisposeObserver;
  71837. /**
  71838. * Callback called when the manager is disposed
  71839. */
  71840. onDispose: () => void;
  71841. private _capacity;
  71842. private _spriteTexture;
  71843. private _epsilon;
  71844. private _scene;
  71845. private _vertexData;
  71846. private _buffer;
  71847. private _vertexBuffers;
  71848. private _indexBuffer;
  71849. private _effectBase;
  71850. private _effectFog;
  71851. /**
  71852. * Gets or sets the spritesheet texture
  71853. */
  71854. texture: Texture;
  71855. /**
  71856. * Creates a new sprite manager
  71857. * @param name defines the manager's name
  71858. * @param imgUrl defines the sprite sheet url
  71859. * @param capacity defines the maximum allowed number of sprites
  71860. * @param cellSize defines the size of a sprite cell
  71861. * @param scene defines the hosting scene
  71862. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71863. * @param samplingMode defines the smapling mode to use with spritesheet
  71864. */
  71865. constructor(
  71866. /** defines the manager's name */
  71867. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71868. private _appendSpriteVertex;
  71869. /**
  71870. * Intersects the sprites with a ray
  71871. * @param ray defines the ray to intersect with
  71872. * @param camera defines the current active camera
  71873. * @param predicate defines a predicate used to select candidate sprites
  71874. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71875. * @returns null if no hit or a PickingInfo
  71876. */
  71877. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71878. /**
  71879. * Render all child sprites
  71880. */
  71881. render(): void;
  71882. /**
  71883. * Release associated resources
  71884. */
  71885. dispose(): void;
  71886. }
  71887. }
  71888. declare module BABYLON {
  71889. /**
  71890. * Class used to represent a sprite
  71891. * @see http://doc.babylonjs.com/babylon101/sprites
  71892. */
  71893. export class Sprite {
  71894. /** defines the name */
  71895. name: string;
  71896. /** Gets or sets the current world position */
  71897. position: Vector3;
  71898. /** Gets or sets the main color */
  71899. color: Color4;
  71900. /** Gets or sets the width */
  71901. width: number;
  71902. /** Gets or sets the height */
  71903. height: number;
  71904. /** Gets or sets rotation angle */
  71905. angle: number;
  71906. /** Gets or sets the cell index in the sprite sheet */
  71907. cellIndex: number;
  71908. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71909. invertU: number;
  71910. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71911. invertV: number;
  71912. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71913. disposeWhenFinishedAnimating: boolean;
  71914. /** Gets the list of attached animations */
  71915. animations: Animation[];
  71916. /** Gets or sets a boolean indicating if the sprite can be picked */
  71917. isPickable: boolean;
  71918. /**
  71919. * Gets or sets the associated action manager
  71920. */
  71921. actionManager: Nullable<ActionManager>;
  71922. private _animationStarted;
  71923. private _loopAnimation;
  71924. private _fromIndex;
  71925. private _toIndex;
  71926. private _delay;
  71927. private _direction;
  71928. private _manager;
  71929. private _time;
  71930. private _onAnimationEnd;
  71931. /**
  71932. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71933. */
  71934. isVisible: boolean;
  71935. /**
  71936. * Gets or sets the sprite size
  71937. */
  71938. size: number;
  71939. /**
  71940. * Creates a new Sprite
  71941. * @param name defines the name
  71942. * @param manager defines the manager
  71943. */
  71944. constructor(
  71945. /** defines the name */
  71946. name: string, manager: ISpriteManager);
  71947. /**
  71948. * Starts an animation
  71949. * @param from defines the initial key
  71950. * @param to defines the end key
  71951. * @param loop defines if the animation must loop
  71952. * @param delay defines the start delay (in ms)
  71953. * @param onAnimationEnd defines a callback to call when animation ends
  71954. */
  71955. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71956. /** Stops current animation (if any) */
  71957. stopAnimation(): void;
  71958. /** @hidden */
  71959. _animate(deltaTime: number): void;
  71960. /** Release associated resources */
  71961. dispose(): void;
  71962. }
  71963. }
  71964. declare module BABYLON {
  71965. /**
  71966. * Information about the result of picking within a scene
  71967. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71968. */
  71969. export class PickingInfo {
  71970. /** @hidden */
  71971. _pickingUnavailable: boolean;
  71972. /**
  71973. * If the pick collided with an object
  71974. */
  71975. hit: boolean;
  71976. /**
  71977. * Distance away where the pick collided
  71978. */
  71979. distance: number;
  71980. /**
  71981. * The location of pick collision
  71982. */
  71983. pickedPoint: Nullable<Vector3>;
  71984. /**
  71985. * The mesh corresponding the the pick collision
  71986. */
  71987. pickedMesh: Nullable<AbstractMesh>;
  71988. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71989. bu: number;
  71990. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71991. bv: number;
  71992. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71993. faceId: number;
  71994. /** Id of the the submesh that was picked */
  71995. subMeshId: number;
  71996. /** If a sprite was picked, this will be the sprite the pick collided with */
  71997. pickedSprite: Nullable<Sprite>;
  71998. /**
  71999. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  72000. */
  72001. originMesh: Nullable<AbstractMesh>;
  72002. /**
  72003. * The ray that was used to perform the picking.
  72004. */
  72005. ray: Nullable<Ray>;
  72006. /**
  72007. * Gets the normal correspodning to the face the pick collided with
  72008. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  72009. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  72010. * @returns The normal correspodning to the face the pick collided with
  72011. */
  72012. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  72013. /**
  72014. * Gets the texture coordinates of where the pick occured
  72015. * @returns the vector containing the coordnates of the texture
  72016. */
  72017. getTextureCoordinates(): Nullable<Vector2>;
  72018. }
  72019. }
  72020. declare module BABYLON {
  72021. /**
  72022. * Gather the list of pointer event types as constants.
  72023. */
  72024. export class PointerEventTypes {
  72025. /**
  72026. * 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.
  72027. */
  72028. static readonly POINTERDOWN: number;
  72029. /**
  72030. * The pointerup event is fired when a pointer is no longer active.
  72031. */
  72032. static readonly POINTERUP: number;
  72033. /**
  72034. * The pointermove event is fired when a pointer changes coordinates.
  72035. */
  72036. static readonly POINTERMOVE: number;
  72037. /**
  72038. * The pointerwheel event is fired when a mouse wheel has been rotated.
  72039. */
  72040. static readonly POINTERWHEEL: number;
  72041. /**
  72042. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  72043. */
  72044. static readonly POINTERPICK: number;
  72045. /**
  72046. * The pointertap event is fired when a the object has been touched and released without drag.
  72047. */
  72048. static readonly POINTERTAP: number;
  72049. /**
  72050. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  72051. */
  72052. static readonly POINTERDOUBLETAP: number;
  72053. }
  72054. /**
  72055. * Base class of pointer info types.
  72056. */
  72057. export class PointerInfoBase {
  72058. /**
  72059. * Defines the type of event (PointerEventTypes)
  72060. */
  72061. type: number;
  72062. /**
  72063. * Defines the related dom event
  72064. */
  72065. event: PointerEvent | MouseWheelEvent;
  72066. /**
  72067. * Instantiates the base class of pointers info.
  72068. * @param type Defines the type of event (PointerEventTypes)
  72069. * @param event Defines the related dom event
  72070. */
  72071. constructor(
  72072. /**
  72073. * Defines the type of event (PointerEventTypes)
  72074. */
  72075. type: number,
  72076. /**
  72077. * Defines the related dom event
  72078. */
  72079. event: PointerEvent | MouseWheelEvent);
  72080. }
  72081. /**
  72082. * This class is used to store pointer related info for the onPrePointerObservable event.
  72083. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  72084. */
  72085. export class PointerInfoPre extends PointerInfoBase {
  72086. /**
  72087. * Ray from a pointer if availible (eg. 6dof controller)
  72088. */
  72089. ray: Nullable<Ray>;
  72090. /**
  72091. * Defines the local position of the pointer on the canvas.
  72092. */
  72093. localPosition: Vector2;
  72094. /**
  72095. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  72096. */
  72097. skipOnPointerObservable: boolean;
  72098. /**
  72099. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  72100. * @param type Defines the type of event (PointerEventTypes)
  72101. * @param event Defines the related dom event
  72102. * @param localX Defines the local x coordinates of the pointer when the event occured
  72103. * @param localY Defines the local y coordinates of the pointer when the event occured
  72104. */
  72105. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  72106. }
  72107. /**
  72108. * This type contains all the data related to a pointer event in Babylon.js.
  72109. * 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.
  72110. */
  72111. export class PointerInfo extends PointerInfoBase {
  72112. /**
  72113. * Defines the picking info associated to the info (if any)\
  72114. */
  72115. pickInfo: Nullable<PickingInfo>;
  72116. /**
  72117. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  72118. * @param type Defines the type of event (PointerEventTypes)
  72119. * @param event Defines the related dom event
  72120. * @param pickInfo Defines the picking info associated to the info (if any)\
  72121. */
  72122. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  72123. /**
  72124. * Defines the picking info associated to the info (if any)\
  72125. */
  72126. pickInfo: Nullable<PickingInfo>);
  72127. }
  72128. /**
  72129. * Data relating to a touch event on the screen.
  72130. */
  72131. export interface PointerTouch {
  72132. /**
  72133. * X coordinate of touch.
  72134. */
  72135. x: number;
  72136. /**
  72137. * Y coordinate of touch.
  72138. */
  72139. y: number;
  72140. /**
  72141. * Id of touch. Unique for each finger.
  72142. */
  72143. pointerId: number;
  72144. /**
  72145. * Event type passed from DOM.
  72146. */
  72147. type: any;
  72148. }
  72149. }
  72150. declare module BABYLON {
  72151. /**
  72152. * Manage the mouse inputs to control the movement of a free camera.
  72153. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72154. */
  72155. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  72156. /**
  72157. * Define if touch is enabled in the mouse input
  72158. */
  72159. touchEnabled: boolean;
  72160. /**
  72161. * Defines the camera the input is attached to.
  72162. */
  72163. camera: FreeCamera;
  72164. /**
  72165. * Defines the buttons associated with the input to handle camera move.
  72166. */
  72167. buttons: number[];
  72168. /**
  72169. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  72170. */
  72171. angularSensibility: number;
  72172. private _pointerInput;
  72173. private _onMouseMove;
  72174. private _observer;
  72175. private previousPosition;
  72176. /**
  72177. * Observable for when a pointer move event occurs containing the move offset
  72178. */
  72179. onPointerMovedObservable: Observable<{
  72180. offsetX: number;
  72181. offsetY: number;
  72182. }>;
  72183. /**
  72184. * @hidden
  72185. * If the camera should be rotated automatically based on pointer movement
  72186. */
  72187. _allowCameraRotation: boolean;
  72188. /**
  72189. * Manage the mouse inputs to control the movement of a free camera.
  72190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72191. * @param touchEnabled Defines if touch is enabled or not
  72192. */
  72193. constructor(
  72194. /**
  72195. * Define if touch is enabled in the mouse input
  72196. */
  72197. touchEnabled?: boolean);
  72198. /**
  72199. * Attach the input controls to a specific dom element to get the input from.
  72200. * @param element Defines the element the controls should be listened from
  72201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72202. */
  72203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72204. /**
  72205. * Called on JS contextmenu event.
  72206. * Override this method to provide functionality.
  72207. */
  72208. protected onContextMenu(evt: PointerEvent): void;
  72209. /**
  72210. * Detach the current controls from the specified dom element.
  72211. * @param element Defines the element to stop listening the inputs from
  72212. */
  72213. detachControl(element: Nullable<HTMLElement>): void;
  72214. /**
  72215. * Gets the class name of the current intput.
  72216. * @returns the class name
  72217. */
  72218. getClassName(): string;
  72219. /**
  72220. * Get the friendly name associated with the input class.
  72221. * @returns the input friendly name
  72222. */
  72223. getSimpleName(): string;
  72224. }
  72225. }
  72226. declare module BABYLON {
  72227. /**
  72228. * Manage the touch inputs to control the movement of a free camera.
  72229. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72230. */
  72231. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  72232. /**
  72233. * Defines the camera the input is attached to.
  72234. */
  72235. camera: FreeCamera;
  72236. /**
  72237. * Defines the touch sensibility for rotation.
  72238. * The higher the faster.
  72239. */
  72240. touchAngularSensibility: number;
  72241. /**
  72242. * Defines the touch sensibility for move.
  72243. * The higher the faster.
  72244. */
  72245. touchMoveSensibility: number;
  72246. private _offsetX;
  72247. private _offsetY;
  72248. private _pointerPressed;
  72249. private _pointerInput;
  72250. private _observer;
  72251. private _onLostFocus;
  72252. /**
  72253. * Attach the input controls to a specific dom element to get the input from.
  72254. * @param element Defines the element the controls should be listened from
  72255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72256. */
  72257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72258. /**
  72259. * Detach the current controls from the specified dom element.
  72260. * @param element Defines the element to stop listening the inputs from
  72261. */
  72262. detachControl(element: Nullable<HTMLElement>): void;
  72263. /**
  72264. * Update the current camera state depending on the inputs that have been used this frame.
  72265. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72266. */
  72267. checkInputs(): void;
  72268. /**
  72269. * Gets the class name of the current intput.
  72270. * @returns the class name
  72271. */
  72272. getClassName(): string;
  72273. /**
  72274. * Get the friendly name associated with the input class.
  72275. * @returns the input friendly name
  72276. */
  72277. getSimpleName(): string;
  72278. }
  72279. }
  72280. declare module BABYLON {
  72281. /**
  72282. * Default Inputs manager for the FreeCamera.
  72283. * It groups all the default supported inputs for ease of use.
  72284. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72285. */
  72286. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  72287. /**
  72288. * @hidden
  72289. */
  72290. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  72291. /**
  72292. * @hidden
  72293. */
  72294. _mouseInput: Nullable<FreeCameraMouseInput>;
  72295. /**
  72296. * Instantiates a new FreeCameraInputsManager.
  72297. * @param camera Defines the camera the inputs belong to
  72298. */
  72299. constructor(camera: FreeCamera);
  72300. /**
  72301. * Add keyboard input support to the input manager.
  72302. * @returns the current input manager
  72303. */
  72304. addKeyboard(): FreeCameraInputsManager;
  72305. /**
  72306. * Add mouse input support to the input manager.
  72307. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  72308. * @returns the current input manager
  72309. */
  72310. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  72311. /**
  72312. * Removes the mouse input support from the manager
  72313. * @returns the current input manager
  72314. */
  72315. removeMouse(): FreeCameraInputsManager;
  72316. /**
  72317. * Add touch input support to the input manager.
  72318. * @returns the current input manager
  72319. */
  72320. addTouch(): FreeCameraInputsManager;
  72321. }
  72322. }
  72323. declare module BABYLON {
  72324. /**
  72325. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72326. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  72327. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72328. */
  72329. export class FreeCamera extends TargetCamera {
  72330. /**
  72331. * Define the collision ellipsoid of the camera.
  72332. * This is helpful to simulate a camera body like the player body around the camera
  72333. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  72334. */
  72335. ellipsoid: Vector3;
  72336. /**
  72337. * Define an offset for the position of the ellipsoid around the camera.
  72338. * This can be helpful to determine the center of the body near the gravity center of the body
  72339. * instead of its head.
  72340. */
  72341. ellipsoidOffset: Vector3;
  72342. /**
  72343. * Enable or disable collisions of the camera with the rest of the scene objects.
  72344. */
  72345. checkCollisions: boolean;
  72346. /**
  72347. * Enable or disable gravity on the camera.
  72348. */
  72349. applyGravity: boolean;
  72350. /**
  72351. * Define the input manager associated to the camera.
  72352. */
  72353. inputs: FreeCameraInputsManager;
  72354. /**
  72355. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72356. * Higher values reduce sensitivity.
  72357. */
  72358. /**
  72359. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72360. * Higher values reduce sensitivity.
  72361. */
  72362. angularSensibility: number;
  72363. /**
  72364. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72365. */
  72366. keysUp: number[];
  72367. /**
  72368. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72369. */
  72370. keysDown: number[];
  72371. /**
  72372. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72373. */
  72374. keysLeft: number[];
  72375. /**
  72376. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72377. */
  72378. keysRight: number[];
  72379. /**
  72380. * Event raised when the camera collide with a mesh in the scene.
  72381. */
  72382. onCollide: (collidedMesh: AbstractMesh) => void;
  72383. private _collider;
  72384. private _needMoveForGravity;
  72385. private _oldPosition;
  72386. private _diffPosition;
  72387. private _newPosition;
  72388. /** @hidden */
  72389. _localDirection: Vector3;
  72390. /** @hidden */
  72391. _transformedDirection: Vector3;
  72392. /**
  72393. * Instantiates a Free Camera.
  72394. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72395. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72396. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72397. * @param name Define the name of the camera in the scene
  72398. * @param position Define the start position of the camera in the scene
  72399. * @param scene Define the scene the camera belongs to
  72400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72401. */
  72402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72403. /**
  72404. * Attached controls to the current camera.
  72405. * @param element Defines the element the controls should be listened from
  72406. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72407. */
  72408. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72409. /**
  72410. * Detach the current controls from the camera.
  72411. * The camera will stop reacting to inputs.
  72412. * @param element Defines the element to stop listening the inputs from
  72413. */
  72414. detachControl(element: HTMLElement): void;
  72415. private _collisionMask;
  72416. /**
  72417. * Define a collision mask to limit the list of object the camera can collide with
  72418. */
  72419. collisionMask: number;
  72420. /** @hidden */
  72421. _collideWithWorld(displacement: Vector3): void;
  72422. private _onCollisionPositionChange;
  72423. /** @hidden */
  72424. _checkInputs(): void;
  72425. /** @hidden */
  72426. _decideIfNeedsToMove(): boolean;
  72427. /** @hidden */
  72428. _updatePosition(): void;
  72429. /**
  72430. * Destroy the camera and release the current resources hold by it.
  72431. */
  72432. dispose(): void;
  72433. /**
  72434. * Gets the current object class name.
  72435. * @return the class name
  72436. */
  72437. getClassName(): string;
  72438. }
  72439. }
  72440. declare module BABYLON {
  72441. /**
  72442. * Represents a gamepad control stick position
  72443. */
  72444. export class StickValues {
  72445. /**
  72446. * The x component of the control stick
  72447. */
  72448. x: number;
  72449. /**
  72450. * The y component of the control stick
  72451. */
  72452. y: number;
  72453. /**
  72454. * Initializes the gamepad x and y control stick values
  72455. * @param x The x component of the gamepad control stick value
  72456. * @param y The y component of the gamepad control stick value
  72457. */
  72458. constructor(
  72459. /**
  72460. * The x component of the control stick
  72461. */
  72462. x: number,
  72463. /**
  72464. * The y component of the control stick
  72465. */
  72466. y: number);
  72467. }
  72468. /**
  72469. * An interface which manages callbacks for gamepad button changes
  72470. */
  72471. export interface GamepadButtonChanges {
  72472. /**
  72473. * Called when a gamepad has been changed
  72474. */
  72475. changed: boolean;
  72476. /**
  72477. * Called when a gamepad press event has been triggered
  72478. */
  72479. pressChanged: boolean;
  72480. /**
  72481. * Called when a touch event has been triggered
  72482. */
  72483. touchChanged: boolean;
  72484. /**
  72485. * Called when a value has changed
  72486. */
  72487. valueChanged: boolean;
  72488. }
  72489. /**
  72490. * Represents a gamepad
  72491. */
  72492. export class Gamepad {
  72493. /**
  72494. * The id of the gamepad
  72495. */
  72496. id: string;
  72497. /**
  72498. * The index of the gamepad
  72499. */
  72500. index: number;
  72501. /**
  72502. * The browser gamepad
  72503. */
  72504. browserGamepad: any;
  72505. /**
  72506. * Specifies what type of gamepad this represents
  72507. */
  72508. type: number;
  72509. private _leftStick;
  72510. private _rightStick;
  72511. /** @hidden */
  72512. _isConnected: boolean;
  72513. private _leftStickAxisX;
  72514. private _leftStickAxisY;
  72515. private _rightStickAxisX;
  72516. private _rightStickAxisY;
  72517. /**
  72518. * Triggered when the left control stick has been changed
  72519. */
  72520. private _onleftstickchanged;
  72521. /**
  72522. * Triggered when the right control stick has been changed
  72523. */
  72524. private _onrightstickchanged;
  72525. /**
  72526. * Represents a gamepad controller
  72527. */
  72528. static GAMEPAD: number;
  72529. /**
  72530. * Represents a generic controller
  72531. */
  72532. static GENERIC: number;
  72533. /**
  72534. * Represents an XBox controller
  72535. */
  72536. static XBOX: number;
  72537. /**
  72538. * Represents a pose-enabled controller
  72539. */
  72540. static POSE_ENABLED: number;
  72541. /**
  72542. * Specifies whether the left control stick should be Y-inverted
  72543. */
  72544. protected _invertLeftStickY: boolean;
  72545. /**
  72546. * Specifies if the gamepad has been connected
  72547. */
  72548. readonly isConnected: boolean;
  72549. /**
  72550. * Initializes the gamepad
  72551. * @param id The id of the gamepad
  72552. * @param index The index of the gamepad
  72553. * @param browserGamepad The browser gamepad
  72554. * @param leftStickX The x component of the left joystick
  72555. * @param leftStickY The y component of the left joystick
  72556. * @param rightStickX The x component of the right joystick
  72557. * @param rightStickY The y component of the right joystick
  72558. */
  72559. constructor(
  72560. /**
  72561. * The id of the gamepad
  72562. */
  72563. id: string,
  72564. /**
  72565. * The index of the gamepad
  72566. */
  72567. index: number,
  72568. /**
  72569. * The browser gamepad
  72570. */
  72571. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72572. /**
  72573. * Callback triggered when the left joystick has changed
  72574. * @param callback
  72575. */
  72576. onleftstickchanged(callback: (values: StickValues) => void): void;
  72577. /**
  72578. * Callback triggered when the right joystick has changed
  72579. * @param callback
  72580. */
  72581. onrightstickchanged(callback: (values: StickValues) => void): void;
  72582. /**
  72583. * Gets the left joystick
  72584. */
  72585. /**
  72586. * Sets the left joystick values
  72587. */
  72588. leftStick: StickValues;
  72589. /**
  72590. * Gets the right joystick
  72591. */
  72592. /**
  72593. * Sets the right joystick value
  72594. */
  72595. rightStick: StickValues;
  72596. /**
  72597. * Updates the gamepad joystick positions
  72598. */
  72599. update(): void;
  72600. /**
  72601. * Disposes the gamepad
  72602. */
  72603. dispose(): void;
  72604. }
  72605. /**
  72606. * Represents a generic gamepad
  72607. */
  72608. export class GenericPad extends Gamepad {
  72609. private _buttons;
  72610. private _onbuttondown;
  72611. private _onbuttonup;
  72612. /**
  72613. * Observable triggered when a button has been pressed
  72614. */
  72615. onButtonDownObservable: Observable<number>;
  72616. /**
  72617. * Observable triggered when a button has been released
  72618. */
  72619. onButtonUpObservable: Observable<number>;
  72620. /**
  72621. * Callback triggered when a button has been pressed
  72622. * @param callback Called when a button has been pressed
  72623. */
  72624. onbuttondown(callback: (buttonPressed: number) => void): void;
  72625. /**
  72626. * Callback triggered when a button has been released
  72627. * @param callback Called when a button has been released
  72628. */
  72629. onbuttonup(callback: (buttonReleased: number) => void): void;
  72630. /**
  72631. * Initializes the generic gamepad
  72632. * @param id The id of the generic gamepad
  72633. * @param index The index of the generic gamepad
  72634. * @param browserGamepad The browser gamepad
  72635. */
  72636. constructor(id: string, index: number, browserGamepad: any);
  72637. private _setButtonValue;
  72638. /**
  72639. * Updates the generic gamepad
  72640. */
  72641. update(): void;
  72642. /**
  72643. * Disposes the generic gamepad
  72644. */
  72645. dispose(): void;
  72646. }
  72647. }
  72648. declare module BABYLON {
  72649. /**
  72650. * Defines the types of pose enabled controllers that are supported
  72651. */
  72652. export enum PoseEnabledControllerType {
  72653. /**
  72654. * HTC Vive
  72655. */
  72656. VIVE = 0,
  72657. /**
  72658. * Oculus Rift
  72659. */
  72660. OCULUS = 1,
  72661. /**
  72662. * Windows mixed reality
  72663. */
  72664. WINDOWS = 2,
  72665. /**
  72666. * Samsung gear VR
  72667. */
  72668. GEAR_VR = 3,
  72669. /**
  72670. * Google Daydream
  72671. */
  72672. DAYDREAM = 4,
  72673. /**
  72674. * Generic
  72675. */
  72676. GENERIC = 5
  72677. }
  72678. /**
  72679. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72680. */
  72681. export interface MutableGamepadButton {
  72682. /**
  72683. * Value of the button/trigger
  72684. */
  72685. value: number;
  72686. /**
  72687. * If the button/trigger is currently touched
  72688. */
  72689. touched: boolean;
  72690. /**
  72691. * If the button/trigger is currently pressed
  72692. */
  72693. pressed: boolean;
  72694. }
  72695. /**
  72696. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72697. * @hidden
  72698. */
  72699. export interface ExtendedGamepadButton extends GamepadButton {
  72700. /**
  72701. * If the button/trigger is currently pressed
  72702. */
  72703. readonly pressed: boolean;
  72704. /**
  72705. * If the button/trigger is currently touched
  72706. */
  72707. readonly touched: boolean;
  72708. /**
  72709. * Value of the button/trigger
  72710. */
  72711. readonly value: number;
  72712. }
  72713. /** @hidden */
  72714. export interface _GamePadFactory {
  72715. /**
  72716. * Returns wether or not the current gamepad can be created for this type of controller.
  72717. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72718. * @returns true if it can be created, otherwise false
  72719. */
  72720. canCreate(gamepadInfo: any): boolean;
  72721. /**
  72722. * Creates a new instance of the Gamepad.
  72723. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72724. * @returns the new gamepad instance
  72725. */
  72726. create(gamepadInfo: any): Gamepad;
  72727. }
  72728. /**
  72729. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72730. */
  72731. export class PoseEnabledControllerHelper {
  72732. /** @hidden */
  72733. static _ControllerFactories: _GamePadFactory[];
  72734. /** @hidden */
  72735. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72736. /**
  72737. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72738. * @param vrGamepad the gamepad to initialized
  72739. * @returns a vr controller of the type the gamepad identified as
  72740. */
  72741. static InitiateController(vrGamepad: any): Gamepad;
  72742. }
  72743. /**
  72744. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72745. */
  72746. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72747. private _deviceRoomPosition;
  72748. private _deviceRoomRotationQuaternion;
  72749. /**
  72750. * The device position in babylon space
  72751. */
  72752. devicePosition: Vector3;
  72753. /**
  72754. * The device rotation in babylon space
  72755. */
  72756. deviceRotationQuaternion: Quaternion;
  72757. /**
  72758. * The scale factor of the device in babylon space
  72759. */
  72760. deviceScaleFactor: number;
  72761. /**
  72762. * (Likely devicePosition should be used instead) The device position in its room space
  72763. */
  72764. position: Vector3;
  72765. /**
  72766. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72767. */
  72768. rotationQuaternion: Quaternion;
  72769. /**
  72770. * The type of controller (Eg. Windows mixed reality)
  72771. */
  72772. controllerType: PoseEnabledControllerType;
  72773. protected _calculatedPosition: Vector3;
  72774. private _calculatedRotation;
  72775. /**
  72776. * The raw pose from the device
  72777. */
  72778. rawPose: DevicePose;
  72779. private _trackPosition;
  72780. private _maxRotationDistFromHeadset;
  72781. private _draggedRoomRotation;
  72782. /**
  72783. * @hidden
  72784. */
  72785. _disableTrackPosition(fixedPosition: Vector3): void;
  72786. /**
  72787. * Internal, the mesh attached to the controller
  72788. * @hidden
  72789. */
  72790. _mesh: Nullable<AbstractMesh>;
  72791. private _poseControlledCamera;
  72792. private _leftHandSystemQuaternion;
  72793. /**
  72794. * Internal, matrix used to convert room space to babylon space
  72795. * @hidden
  72796. */
  72797. _deviceToWorld: Matrix;
  72798. /**
  72799. * Node to be used when casting a ray from the controller
  72800. * @hidden
  72801. */
  72802. _pointingPoseNode: Nullable<TransformNode>;
  72803. /**
  72804. * Name of the child mesh that can be used to cast a ray from the controller
  72805. */
  72806. static readonly POINTING_POSE: string;
  72807. /**
  72808. * Creates a new PoseEnabledController from a gamepad
  72809. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72810. */
  72811. constructor(browserGamepad: any);
  72812. private _workingMatrix;
  72813. /**
  72814. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72815. */
  72816. update(): void;
  72817. /**
  72818. * Updates only the pose device and mesh without doing any button event checking
  72819. */
  72820. protected _updatePoseAndMesh(): void;
  72821. /**
  72822. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72823. * @param poseData raw pose fromthe device
  72824. */
  72825. updateFromDevice(poseData: DevicePose): void;
  72826. /**
  72827. * @hidden
  72828. */
  72829. _meshAttachedObservable: Observable<AbstractMesh>;
  72830. /**
  72831. * Attaches a mesh to the controller
  72832. * @param mesh the mesh to be attached
  72833. */
  72834. attachToMesh(mesh: AbstractMesh): void;
  72835. /**
  72836. * Attaches the controllers mesh to a camera
  72837. * @param camera the camera the mesh should be attached to
  72838. */
  72839. attachToPoseControlledCamera(camera: TargetCamera): void;
  72840. /**
  72841. * Disposes of the controller
  72842. */
  72843. dispose(): void;
  72844. /**
  72845. * The mesh that is attached to the controller
  72846. */
  72847. readonly mesh: Nullable<AbstractMesh>;
  72848. /**
  72849. * Gets the ray of the controller in the direction the controller is pointing
  72850. * @param length the length the resulting ray should be
  72851. * @returns a ray in the direction the controller is pointing
  72852. */
  72853. getForwardRay(length?: number): Ray;
  72854. }
  72855. }
  72856. declare module BABYLON {
  72857. /**
  72858. * Defines the WebVRController object that represents controllers tracked in 3D space
  72859. */
  72860. export abstract class WebVRController extends PoseEnabledController {
  72861. /**
  72862. * Internal, the default controller model for the controller
  72863. */
  72864. protected _defaultModel: AbstractMesh;
  72865. /**
  72866. * Fired when the trigger state has changed
  72867. */
  72868. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72869. /**
  72870. * Fired when the main button state has changed
  72871. */
  72872. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72873. /**
  72874. * Fired when the secondary button state has changed
  72875. */
  72876. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72877. /**
  72878. * Fired when the pad state has changed
  72879. */
  72880. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72881. /**
  72882. * Fired when controllers stick values have changed
  72883. */
  72884. onPadValuesChangedObservable: Observable<StickValues>;
  72885. /**
  72886. * Array of button availible on the controller
  72887. */
  72888. protected _buttons: Array<MutableGamepadButton>;
  72889. private _onButtonStateChange;
  72890. /**
  72891. * Fired when a controller button's state has changed
  72892. * @param callback the callback containing the button that was modified
  72893. */
  72894. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72895. /**
  72896. * X and Y axis corrisponding to the controllers joystick
  72897. */
  72898. pad: StickValues;
  72899. /**
  72900. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72901. */
  72902. hand: string;
  72903. /**
  72904. * The default controller model for the controller
  72905. */
  72906. readonly defaultModel: AbstractMesh;
  72907. /**
  72908. * Creates a new WebVRController from a gamepad
  72909. * @param vrGamepad the gamepad that the WebVRController should be created from
  72910. */
  72911. constructor(vrGamepad: any);
  72912. /**
  72913. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72914. */
  72915. update(): void;
  72916. /**
  72917. * Function to be called when a button is modified
  72918. */
  72919. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72920. /**
  72921. * Loads a mesh and attaches it to the controller
  72922. * @param scene the scene the mesh should be added to
  72923. * @param meshLoaded callback for when the mesh has been loaded
  72924. */
  72925. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72926. private _setButtonValue;
  72927. private _changes;
  72928. private _checkChanges;
  72929. /**
  72930. * Disposes of th webVRCOntroller
  72931. */
  72932. dispose(): void;
  72933. }
  72934. }
  72935. declare module BABYLON {
  72936. /**
  72937. * The HemisphericLight simulates the ambient environment light,
  72938. * so the passed direction is the light reflection direction, not the incoming direction.
  72939. */
  72940. export class HemisphericLight extends Light {
  72941. /**
  72942. * The groundColor is the light in the opposite direction to the one specified during creation.
  72943. * 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.
  72944. */
  72945. groundColor: Color3;
  72946. /**
  72947. * The light reflection direction, not the incoming direction.
  72948. */
  72949. direction: Vector3;
  72950. /**
  72951. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72952. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72953. * The HemisphericLight can't cast shadows.
  72954. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72955. * @param name The friendly name of the light
  72956. * @param direction The direction of the light reflection
  72957. * @param scene The scene the light belongs to
  72958. */
  72959. constructor(name: string, direction: Vector3, scene: Scene);
  72960. protected _buildUniformLayout(): void;
  72961. /**
  72962. * Returns the string "HemisphericLight".
  72963. * @return The class name
  72964. */
  72965. getClassName(): string;
  72966. /**
  72967. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72968. * Returns the updated direction.
  72969. * @param target The target the direction should point to
  72970. * @return The computed direction
  72971. */
  72972. setDirectionToTarget(target: Vector3): Vector3;
  72973. /**
  72974. * Returns the shadow generator associated to the light.
  72975. * @returns Always null for hemispheric lights because it does not support shadows.
  72976. */
  72977. getShadowGenerator(): Nullable<IShadowGenerator>;
  72978. /**
  72979. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72980. * @param effect The effect to update
  72981. * @param lightIndex The index of the light in the effect to update
  72982. * @returns The hemispheric light
  72983. */
  72984. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72985. /**
  72986. * Computes the world matrix of the node
  72987. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72988. * @param useWasUpdatedFlag defines a reserved property
  72989. * @returns the world matrix
  72990. */
  72991. computeWorldMatrix(): Matrix;
  72992. /**
  72993. * Returns the integer 3.
  72994. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72995. */
  72996. getTypeID(): number;
  72997. /**
  72998. * Prepares the list of defines specific to the light type.
  72999. * @param defines the list of defines
  73000. * @param lightIndex defines the index of the light for the effect
  73001. */
  73002. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73003. }
  73004. }
  73005. declare module BABYLON {
  73006. /** @hidden */
  73007. export var vrMultiviewToSingleviewPixelShader: {
  73008. name: string;
  73009. shader: string;
  73010. };
  73011. }
  73012. declare module BABYLON {
  73013. /**
  73014. * Renders to multiple views with a single draw call
  73015. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  73016. */
  73017. export class MultiviewRenderTarget extends RenderTargetTexture {
  73018. /**
  73019. * Creates a multiview render target
  73020. * @param scene scene used with the render target
  73021. * @param size the size of the render target (used for each view)
  73022. */
  73023. constructor(scene: Scene, size?: number | {
  73024. width: number;
  73025. height: number;
  73026. } | {
  73027. ratio: number;
  73028. });
  73029. /**
  73030. * @hidden
  73031. * @param faceIndex the face index, if its a cube texture
  73032. */
  73033. _bindFrameBuffer(faceIndex?: number): void;
  73034. /**
  73035. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  73036. * @returns the view count
  73037. */
  73038. getViewCount(): number;
  73039. }
  73040. }
  73041. declare module BABYLON {
  73042. interface Engine {
  73043. /**
  73044. * Creates a new multiview render target
  73045. * @param width defines the width of the texture
  73046. * @param height defines the height of the texture
  73047. * @returns the created multiview texture
  73048. */
  73049. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  73050. /**
  73051. * Binds a multiview framebuffer to be drawn to
  73052. * @param multiviewTexture texture to bind
  73053. */
  73054. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  73055. }
  73056. interface Camera {
  73057. /**
  73058. * @hidden
  73059. * 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)
  73060. */
  73061. _useMultiviewToSingleView: boolean;
  73062. /**
  73063. * @hidden
  73064. * 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)
  73065. */
  73066. _multiviewTexture: Nullable<RenderTargetTexture>;
  73067. /**
  73068. * @hidden
  73069. * ensures the multiview texture of the camera exists and has the specified width/height
  73070. * @param width height to set on the multiview texture
  73071. * @param height width to set on the multiview texture
  73072. */
  73073. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  73074. }
  73075. interface Scene {
  73076. /** @hidden */
  73077. _transformMatrixR: Matrix;
  73078. /** @hidden */
  73079. _multiviewSceneUbo: Nullable<UniformBuffer>;
  73080. /** @hidden */
  73081. _createMultiviewUbo(): void;
  73082. /** @hidden */
  73083. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  73084. /** @hidden */
  73085. _renderMultiviewToSingleView(camera: Camera): void;
  73086. }
  73087. }
  73088. declare module BABYLON {
  73089. /**
  73090. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  73091. * This will not be used for webXR as it supports displaying texture arrays directly
  73092. */
  73093. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  73094. /**
  73095. * Initializes a VRMultiviewToSingleview
  73096. * @param name name of the post process
  73097. * @param camera camera to be applied to
  73098. * @param scaleFactor scaling factor to the size of the output texture
  73099. */
  73100. constructor(name: string, camera: Camera, scaleFactor: number);
  73101. }
  73102. }
  73103. declare module BABYLON {
  73104. /**
  73105. * Defines the interface used by display changed events
  73106. */
  73107. interface IDisplayChangedEventArgs {
  73108. /** Gets the vrDisplay object (if any) */
  73109. vrDisplay: Nullable<any>;
  73110. /** Gets a boolean indicating if webVR is supported */
  73111. vrSupported: boolean;
  73112. }
  73113. interface Engine {
  73114. /** @hidden */
  73115. _vrDisplay: any;
  73116. /** @hidden */
  73117. _vrSupported: boolean;
  73118. /** @hidden */
  73119. _oldSize: Size;
  73120. /** @hidden */
  73121. _oldHardwareScaleFactor: number;
  73122. /** @hidden */
  73123. _vrExclusivePointerMode: boolean;
  73124. /** @hidden */
  73125. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  73126. /** @hidden */
  73127. _onVRDisplayPointerRestricted: () => void;
  73128. /** @hidden */
  73129. _onVRDisplayPointerUnrestricted: () => void;
  73130. /** @hidden */
  73131. _onVrDisplayConnect: Nullable<(display: any) => void>;
  73132. /** @hidden */
  73133. _onVrDisplayDisconnect: Nullable<() => void>;
  73134. /** @hidden */
  73135. _onVrDisplayPresentChange: Nullable<() => void>;
  73136. /**
  73137. * Observable signaled when VR display mode changes
  73138. */
  73139. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  73140. /**
  73141. * Observable signaled when VR request present is complete
  73142. */
  73143. onVRRequestPresentComplete: Observable<boolean>;
  73144. /**
  73145. * Observable signaled when VR request present starts
  73146. */
  73147. onVRRequestPresentStart: Observable<Engine>;
  73148. /**
  73149. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  73150. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  73151. */
  73152. isInVRExclusivePointerMode: boolean;
  73153. /**
  73154. * Gets a boolean indicating if a webVR device was detected
  73155. * @returns true if a webVR device was detected
  73156. */
  73157. isVRDevicePresent(): boolean;
  73158. /**
  73159. * Gets the current webVR device
  73160. * @returns the current webVR device (or null)
  73161. */
  73162. getVRDevice(): any;
  73163. /**
  73164. * Initializes a webVR display and starts listening to display change events
  73165. * The onVRDisplayChangedObservable will be notified upon these changes
  73166. * @returns A promise containing a VRDisplay and if vr is supported
  73167. */
  73168. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  73169. /** @hidden */
  73170. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  73171. /**
  73172. * Call this function to switch to webVR mode
  73173. * Will do nothing if webVR is not supported or if there is no webVR device
  73174. * @see http://doc.babylonjs.com/how_to/webvr_camera
  73175. */
  73176. enableVR(): void;
  73177. /** @hidden */
  73178. _onVRFullScreenTriggered(): void;
  73179. }
  73180. }
  73181. declare module BABYLON {
  73182. /**
  73183. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  73184. * IMPORTANT!! The data is right-hand data.
  73185. * @export
  73186. * @interface DevicePose
  73187. */
  73188. export interface DevicePose {
  73189. /**
  73190. * The position of the device, values in array are [x,y,z].
  73191. */
  73192. readonly position: Nullable<Float32Array>;
  73193. /**
  73194. * The linearVelocity of the device, values in array are [x,y,z].
  73195. */
  73196. readonly linearVelocity: Nullable<Float32Array>;
  73197. /**
  73198. * The linearAcceleration of the device, values in array are [x,y,z].
  73199. */
  73200. readonly linearAcceleration: Nullable<Float32Array>;
  73201. /**
  73202. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  73203. */
  73204. readonly orientation: Nullable<Float32Array>;
  73205. /**
  73206. * The angularVelocity of the device, values in array are [x,y,z].
  73207. */
  73208. readonly angularVelocity: Nullable<Float32Array>;
  73209. /**
  73210. * The angularAcceleration of the device, values in array are [x,y,z].
  73211. */
  73212. readonly angularAcceleration: Nullable<Float32Array>;
  73213. }
  73214. /**
  73215. * Interface representing a pose controlled object in Babylon.
  73216. * A pose controlled object has both regular pose values as well as pose values
  73217. * from an external device such as a VR head mounted display
  73218. */
  73219. export interface PoseControlled {
  73220. /**
  73221. * The position of the object in babylon space.
  73222. */
  73223. position: Vector3;
  73224. /**
  73225. * The rotation quaternion of the object in babylon space.
  73226. */
  73227. rotationQuaternion: Quaternion;
  73228. /**
  73229. * The position of the device in babylon space.
  73230. */
  73231. devicePosition?: Vector3;
  73232. /**
  73233. * The rotation quaternion of the device in babylon space.
  73234. */
  73235. deviceRotationQuaternion: Quaternion;
  73236. /**
  73237. * The raw pose coming from the device.
  73238. */
  73239. rawPose: Nullable<DevicePose>;
  73240. /**
  73241. * The scale of the device to be used when translating from device space to babylon space.
  73242. */
  73243. deviceScaleFactor: number;
  73244. /**
  73245. * Updates the poseControlled values based on the input device pose.
  73246. * @param poseData the pose data to update the object with
  73247. */
  73248. updateFromDevice(poseData: DevicePose): void;
  73249. }
  73250. /**
  73251. * Set of options to customize the webVRCamera
  73252. */
  73253. export interface WebVROptions {
  73254. /**
  73255. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  73256. */
  73257. trackPosition?: boolean;
  73258. /**
  73259. * Sets the scale of the vrDevice in babylon space. (default: 1)
  73260. */
  73261. positionScale?: number;
  73262. /**
  73263. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  73264. */
  73265. displayName?: string;
  73266. /**
  73267. * Should the native controller meshes be initialized. (default: true)
  73268. */
  73269. controllerMeshes?: boolean;
  73270. /**
  73271. * Creating a default HemiLight only on controllers. (default: true)
  73272. */
  73273. defaultLightingOnControllers?: boolean;
  73274. /**
  73275. * If you don't want to use the default VR button of the helper. (default: false)
  73276. */
  73277. useCustomVRButton?: boolean;
  73278. /**
  73279. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  73280. */
  73281. customVRButton?: HTMLButtonElement;
  73282. /**
  73283. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  73284. */
  73285. rayLength?: number;
  73286. /**
  73287. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  73288. */
  73289. defaultHeight?: number;
  73290. /**
  73291. * If multiview should be used if availible (default: false)
  73292. */
  73293. useMultiview?: boolean;
  73294. }
  73295. /**
  73296. * This represents a WebVR camera.
  73297. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  73298. * @example http://doc.babylonjs.com/how_to/webvr_camera
  73299. */
  73300. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  73301. private webVROptions;
  73302. /**
  73303. * @hidden
  73304. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  73305. */
  73306. _vrDevice: any;
  73307. /**
  73308. * The rawPose of the vrDevice.
  73309. */
  73310. rawPose: Nullable<DevicePose>;
  73311. private _onVREnabled;
  73312. private _specsVersion;
  73313. private _attached;
  73314. private _frameData;
  73315. protected _descendants: Array<Node>;
  73316. private _deviceRoomPosition;
  73317. /** @hidden */
  73318. _deviceRoomRotationQuaternion: Quaternion;
  73319. private _standingMatrix;
  73320. /**
  73321. * Represents device position in babylon space.
  73322. */
  73323. devicePosition: Vector3;
  73324. /**
  73325. * Represents device rotation in babylon space.
  73326. */
  73327. deviceRotationQuaternion: Quaternion;
  73328. /**
  73329. * The scale of the device to be used when translating from device space to babylon space.
  73330. */
  73331. deviceScaleFactor: number;
  73332. private _deviceToWorld;
  73333. private _worldToDevice;
  73334. /**
  73335. * References to the webVR controllers for the vrDevice.
  73336. */
  73337. controllers: Array<WebVRController>;
  73338. /**
  73339. * Emits an event when a controller is attached.
  73340. */
  73341. onControllersAttachedObservable: Observable<WebVRController[]>;
  73342. /**
  73343. * Emits an event when a controller's mesh has been loaded;
  73344. */
  73345. onControllerMeshLoadedObservable: Observable<WebVRController>;
  73346. /**
  73347. * Emits an event when the HMD's pose has been updated.
  73348. */
  73349. onPoseUpdatedFromDeviceObservable: Observable<any>;
  73350. private _poseSet;
  73351. /**
  73352. * If the rig cameras be used as parent instead of this camera.
  73353. */
  73354. rigParenting: boolean;
  73355. private _lightOnControllers;
  73356. private _defaultHeight?;
  73357. /**
  73358. * Instantiates a WebVRFreeCamera.
  73359. * @param name The name of the WebVRFreeCamera
  73360. * @param position The starting anchor position for the camera
  73361. * @param scene The scene the camera belongs to
  73362. * @param webVROptions a set of customizable options for the webVRCamera
  73363. */
  73364. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  73365. /**
  73366. * Gets the device distance from the ground in meters.
  73367. * @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.
  73368. */
  73369. deviceDistanceToRoomGround(): number;
  73370. /**
  73371. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73372. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  73373. */
  73374. useStandingMatrix(callback?: (bool: boolean) => void): void;
  73375. /**
  73376. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73377. * @returns A promise with a boolean set to if the standing matrix is supported.
  73378. */
  73379. useStandingMatrixAsync(): Promise<boolean>;
  73380. /**
  73381. * Disposes the camera
  73382. */
  73383. dispose(): void;
  73384. /**
  73385. * Gets a vrController by name.
  73386. * @param name The name of the controller to retreive
  73387. * @returns the controller matching the name specified or null if not found
  73388. */
  73389. getControllerByName(name: string): Nullable<WebVRController>;
  73390. private _leftController;
  73391. /**
  73392. * The controller corrisponding to the users left hand.
  73393. */
  73394. readonly leftController: Nullable<WebVRController>;
  73395. private _rightController;
  73396. /**
  73397. * The controller corrisponding to the users right hand.
  73398. */
  73399. readonly rightController: Nullable<WebVRController>;
  73400. /**
  73401. * Casts a ray forward from the vrCamera's gaze.
  73402. * @param length Length of the ray (default: 100)
  73403. * @returns the ray corrisponding to the gaze
  73404. */
  73405. getForwardRay(length?: number): Ray;
  73406. /**
  73407. * @hidden
  73408. * Updates the camera based on device's frame data
  73409. */
  73410. _checkInputs(): void;
  73411. /**
  73412. * Updates the poseControlled values based on the input device pose.
  73413. * @param poseData Pose coming from the device
  73414. */
  73415. updateFromDevice(poseData: DevicePose): void;
  73416. private _htmlElementAttached;
  73417. private _detachIfAttached;
  73418. /**
  73419. * WebVR's attach control will start broadcasting frames to the device.
  73420. * Note that in certain browsers (chrome for example) this function must be called
  73421. * within a user-interaction callback. Example:
  73422. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73423. *
  73424. * @param element html element to attach the vrDevice to
  73425. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73426. */
  73427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73428. /**
  73429. * Detaches the camera from the html element and disables VR
  73430. *
  73431. * @param element html element to detach from
  73432. */
  73433. detachControl(element: HTMLElement): void;
  73434. /**
  73435. * @returns the name of this class
  73436. */
  73437. getClassName(): string;
  73438. /**
  73439. * Calls resetPose on the vrDisplay
  73440. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73441. */
  73442. resetToCurrentRotation(): void;
  73443. /**
  73444. * @hidden
  73445. * Updates the rig cameras (left and right eye)
  73446. */
  73447. _updateRigCameras(): void;
  73448. private _workingVector;
  73449. private _oneVector;
  73450. private _workingMatrix;
  73451. private updateCacheCalled;
  73452. private _correctPositionIfNotTrackPosition;
  73453. /**
  73454. * @hidden
  73455. * Updates the cached values of the camera
  73456. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73457. */
  73458. _updateCache(ignoreParentClass?: boolean): void;
  73459. /**
  73460. * @hidden
  73461. * Get current device position in babylon world
  73462. */
  73463. _computeDevicePosition(): void;
  73464. /**
  73465. * Updates the current device position and rotation in the babylon world
  73466. */
  73467. update(): void;
  73468. /**
  73469. * @hidden
  73470. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73471. * @returns an identity matrix
  73472. */
  73473. _getViewMatrix(): Matrix;
  73474. private _tmpMatrix;
  73475. /**
  73476. * This function is called by the two RIG cameras.
  73477. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73478. * @hidden
  73479. */
  73480. _getWebVRViewMatrix(): Matrix;
  73481. /** @hidden */
  73482. _getWebVRProjectionMatrix(): Matrix;
  73483. private _onGamepadConnectedObserver;
  73484. private _onGamepadDisconnectedObserver;
  73485. private _updateCacheWhenTrackingDisabledObserver;
  73486. /**
  73487. * Initializes the controllers and their meshes
  73488. */
  73489. initControllers(): void;
  73490. }
  73491. }
  73492. declare module BABYLON {
  73493. /**
  73494. * Size options for a post process
  73495. */
  73496. export type PostProcessOptions = {
  73497. width: number;
  73498. height: number;
  73499. };
  73500. /**
  73501. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73502. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73503. */
  73504. export class PostProcess {
  73505. /** Name of the PostProcess. */
  73506. name: string;
  73507. /**
  73508. * Gets or sets the unique id of the post process
  73509. */
  73510. uniqueId: number;
  73511. /**
  73512. * Width of the texture to apply the post process on
  73513. */
  73514. width: number;
  73515. /**
  73516. * Height of the texture to apply the post process on
  73517. */
  73518. height: number;
  73519. /**
  73520. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73521. * @hidden
  73522. */
  73523. _outputTexture: Nullable<InternalTexture>;
  73524. /**
  73525. * Sampling mode used by the shader
  73526. * See https://doc.babylonjs.com/classes/3.1/texture
  73527. */
  73528. renderTargetSamplingMode: number;
  73529. /**
  73530. * Clear color to use when screen clearing
  73531. */
  73532. clearColor: Color4;
  73533. /**
  73534. * If the buffer needs to be cleared before applying the post process. (default: true)
  73535. * Should be set to false if shader will overwrite all previous pixels.
  73536. */
  73537. autoClear: boolean;
  73538. /**
  73539. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73540. */
  73541. alphaMode: number;
  73542. /**
  73543. * Sets the setAlphaBlendConstants of the babylon engine
  73544. */
  73545. alphaConstants: Color4;
  73546. /**
  73547. * Animations to be used for the post processing
  73548. */
  73549. animations: Animation[];
  73550. /**
  73551. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73552. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73553. */
  73554. enablePixelPerfectMode: boolean;
  73555. /**
  73556. * Force the postprocess to be applied without taking in account viewport
  73557. */
  73558. forceFullscreenViewport: boolean;
  73559. /**
  73560. * List of inspectable custom properties (used by the Inspector)
  73561. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73562. */
  73563. inspectableCustomProperties: IInspectable[];
  73564. /**
  73565. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73566. *
  73567. * | Value | Type | Description |
  73568. * | ----- | ----------------------------------- | ----------- |
  73569. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73570. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73571. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73572. *
  73573. */
  73574. scaleMode: number;
  73575. /**
  73576. * Force textures to be a power of two (default: false)
  73577. */
  73578. alwaysForcePOT: boolean;
  73579. private _samples;
  73580. /**
  73581. * Number of sample textures (default: 1)
  73582. */
  73583. samples: number;
  73584. /**
  73585. * Modify the scale of the post process to be the same as the viewport (default: false)
  73586. */
  73587. adaptScaleToCurrentViewport: boolean;
  73588. private _camera;
  73589. private _scene;
  73590. private _engine;
  73591. private _options;
  73592. private _reusable;
  73593. private _textureType;
  73594. /**
  73595. * Smart array of input and output textures for the post process.
  73596. * @hidden
  73597. */
  73598. _textures: SmartArray<InternalTexture>;
  73599. /**
  73600. * The index in _textures that corresponds to the output texture.
  73601. * @hidden
  73602. */
  73603. _currentRenderTextureInd: number;
  73604. private _effect;
  73605. private _samplers;
  73606. private _fragmentUrl;
  73607. private _vertexUrl;
  73608. private _parameters;
  73609. private _scaleRatio;
  73610. protected _indexParameters: any;
  73611. private _shareOutputWithPostProcess;
  73612. private _texelSize;
  73613. private _forcedOutputTexture;
  73614. /**
  73615. * Returns the fragment url or shader name used in the post process.
  73616. * @returns the fragment url or name in the shader store.
  73617. */
  73618. getEffectName(): string;
  73619. /**
  73620. * An event triggered when the postprocess is activated.
  73621. */
  73622. onActivateObservable: Observable<Camera>;
  73623. private _onActivateObserver;
  73624. /**
  73625. * A function that is added to the onActivateObservable
  73626. */
  73627. onActivate: Nullable<(camera: Camera) => void>;
  73628. /**
  73629. * An event triggered when the postprocess changes its size.
  73630. */
  73631. onSizeChangedObservable: Observable<PostProcess>;
  73632. private _onSizeChangedObserver;
  73633. /**
  73634. * A function that is added to the onSizeChangedObservable
  73635. */
  73636. onSizeChanged: (postProcess: PostProcess) => void;
  73637. /**
  73638. * An event triggered when the postprocess applies its effect.
  73639. */
  73640. onApplyObservable: Observable<Effect>;
  73641. private _onApplyObserver;
  73642. /**
  73643. * A function that is added to the onApplyObservable
  73644. */
  73645. onApply: (effect: Effect) => void;
  73646. /**
  73647. * An event triggered before rendering the postprocess
  73648. */
  73649. onBeforeRenderObservable: Observable<Effect>;
  73650. private _onBeforeRenderObserver;
  73651. /**
  73652. * A function that is added to the onBeforeRenderObservable
  73653. */
  73654. onBeforeRender: (effect: Effect) => void;
  73655. /**
  73656. * An event triggered after rendering the postprocess
  73657. */
  73658. onAfterRenderObservable: Observable<Effect>;
  73659. private _onAfterRenderObserver;
  73660. /**
  73661. * A function that is added to the onAfterRenderObservable
  73662. */
  73663. onAfterRender: (efect: Effect) => void;
  73664. /**
  73665. * 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
  73666. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73667. */
  73668. inputTexture: InternalTexture;
  73669. /**
  73670. * Gets the camera which post process is applied to.
  73671. * @returns The camera the post process is applied to.
  73672. */
  73673. getCamera(): Camera;
  73674. /**
  73675. * Gets the texel size of the postprocess.
  73676. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73677. */
  73678. readonly texelSize: Vector2;
  73679. /**
  73680. * Creates a new instance PostProcess
  73681. * @param name The name of the PostProcess.
  73682. * @param fragmentUrl The url of the fragment shader to be used.
  73683. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73684. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73685. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73686. * @param camera The camera to apply the render pass to.
  73687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73688. * @param engine The engine which the post process will be applied. (default: current engine)
  73689. * @param reusable If the post process can be reused on the same frame. (default: false)
  73690. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73691. * @param textureType Type of textures used when performing the post process. (default: 0)
  73692. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73693. * @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
  73694. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73695. */
  73696. constructor(
  73697. /** Name of the PostProcess. */
  73698. 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);
  73699. /**
  73700. * Gets a string idenfifying the name of the class
  73701. * @returns "PostProcess" string
  73702. */
  73703. getClassName(): string;
  73704. /**
  73705. * Gets the engine which this post process belongs to.
  73706. * @returns The engine the post process was enabled with.
  73707. */
  73708. getEngine(): Engine;
  73709. /**
  73710. * The effect that is created when initializing the post process.
  73711. * @returns The created effect corrisponding the the postprocess.
  73712. */
  73713. getEffect(): Effect;
  73714. /**
  73715. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73716. * @param postProcess The post process to share the output with.
  73717. * @returns This post process.
  73718. */
  73719. shareOutputWith(postProcess: PostProcess): PostProcess;
  73720. /**
  73721. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73722. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73723. */
  73724. useOwnOutput(): void;
  73725. /**
  73726. * Updates the effect with the current post process compile time values and recompiles the shader.
  73727. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73728. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73729. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73730. * @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
  73731. * @param onCompiled Called when the shader has been compiled.
  73732. * @param onError Called if there is an error when compiling a shader.
  73733. */
  73734. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73735. /**
  73736. * The post process is reusable if it can be used multiple times within one frame.
  73737. * @returns If the post process is reusable
  73738. */
  73739. isReusable(): boolean;
  73740. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73741. markTextureDirty(): void;
  73742. /**
  73743. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73744. * 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.
  73745. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73746. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73747. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73748. * @returns The target texture that was bound to be written to.
  73749. */
  73750. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73751. /**
  73752. * If the post process is supported.
  73753. */
  73754. readonly isSupported: boolean;
  73755. /**
  73756. * The aspect ratio of the output texture.
  73757. */
  73758. readonly aspectRatio: number;
  73759. /**
  73760. * Get a value indicating if the post-process is ready to be used
  73761. * @returns true if the post-process is ready (shader is compiled)
  73762. */
  73763. isReady(): boolean;
  73764. /**
  73765. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73766. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73767. */
  73768. apply(): Nullable<Effect>;
  73769. private _disposeTextures;
  73770. /**
  73771. * Disposes the post process.
  73772. * @param camera The camera to dispose the post process on.
  73773. */
  73774. dispose(camera?: Camera): void;
  73775. }
  73776. }
  73777. declare module BABYLON {
  73778. /**
  73779. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73780. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73781. */
  73782. export class PostProcessManager {
  73783. private _scene;
  73784. private _indexBuffer;
  73785. private _vertexBuffers;
  73786. /**
  73787. * Creates a new instance PostProcess
  73788. * @param scene The scene that the post process is associated with.
  73789. */
  73790. constructor(scene: Scene);
  73791. private _prepareBuffers;
  73792. private _buildIndexBuffer;
  73793. /**
  73794. * Rebuilds the vertex buffers of the manager.
  73795. * @hidden
  73796. */
  73797. _rebuild(): void;
  73798. /**
  73799. * Prepares a frame to be run through a post process.
  73800. * @param sourceTexture The input texture to the post procesess. (default: null)
  73801. * @param postProcesses An array of post processes to be run. (default: null)
  73802. * @returns True if the post processes were able to be run.
  73803. * @hidden
  73804. */
  73805. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73806. /**
  73807. * Manually render a set of post processes to a texture.
  73808. * @param postProcesses An array of post processes to be run.
  73809. * @param targetTexture The target texture to render to.
  73810. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73811. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73812. * @param lodLevel defines which lod of the texture to render to
  73813. */
  73814. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73815. /**
  73816. * Finalize the result of the output of the postprocesses.
  73817. * @param doNotPresent If true the result will not be displayed to the screen.
  73818. * @param targetTexture The target texture to render to.
  73819. * @param faceIndex The index of the face to bind the target texture to.
  73820. * @param postProcesses The array of post processes to render.
  73821. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73822. * @hidden
  73823. */
  73824. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73825. /**
  73826. * Disposes of the post process manager.
  73827. */
  73828. dispose(): void;
  73829. }
  73830. }
  73831. declare module BABYLON {
  73832. interface AbstractScene {
  73833. /**
  73834. * The list of layers (background and foreground) of the scene
  73835. */
  73836. layers: Array<Layer>;
  73837. }
  73838. /**
  73839. * Defines the layer scene component responsible to manage any layers
  73840. * in a given scene.
  73841. */
  73842. export class LayerSceneComponent implements ISceneComponent {
  73843. /**
  73844. * The component name helpfull to identify the component in the list of scene components.
  73845. */
  73846. readonly name: string;
  73847. /**
  73848. * The scene the component belongs to.
  73849. */
  73850. scene: Scene;
  73851. private _engine;
  73852. /**
  73853. * Creates a new instance of the component for the given scene
  73854. * @param scene Defines the scene to register the component in
  73855. */
  73856. constructor(scene: Scene);
  73857. /**
  73858. * Registers the component in a given scene
  73859. */
  73860. register(): void;
  73861. /**
  73862. * Rebuilds the elements related to this component in case of
  73863. * context lost for instance.
  73864. */
  73865. rebuild(): void;
  73866. /**
  73867. * Disposes the component and the associated ressources.
  73868. */
  73869. dispose(): void;
  73870. private _draw;
  73871. private _drawCameraPredicate;
  73872. private _drawCameraBackground;
  73873. private _drawCameraForeground;
  73874. private _drawRenderTargetPredicate;
  73875. private _drawRenderTargetBackground;
  73876. private _drawRenderTargetForeground;
  73877. }
  73878. }
  73879. declare module BABYLON {
  73880. /** @hidden */
  73881. export var layerPixelShader: {
  73882. name: string;
  73883. shader: string;
  73884. };
  73885. }
  73886. declare module BABYLON {
  73887. /** @hidden */
  73888. export var layerVertexShader: {
  73889. name: string;
  73890. shader: string;
  73891. };
  73892. }
  73893. declare module BABYLON {
  73894. /**
  73895. * This represents a full screen 2d layer.
  73896. * This can be useful to display a picture in the background of your scene for instance.
  73897. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73898. */
  73899. export class Layer {
  73900. /**
  73901. * Define the name of the layer.
  73902. */
  73903. name: string;
  73904. /**
  73905. * Define the texture the layer should display.
  73906. */
  73907. texture: Nullable<Texture>;
  73908. /**
  73909. * Is the layer in background or foreground.
  73910. */
  73911. isBackground: boolean;
  73912. /**
  73913. * Define the color of the layer (instead of texture).
  73914. */
  73915. color: Color4;
  73916. /**
  73917. * Define the scale of the layer in order to zoom in out of the texture.
  73918. */
  73919. scale: Vector2;
  73920. /**
  73921. * Define an offset for the layer in order to shift the texture.
  73922. */
  73923. offset: Vector2;
  73924. /**
  73925. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73926. */
  73927. alphaBlendingMode: number;
  73928. /**
  73929. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73930. * Alpha test will not mix with the background color in case of transparency.
  73931. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73932. */
  73933. alphaTest: boolean;
  73934. /**
  73935. * Define a mask to restrict the layer to only some of the scene cameras.
  73936. */
  73937. layerMask: number;
  73938. /**
  73939. * Define the list of render target the layer is visible into.
  73940. */
  73941. renderTargetTextures: RenderTargetTexture[];
  73942. /**
  73943. * Define if the layer is only used in renderTarget or if it also
  73944. * renders in the main frame buffer of the canvas.
  73945. */
  73946. renderOnlyInRenderTargetTextures: boolean;
  73947. private _scene;
  73948. private _vertexBuffers;
  73949. private _indexBuffer;
  73950. private _effect;
  73951. private _alphaTestEffect;
  73952. /**
  73953. * An event triggered when the layer is disposed.
  73954. */
  73955. onDisposeObservable: Observable<Layer>;
  73956. private _onDisposeObserver;
  73957. /**
  73958. * Back compatibility with callback before the onDisposeObservable existed.
  73959. * The set callback will be triggered when the layer has been disposed.
  73960. */
  73961. onDispose: () => void;
  73962. /**
  73963. * An event triggered before rendering the scene
  73964. */
  73965. onBeforeRenderObservable: Observable<Layer>;
  73966. private _onBeforeRenderObserver;
  73967. /**
  73968. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73969. * The set callback will be triggered just before rendering the layer.
  73970. */
  73971. onBeforeRender: () => void;
  73972. /**
  73973. * An event triggered after rendering the scene
  73974. */
  73975. onAfterRenderObservable: Observable<Layer>;
  73976. private _onAfterRenderObserver;
  73977. /**
  73978. * Back compatibility with callback before the onAfterRenderObservable existed.
  73979. * The set callback will be triggered just after rendering the layer.
  73980. */
  73981. onAfterRender: () => void;
  73982. /**
  73983. * Instantiates a new layer.
  73984. * This represents a full screen 2d layer.
  73985. * This can be useful to display a picture in the background of your scene for instance.
  73986. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73987. * @param name Define the name of the layer in the scene
  73988. * @param imgUrl Define the url of the texture to display in the layer
  73989. * @param scene Define the scene the layer belongs to
  73990. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  73991. * @param color Defines a color for the layer
  73992. */
  73993. constructor(
  73994. /**
  73995. * Define the name of the layer.
  73996. */
  73997. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  73998. private _createIndexBuffer;
  73999. /** @hidden */
  74000. _rebuild(): void;
  74001. /**
  74002. * Renders the layer in the scene.
  74003. */
  74004. render(): void;
  74005. /**
  74006. * Disposes and releases the associated ressources.
  74007. */
  74008. dispose(): void;
  74009. }
  74010. }
  74011. declare module BABYLON {
  74012. interface AbstractScene {
  74013. /**
  74014. * The list of procedural textures added to the scene
  74015. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74016. */
  74017. proceduralTextures: Array<ProceduralTexture>;
  74018. }
  74019. /**
  74020. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  74021. * in a given scene.
  74022. */
  74023. export class ProceduralTextureSceneComponent implements ISceneComponent {
  74024. /**
  74025. * The component name helpfull to identify the component in the list of scene components.
  74026. */
  74027. readonly name: string;
  74028. /**
  74029. * The scene the component belongs to.
  74030. */
  74031. scene: Scene;
  74032. /**
  74033. * Creates a new instance of the component for the given scene
  74034. * @param scene Defines the scene to register the component in
  74035. */
  74036. constructor(scene: Scene);
  74037. /**
  74038. * Registers the component in a given scene
  74039. */
  74040. register(): void;
  74041. /**
  74042. * Rebuilds the elements related to this component in case of
  74043. * context lost for instance.
  74044. */
  74045. rebuild(): void;
  74046. /**
  74047. * Disposes the component and the associated ressources.
  74048. */
  74049. dispose(): void;
  74050. private _beforeClear;
  74051. }
  74052. }
  74053. declare module BABYLON {
  74054. interface Engine {
  74055. /**
  74056. * Creates a new render target cube texture
  74057. * @param size defines the size of the texture
  74058. * @param options defines the options used to create the texture
  74059. * @returns a new render target cube texture stored in an InternalTexture
  74060. */
  74061. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  74062. }
  74063. }
  74064. declare module BABYLON {
  74065. /** @hidden */
  74066. export var proceduralVertexShader: {
  74067. name: string;
  74068. shader: string;
  74069. };
  74070. }
  74071. declare module BABYLON {
  74072. /**
  74073. * 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.
  74074. * This is the base class of any Procedural texture and contains most of the shareable code.
  74075. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74076. */
  74077. export class ProceduralTexture extends Texture {
  74078. isCube: boolean;
  74079. /**
  74080. * Define if the texture is enabled or not (disabled texture will not render)
  74081. */
  74082. isEnabled: boolean;
  74083. /**
  74084. * Define if the texture must be cleared before rendering (default is true)
  74085. */
  74086. autoClear: boolean;
  74087. /**
  74088. * Callback called when the texture is generated
  74089. */
  74090. onGenerated: () => void;
  74091. /**
  74092. * Event raised when the texture is generated
  74093. */
  74094. onGeneratedObservable: Observable<ProceduralTexture>;
  74095. /** @hidden */
  74096. _generateMipMaps: boolean;
  74097. /** @hidden **/
  74098. _effect: Effect;
  74099. /** @hidden */
  74100. _textures: {
  74101. [key: string]: Texture;
  74102. };
  74103. private _size;
  74104. private _currentRefreshId;
  74105. private _refreshRate;
  74106. private _vertexBuffers;
  74107. private _indexBuffer;
  74108. private _uniforms;
  74109. private _samplers;
  74110. private _fragment;
  74111. private _floats;
  74112. private _ints;
  74113. private _floatsArrays;
  74114. private _colors3;
  74115. private _colors4;
  74116. private _vectors2;
  74117. private _vectors3;
  74118. private _matrices;
  74119. private _fallbackTexture;
  74120. private _fallbackTextureUsed;
  74121. private _engine;
  74122. private _cachedDefines;
  74123. private _contentUpdateId;
  74124. private _contentData;
  74125. /**
  74126. * Instantiates a new procedural texture.
  74127. * 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.
  74128. * This is the base class of any Procedural texture and contains most of the shareable code.
  74129. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74130. * @param name Define the name of the texture
  74131. * @param size Define the size of the texture to create
  74132. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  74133. * @param scene Define the scene the texture belongs to
  74134. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  74135. * @param generateMipMaps Define if the texture should creates mip maps or not
  74136. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  74137. */
  74138. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  74139. /**
  74140. * The effect that is created when initializing the post process.
  74141. * @returns The created effect corrisponding the the postprocess.
  74142. */
  74143. getEffect(): Effect;
  74144. /**
  74145. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  74146. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  74147. */
  74148. getContent(): Nullable<ArrayBufferView>;
  74149. private _createIndexBuffer;
  74150. /** @hidden */
  74151. _rebuild(): void;
  74152. /**
  74153. * Resets the texture in order to recreate its associated resources.
  74154. * This can be called in case of context loss
  74155. */
  74156. reset(): void;
  74157. protected _getDefines(): string;
  74158. /**
  74159. * Is the texture ready to be used ? (rendered at least once)
  74160. * @returns true if ready, otherwise, false.
  74161. */
  74162. isReady(): boolean;
  74163. /**
  74164. * Resets the refresh counter of the texture and start bak from scratch.
  74165. * Could be useful to regenerate the texture if it is setup to render only once.
  74166. */
  74167. resetRefreshCounter(): void;
  74168. /**
  74169. * Set the fragment shader to use in order to render the texture.
  74170. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  74171. */
  74172. setFragment(fragment: any): void;
  74173. /**
  74174. * Define the refresh rate of the texture or the rendering frequency.
  74175. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74176. */
  74177. refreshRate: number;
  74178. /** @hidden */
  74179. _shouldRender(): boolean;
  74180. /**
  74181. * Get the size the texture is rendering at.
  74182. * @returns the size (texture is always squared)
  74183. */
  74184. getRenderSize(): number;
  74185. /**
  74186. * Resize the texture to new value.
  74187. * @param size Define the new size the texture should have
  74188. * @param generateMipMaps Define whether the new texture should create mip maps
  74189. */
  74190. resize(size: number, generateMipMaps: boolean): void;
  74191. private _checkUniform;
  74192. /**
  74193. * Set a texture in the shader program used to render.
  74194. * @param name Define the name of the uniform samplers as defined in the shader
  74195. * @param texture Define the texture to bind to this sampler
  74196. * @return the texture itself allowing "fluent" like uniform updates
  74197. */
  74198. setTexture(name: string, texture: Texture): ProceduralTexture;
  74199. /**
  74200. * Set a float in the shader.
  74201. * @param name Define the name of the uniform as defined in the shader
  74202. * @param value Define the value to give to the uniform
  74203. * @return the texture itself allowing "fluent" like uniform updates
  74204. */
  74205. setFloat(name: string, value: number): ProceduralTexture;
  74206. /**
  74207. * Set a int in the shader.
  74208. * @param name Define the name of the uniform as defined in the shader
  74209. * @param value Define the value to give to the uniform
  74210. * @return the texture itself allowing "fluent" like uniform updates
  74211. */
  74212. setInt(name: string, value: number): ProceduralTexture;
  74213. /**
  74214. * Set an array of floats in the shader.
  74215. * @param name Define the name of the uniform as defined in the shader
  74216. * @param value Define the value to give to the uniform
  74217. * @return the texture itself allowing "fluent" like uniform updates
  74218. */
  74219. setFloats(name: string, value: number[]): ProceduralTexture;
  74220. /**
  74221. * Set a vec3 in the shader from a Color3.
  74222. * @param name Define the name of the uniform as defined in the shader
  74223. * @param value Define the value to give to the uniform
  74224. * @return the texture itself allowing "fluent" like uniform updates
  74225. */
  74226. setColor3(name: string, value: Color3): ProceduralTexture;
  74227. /**
  74228. * Set a vec4 in the shader from a Color4.
  74229. * @param name Define the name of the uniform as defined in the shader
  74230. * @param value Define the value to give to the uniform
  74231. * @return the texture itself allowing "fluent" like uniform updates
  74232. */
  74233. setColor4(name: string, value: Color4): ProceduralTexture;
  74234. /**
  74235. * Set a vec2 in the shader from a Vector2.
  74236. * @param name Define the name of the uniform as defined in the shader
  74237. * @param value Define the value to give to the uniform
  74238. * @return the texture itself allowing "fluent" like uniform updates
  74239. */
  74240. setVector2(name: string, value: Vector2): ProceduralTexture;
  74241. /**
  74242. * Set a vec3 in the shader from a Vector3.
  74243. * @param name Define the name of the uniform as defined in the shader
  74244. * @param value Define the value to give to the uniform
  74245. * @return the texture itself allowing "fluent" like uniform updates
  74246. */
  74247. setVector3(name: string, value: Vector3): ProceduralTexture;
  74248. /**
  74249. * Set a mat4 in the shader from a MAtrix.
  74250. * @param name Define the name of the uniform as defined in the shader
  74251. * @param value Define the value to give to the uniform
  74252. * @return the texture itself allowing "fluent" like uniform updates
  74253. */
  74254. setMatrix(name: string, value: Matrix): ProceduralTexture;
  74255. /**
  74256. * Render the texture to its associated render target.
  74257. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  74258. */
  74259. render(useCameraPostProcess?: boolean): void;
  74260. /**
  74261. * Clone the texture.
  74262. * @returns the cloned texture
  74263. */
  74264. clone(): ProceduralTexture;
  74265. /**
  74266. * Dispose the texture and release its asoociated resources.
  74267. */
  74268. dispose(): void;
  74269. }
  74270. }
  74271. declare module BABYLON {
  74272. /**
  74273. * This represents the base class for particle system in Babylon.
  74274. * 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.
  74275. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74276. * @example https://doc.babylonjs.com/babylon101/particles
  74277. */
  74278. export class BaseParticleSystem {
  74279. /**
  74280. * Source color is added to the destination color without alpha affecting the result
  74281. */
  74282. static BLENDMODE_ONEONE: number;
  74283. /**
  74284. * Blend current color and particle color using particle’s alpha
  74285. */
  74286. static BLENDMODE_STANDARD: number;
  74287. /**
  74288. * Add current color and particle color multiplied by particle’s alpha
  74289. */
  74290. static BLENDMODE_ADD: number;
  74291. /**
  74292. * Multiply current color with particle color
  74293. */
  74294. static BLENDMODE_MULTIPLY: number;
  74295. /**
  74296. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  74297. */
  74298. static BLENDMODE_MULTIPLYADD: number;
  74299. /**
  74300. * List of animations used by the particle system.
  74301. */
  74302. animations: Animation[];
  74303. /**
  74304. * The id of the Particle system.
  74305. */
  74306. id: string;
  74307. /**
  74308. * The friendly name of the Particle system.
  74309. */
  74310. name: string;
  74311. /**
  74312. * The rendering group used by the Particle system to chose when to render.
  74313. */
  74314. renderingGroupId: number;
  74315. /**
  74316. * The emitter represents the Mesh or position we are attaching the particle system to.
  74317. */
  74318. emitter: Nullable<AbstractMesh | Vector3>;
  74319. /**
  74320. * The maximum number of particles to emit per frame
  74321. */
  74322. emitRate: number;
  74323. /**
  74324. * If you want to launch only a few particles at once, that can be done, as well.
  74325. */
  74326. manualEmitCount: number;
  74327. /**
  74328. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74329. */
  74330. updateSpeed: number;
  74331. /**
  74332. * The amount of time the particle system is running (depends of the overall update speed).
  74333. */
  74334. targetStopDuration: number;
  74335. /**
  74336. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74337. */
  74338. disposeOnStop: boolean;
  74339. /**
  74340. * Minimum power of emitting particles.
  74341. */
  74342. minEmitPower: number;
  74343. /**
  74344. * Maximum power of emitting particles.
  74345. */
  74346. maxEmitPower: number;
  74347. /**
  74348. * Minimum life time of emitting particles.
  74349. */
  74350. minLifeTime: number;
  74351. /**
  74352. * Maximum life time of emitting particles.
  74353. */
  74354. maxLifeTime: number;
  74355. /**
  74356. * Minimum Size of emitting particles.
  74357. */
  74358. minSize: number;
  74359. /**
  74360. * Maximum Size of emitting particles.
  74361. */
  74362. maxSize: number;
  74363. /**
  74364. * Minimum scale of emitting particles on X axis.
  74365. */
  74366. minScaleX: number;
  74367. /**
  74368. * Maximum scale of emitting particles on X axis.
  74369. */
  74370. maxScaleX: number;
  74371. /**
  74372. * Minimum scale of emitting particles on Y axis.
  74373. */
  74374. minScaleY: number;
  74375. /**
  74376. * Maximum scale of emitting particles on Y axis.
  74377. */
  74378. maxScaleY: number;
  74379. /**
  74380. * Gets or sets the minimal initial rotation in radians.
  74381. */
  74382. minInitialRotation: number;
  74383. /**
  74384. * Gets or sets the maximal initial rotation in radians.
  74385. */
  74386. maxInitialRotation: number;
  74387. /**
  74388. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74389. */
  74390. minAngularSpeed: number;
  74391. /**
  74392. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74393. */
  74394. maxAngularSpeed: number;
  74395. /**
  74396. * The texture used to render each particle. (this can be a spritesheet)
  74397. */
  74398. particleTexture: Nullable<Texture>;
  74399. /**
  74400. * The layer mask we are rendering the particles through.
  74401. */
  74402. layerMask: number;
  74403. /**
  74404. * This can help using your own shader to render the particle system.
  74405. * The according effect will be created
  74406. */
  74407. customShader: any;
  74408. /**
  74409. * By default particle system starts as soon as they are created. This prevents the
  74410. * automatic start to happen and let you decide when to start emitting particles.
  74411. */
  74412. preventAutoStart: boolean;
  74413. private _noiseTexture;
  74414. /**
  74415. * Gets or sets a texture used to add random noise to particle positions
  74416. */
  74417. noiseTexture: Nullable<ProceduralTexture>;
  74418. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74419. noiseStrength: Vector3;
  74420. /**
  74421. * Callback triggered when the particle animation is ending.
  74422. */
  74423. onAnimationEnd: Nullable<() => void>;
  74424. /**
  74425. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74426. */
  74427. blendMode: number;
  74428. /**
  74429. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74430. * to override the particles.
  74431. */
  74432. forceDepthWrite: boolean;
  74433. /** 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 */
  74434. preWarmCycles: number;
  74435. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74436. preWarmStepOffset: number;
  74437. /**
  74438. * 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)
  74439. */
  74440. spriteCellChangeSpeed: number;
  74441. /**
  74442. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74443. */
  74444. startSpriteCellID: number;
  74445. /**
  74446. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74447. */
  74448. endSpriteCellID: number;
  74449. /**
  74450. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74451. */
  74452. spriteCellWidth: number;
  74453. /**
  74454. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74455. */
  74456. spriteCellHeight: number;
  74457. /**
  74458. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74459. */
  74460. spriteRandomStartCell: boolean;
  74461. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74462. translationPivot: Vector2;
  74463. /** @hidden */
  74464. protected _isAnimationSheetEnabled: boolean;
  74465. /**
  74466. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74467. */
  74468. beginAnimationOnStart: boolean;
  74469. /**
  74470. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74471. */
  74472. beginAnimationFrom: number;
  74473. /**
  74474. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74475. */
  74476. beginAnimationTo: number;
  74477. /**
  74478. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74479. */
  74480. beginAnimationLoop: boolean;
  74481. /**
  74482. * Gets or sets a world offset applied to all particles
  74483. */
  74484. worldOffset: Vector3;
  74485. /**
  74486. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74487. */
  74488. isAnimationSheetEnabled: boolean;
  74489. /**
  74490. * Get hosting scene
  74491. * @returns the scene
  74492. */
  74493. getScene(): Scene;
  74494. /**
  74495. * You can use gravity if you want to give an orientation to your particles.
  74496. */
  74497. gravity: Vector3;
  74498. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74499. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74500. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74501. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74502. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74503. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74504. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74505. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74506. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74507. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74508. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74509. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74510. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74511. /**
  74512. * Defines the delay in milliseconds before starting the system (0 by default)
  74513. */
  74514. startDelay: number;
  74515. /**
  74516. * Gets the current list of drag gradients.
  74517. * You must use addDragGradient and removeDragGradient to udpate this list
  74518. * @returns the list of drag gradients
  74519. */
  74520. getDragGradients(): Nullable<Array<FactorGradient>>;
  74521. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74522. limitVelocityDamping: number;
  74523. /**
  74524. * Gets the current list of limit velocity gradients.
  74525. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74526. * @returns the list of limit velocity gradients
  74527. */
  74528. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74529. /**
  74530. * Gets the current list of color gradients.
  74531. * You must use addColorGradient and removeColorGradient to udpate this list
  74532. * @returns the list of color gradients
  74533. */
  74534. getColorGradients(): Nullable<Array<ColorGradient>>;
  74535. /**
  74536. * Gets the current list of size gradients.
  74537. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74538. * @returns the list of size gradients
  74539. */
  74540. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74541. /**
  74542. * Gets the current list of color remap gradients.
  74543. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74544. * @returns the list of color remap gradients
  74545. */
  74546. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74547. /**
  74548. * Gets the current list of alpha remap gradients.
  74549. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74550. * @returns the list of alpha remap gradients
  74551. */
  74552. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74553. /**
  74554. * Gets the current list of life time gradients.
  74555. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74556. * @returns the list of life time gradients
  74557. */
  74558. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74559. /**
  74560. * Gets the current list of angular speed gradients.
  74561. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74562. * @returns the list of angular speed gradients
  74563. */
  74564. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74565. /**
  74566. * Gets the current list of velocity gradients.
  74567. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74568. * @returns the list of velocity gradients
  74569. */
  74570. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74571. /**
  74572. * Gets the current list of start size gradients.
  74573. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74574. * @returns the list of start size gradients
  74575. */
  74576. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74577. /**
  74578. * Gets the current list of emit rate gradients.
  74579. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74580. * @returns the list of emit rate gradients
  74581. */
  74582. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74583. /**
  74584. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74585. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74586. */
  74587. direction1: Vector3;
  74588. /**
  74589. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74590. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74591. */
  74592. direction2: Vector3;
  74593. /**
  74594. * 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.
  74595. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74596. */
  74597. minEmitBox: Vector3;
  74598. /**
  74599. * 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.
  74600. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74601. */
  74602. maxEmitBox: Vector3;
  74603. /**
  74604. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74605. */
  74606. color1: Color4;
  74607. /**
  74608. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74609. */
  74610. color2: Color4;
  74611. /**
  74612. * Color the particle will have at the end of its lifetime
  74613. */
  74614. colorDead: Color4;
  74615. /**
  74616. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74617. */
  74618. textureMask: Color4;
  74619. /**
  74620. * The particle emitter type defines the emitter used by the particle system.
  74621. * It can be for example box, sphere, or cone...
  74622. */
  74623. particleEmitterType: IParticleEmitterType;
  74624. /** @hidden */
  74625. _isSubEmitter: boolean;
  74626. /**
  74627. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74628. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74629. */
  74630. billboardMode: number;
  74631. protected _isBillboardBased: boolean;
  74632. /**
  74633. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74634. */
  74635. isBillboardBased: boolean;
  74636. /**
  74637. * The scene the particle system belongs to.
  74638. */
  74639. protected _scene: Scene;
  74640. /**
  74641. * Local cache of defines for image processing.
  74642. */
  74643. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74644. /**
  74645. * Default configuration related to image processing available in the standard Material.
  74646. */
  74647. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74648. /**
  74649. * Gets the image processing configuration used either in this material.
  74650. */
  74651. /**
  74652. * Sets the Default image processing configuration used either in the this material.
  74653. *
  74654. * If sets to null, the scene one is in use.
  74655. */
  74656. imageProcessingConfiguration: ImageProcessingConfiguration;
  74657. /**
  74658. * Attaches a new image processing configuration to the Standard Material.
  74659. * @param configuration
  74660. */
  74661. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74662. /** @hidden */
  74663. protected _reset(): void;
  74664. /** @hidden */
  74665. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74666. /**
  74667. * Instantiates a particle system.
  74668. * 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.
  74669. * @param name The name of the particle system
  74670. */
  74671. constructor(name: string);
  74672. /**
  74673. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74674. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74675. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74676. * @returns the emitter
  74677. */
  74678. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74679. /**
  74680. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74681. * @param radius The radius of the hemisphere to emit from
  74682. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74683. * @returns the emitter
  74684. */
  74685. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74686. /**
  74687. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74688. * @param radius The radius of the sphere to emit from
  74689. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74690. * @returns the emitter
  74691. */
  74692. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74693. /**
  74694. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74695. * @param radius The radius of the sphere to emit from
  74696. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74697. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74698. * @returns the emitter
  74699. */
  74700. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74701. /**
  74702. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74703. * @param radius The radius of the emission cylinder
  74704. * @param height The height of the emission cylinder
  74705. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74706. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74707. * @returns the emitter
  74708. */
  74709. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74710. /**
  74711. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74712. * @param radius The radius of the cylinder to emit from
  74713. * @param height The height of the emission cylinder
  74714. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74717. * @returns the emitter
  74718. */
  74719. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74720. /**
  74721. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74722. * @param radius The radius of the cone to emit from
  74723. * @param angle The base angle of the cone
  74724. * @returns the emitter
  74725. */
  74726. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74727. /**
  74728. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74729. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74730. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74731. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74732. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74733. * @returns the emitter
  74734. */
  74735. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74736. }
  74737. }
  74738. declare module BABYLON {
  74739. /**
  74740. * Type of sub emitter
  74741. */
  74742. export enum SubEmitterType {
  74743. /**
  74744. * Attached to the particle over it's lifetime
  74745. */
  74746. ATTACHED = 0,
  74747. /**
  74748. * Created when the particle dies
  74749. */
  74750. END = 1
  74751. }
  74752. /**
  74753. * Sub emitter class used to emit particles from an existing particle
  74754. */
  74755. export class SubEmitter {
  74756. /**
  74757. * the particle system to be used by the sub emitter
  74758. */
  74759. particleSystem: ParticleSystem;
  74760. /**
  74761. * Type of the submitter (Default: END)
  74762. */
  74763. type: SubEmitterType;
  74764. /**
  74765. * 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)
  74766. * Note: This only is supported when using an emitter of type Mesh
  74767. */
  74768. inheritDirection: boolean;
  74769. /**
  74770. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74771. */
  74772. inheritedVelocityAmount: number;
  74773. /**
  74774. * Creates a sub emitter
  74775. * @param particleSystem the particle system to be used by the sub emitter
  74776. */
  74777. constructor(
  74778. /**
  74779. * the particle system to be used by the sub emitter
  74780. */
  74781. particleSystem: ParticleSystem);
  74782. /**
  74783. * Clones the sub emitter
  74784. * @returns the cloned sub emitter
  74785. */
  74786. clone(): SubEmitter;
  74787. /**
  74788. * Serialize current object to a JSON object
  74789. * @returns the serialized object
  74790. */
  74791. serialize(): any;
  74792. /** @hidden */
  74793. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74794. /**
  74795. * Creates a new SubEmitter from a serialized JSON version
  74796. * @param serializationObject defines the JSON object to read from
  74797. * @param scene defines the hosting scene
  74798. * @param rootUrl defines the rootUrl for data loading
  74799. * @returns a new SubEmitter
  74800. */
  74801. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74802. /** Release associated resources */
  74803. dispose(): void;
  74804. }
  74805. }
  74806. declare module BABYLON {
  74807. /** @hidden */
  74808. export var clipPlaneFragmentDeclaration: {
  74809. name: string;
  74810. shader: string;
  74811. };
  74812. }
  74813. declare module BABYLON {
  74814. /** @hidden */
  74815. export var imageProcessingDeclaration: {
  74816. name: string;
  74817. shader: string;
  74818. };
  74819. }
  74820. declare module BABYLON {
  74821. /** @hidden */
  74822. export var imageProcessingFunctions: {
  74823. name: string;
  74824. shader: string;
  74825. };
  74826. }
  74827. declare module BABYLON {
  74828. /** @hidden */
  74829. export var clipPlaneFragment: {
  74830. name: string;
  74831. shader: string;
  74832. };
  74833. }
  74834. declare module BABYLON {
  74835. /** @hidden */
  74836. export var particlesPixelShader: {
  74837. name: string;
  74838. shader: string;
  74839. };
  74840. }
  74841. declare module BABYLON {
  74842. /** @hidden */
  74843. export var clipPlaneVertexDeclaration: {
  74844. name: string;
  74845. shader: string;
  74846. };
  74847. }
  74848. declare module BABYLON {
  74849. /** @hidden */
  74850. export var clipPlaneVertex: {
  74851. name: string;
  74852. shader: string;
  74853. };
  74854. }
  74855. declare module BABYLON {
  74856. /** @hidden */
  74857. export var particlesVertexShader: {
  74858. name: string;
  74859. shader: string;
  74860. };
  74861. }
  74862. declare module BABYLON {
  74863. /**
  74864. * This represents a particle system in Babylon.
  74865. * 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.
  74866. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74867. * @example https://doc.babylonjs.com/babylon101/particles
  74868. */
  74869. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74870. /**
  74871. * Billboard mode will only apply to Y axis
  74872. */
  74873. static readonly BILLBOARDMODE_Y: number;
  74874. /**
  74875. * Billboard mode will apply to all axes
  74876. */
  74877. static readonly BILLBOARDMODE_ALL: number;
  74878. /**
  74879. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74880. */
  74881. static readonly BILLBOARDMODE_STRETCHED: number;
  74882. /**
  74883. * This function can be defined to provide custom update for active particles.
  74884. * This function will be called instead of regular update (age, position, color, etc.).
  74885. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74886. */
  74887. updateFunction: (particles: Particle[]) => void;
  74888. private _emitterWorldMatrix;
  74889. /**
  74890. * This function can be defined to specify initial direction for every new particle.
  74891. * It by default use the emitterType defined function
  74892. */
  74893. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74894. /**
  74895. * This function can be defined to specify initial position for every new particle.
  74896. * It by default use the emitterType defined function
  74897. */
  74898. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74899. /**
  74900. * @hidden
  74901. */
  74902. _inheritedVelocityOffset: Vector3;
  74903. /**
  74904. * An event triggered when the system is disposed
  74905. */
  74906. onDisposeObservable: Observable<ParticleSystem>;
  74907. private _onDisposeObserver;
  74908. /**
  74909. * Sets a callback that will be triggered when the system is disposed
  74910. */
  74911. onDispose: () => void;
  74912. private _particles;
  74913. private _epsilon;
  74914. private _capacity;
  74915. private _stockParticles;
  74916. private _newPartsExcess;
  74917. private _vertexData;
  74918. private _vertexBuffer;
  74919. private _vertexBuffers;
  74920. private _spriteBuffer;
  74921. private _indexBuffer;
  74922. private _effect;
  74923. private _customEffect;
  74924. private _cachedDefines;
  74925. private _scaledColorStep;
  74926. private _colorDiff;
  74927. private _scaledDirection;
  74928. private _scaledGravity;
  74929. private _currentRenderId;
  74930. private _alive;
  74931. private _useInstancing;
  74932. private _started;
  74933. private _stopped;
  74934. private _actualFrame;
  74935. private _scaledUpdateSpeed;
  74936. private _vertexBufferSize;
  74937. /** @hidden */
  74938. _currentEmitRateGradient: Nullable<FactorGradient>;
  74939. /** @hidden */
  74940. _currentEmitRate1: number;
  74941. /** @hidden */
  74942. _currentEmitRate2: number;
  74943. /** @hidden */
  74944. _currentStartSizeGradient: Nullable<FactorGradient>;
  74945. /** @hidden */
  74946. _currentStartSize1: number;
  74947. /** @hidden */
  74948. _currentStartSize2: number;
  74949. private readonly _rawTextureWidth;
  74950. private _rampGradientsTexture;
  74951. private _useRampGradients;
  74952. /** Gets or sets a boolean indicating that ramp gradients must be used
  74953. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74954. */
  74955. useRampGradients: boolean;
  74956. /**
  74957. * 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.
  74958. * 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: [])
  74959. */
  74960. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74961. private _subEmitters;
  74962. /**
  74963. * @hidden
  74964. * If the particle systems emitter should be disposed when the particle system is disposed
  74965. */
  74966. _disposeEmitterOnDispose: boolean;
  74967. /**
  74968. * The current active Sub-systems, this property is used by the root particle system only.
  74969. */
  74970. activeSubSystems: Array<ParticleSystem>;
  74971. private _rootParticleSystem;
  74972. /**
  74973. * Gets the current list of active particles
  74974. */
  74975. readonly particles: Particle[];
  74976. /**
  74977. * Returns the string "ParticleSystem"
  74978. * @returns a string containing the class name
  74979. */
  74980. getClassName(): string;
  74981. /**
  74982. * Instantiates a particle system.
  74983. * 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.
  74984. * @param name The name of the particle system
  74985. * @param capacity The max number of particles alive at the same time
  74986. * @param scene The scene the particle system belongs to
  74987. * @param customEffect a custom effect used to change the way particles are rendered by default
  74988. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  74989. * @param epsilon Offset used to render the particles
  74990. */
  74991. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  74992. private _addFactorGradient;
  74993. private _removeFactorGradient;
  74994. /**
  74995. * Adds a new life time gradient
  74996. * @param gradient defines the gradient to use (between 0 and 1)
  74997. * @param factor defines the life time factor to affect to the specified gradient
  74998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74999. * @returns the current particle system
  75000. */
  75001. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75002. /**
  75003. * Remove a specific life time gradient
  75004. * @param gradient defines the gradient to remove
  75005. * @returns the current particle system
  75006. */
  75007. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75008. /**
  75009. * Adds a new size gradient
  75010. * @param gradient defines the gradient to use (between 0 and 1)
  75011. * @param factor defines the size factor to affect to the specified gradient
  75012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75013. * @returns the current particle system
  75014. */
  75015. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75016. /**
  75017. * Remove a specific size gradient
  75018. * @param gradient defines the gradient to remove
  75019. * @returns the current particle system
  75020. */
  75021. removeSizeGradient(gradient: number): IParticleSystem;
  75022. /**
  75023. * Adds a new color remap gradient
  75024. * @param gradient defines the gradient to use (between 0 and 1)
  75025. * @param min defines the color remap minimal range
  75026. * @param max defines the color remap maximal range
  75027. * @returns the current particle system
  75028. */
  75029. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75030. /**
  75031. * Remove a specific color remap gradient
  75032. * @param gradient defines the gradient to remove
  75033. * @returns the current particle system
  75034. */
  75035. removeColorRemapGradient(gradient: number): IParticleSystem;
  75036. /**
  75037. * Adds a new alpha remap gradient
  75038. * @param gradient defines the gradient to use (between 0 and 1)
  75039. * @param min defines the alpha remap minimal range
  75040. * @param max defines the alpha remap maximal range
  75041. * @returns the current particle system
  75042. */
  75043. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75044. /**
  75045. * Remove a specific alpha remap gradient
  75046. * @param gradient defines the gradient to remove
  75047. * @returns the current particle system
  75048. */
  75049. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  75050. /**
  75051. * Adds a new angular speed gradient
  75052. * @param gradient defines the gradient to use (between 0 and 1)
  75053. * @param factor defines the angular speed to affect to the specified gradient
  75054. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75055. * @returns the current particle system
  75056. */
  75057. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75058. /**
  75059. * Remove a specific angular speed gradient
  75060. * @param gradient defines the gradient to remove
  75061. * @returns the current particle system
  75062. */
  75063. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75064. /**
  75065. * Adds a new velocity gradient
  75066. * @param gradient defines the gradient to use (between 0 and 1)
  75067. * @param factor defines the velocity to affect to the specified gradient
  75068. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75069. * @returns the current particle system
  75070. */
  75071. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75072. /**
  75073. * Remove a specific velocity gradient
  75074. * @param gradient defines the gradient to remove
  75075. * @returns the current particle system
  75076. */
  75077. removeVelocityGradient(gradient: number): IParticleSystem;
  75078. /**
  75079. * Adds a new limit velocity gradient
  75080. * @param gradient defines the gradient to use (between 0 and 1)
  75081. * @param factor defines the limit velocity value to affect to the specified gradient
  75082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75083. * @returns the current particle system
  75084. */
  75085. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75086. /**
  75087. * Remove a specific limit velocity gradient
  75088. * @param gradient defines the gradient to remove
  75089. * @returns the current particle system
  75090. */
  75091. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75092. /**
  75093. * Adds a new drag gradient
  75094. * @param gradient defines the gradient to use (between 0 and 1)
  75095. * @param factor defines the drag value to affect to the specified gradient
  75096. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75097. * @returns the current particle system
  75098. */
  75099. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75100. /**
  75101. * Remove a specific drag gradient
  75102. * @param gradient defines the gradient to remove
  75103. * @returns the current particle system
  75104. */
  75105. removeDragGradient(gradient: number): IParticleSystem;
  75106. /**
  75107. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75108. * @param gradient defines the gradient to use (between 0 and 1)
  75109. * @param factor defines the emit rate value to affect to the specified gradient
  75110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75111. * @returns the current particle system
  75112. */
  75113. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75114. /**
  75115. * Remove a specific emit rate gradient
  75116. * @param gradient defines the gradient to remove
  75117. * @returns the current particle system
  75118. */
  75119. removeEmitRateGradient(gradient: number): IParticleSystem;
  75120. /**
  75121. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75122. * @param gradient defines the gradient to use (between 0 and 1)
  75123. * @param factor defines the start size value to affect to the specified gradient
  75124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75125. * @returns the current particle system
  75126. */
  75127. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75128. /**
  75129. * Remove a specific start size gradient
  75130. * @param gradient defines the gradient to remove
  75131. * @returns the current particle system
  75132. */
  75133. removeStartSizeGradient(gradient: number): IParticleSystem;
  75134. private _createRampGradientTexture;
  75135. /**
  75136. * Gets the current list of ramp gradients.
  75137. * You must use addRampGradient and removeRampGradient to udpate this list
  75138. * @returns the list of ramp gradients
  75139. */
  75140. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75141. /**
  75142. * Adds a new ramp gradient used to remap particle colors
  75143. * @param gradient defines the gradient to use (between 0 and 1)
  75144. * @param color defines the color to affect to the specified gradient
  75145. * @returns the current particle system
  75146. */
  75147. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  75148. /**
  75149. * Remove a specific ramp gradient
  75150. * @param gradient defines the gradient to remove
  75151. * @returns the current particle system
  75152. */
  75153. removeRampGradient(gradient: number): ParticleSystem;
  75154. /**
  75155. * Adds a new color gradient
  75156. * @param gradient defines the gradient to use (between 0 and 1)
  75157. * @param color1 defines the color to affect to the specified gradient
  75158. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75159. * @returns this particle system
  75160. */
  75161. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75162. /**
  75163. * Remove a specific color gradient
  75164. * @param gradient defines the gradient to remove
  75165. * @returns this particle system
  75166. */
  75167. removeColorGradient(gradient: number): IParticleSystem;
  75168. private _fetchR;
  75169. protected _reset(): void;
  75170. private _resetEffect;
  75171. private _createVertexBuffers;
  75172. private _createIndexBuffer;
  75173. /**
  75174. * Gets the maximum number of particles active at the same time.
  75175. * @returns The max number of active particles.
  75176. */
  75177. getCapacity(): number;
  75178. /**
  75179. * Gets whether there are still active particles in the system.
  75180. * @returns True if it is alive, otherwise false.
  75181. */
  75182. isAlive(): boolean;
  75183. /**
  75184. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75185. * @returns True if it has been started, otherwise false.
  75186. */
  75187. isStarted(): boolean;
  75188. private _prepareSubEmitterInternalArray;
  75189. /**
  75190. * Starts the particle system and begins to emit
  75191. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75192. */
  75193. start(delay?: number): void;
  75194. /**
  75195. * Stops the particle system.
  75196. * @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.
  75197. */
  75198. stop(stopSubEmitters?: boolean): void;
  75199. /**
  75200. * Remove all active particles
  75201. */
  75202. reset(): void;
  75203. /**
  75204. * @hidden (for internal use only)
  75205. */
  75206. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  75207. /**
  75208. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  75209. * Its lifetime will start back at 0.
  75210. */
  75211. recycleParticle: (particle: Particle) => void;
  75212. private _stopSubEmitters;
  75213. private _createParticle;
  75214. private _removeFromRoot;
  75215. private _emitFromParticle;
  75216. private _update;
  75217. /** @hidden */
  75218. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  75219. /** @hidden */
  75220. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  75221. /** @hidden */
  75222. private _getEffect;
  75223. /**
  75224. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75225. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  75226. */
  75227. animate(preWarmOnly?: boolean): void;
  75228. private _appendParticleVertices;
  75229. /**
  75230. * Rebuilds the particle system.
  75231. */
  75232. rebuild(): void;
  75233. /**
  75234. * Is this system ready to be used/rendered
  75235. * @return true if the system is ready
  75236. */
  75237. isReady(): boolean;
  75238. private _render;
  75239. /**
  75240. * Renders the particle system in its current state.
  75241. * @returns the current number of particles
  75242. */
  75243. render(): number;
  75244. /**
  75245. * Disposes the particle system and free the associated resources
  75246. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75247. */
  75248. dispose(disposeTexture?: boolean): void;
  75249. /**
  75250. * Clones the particle system.
  75251. * @param name The name of the cloned object
  75252. * @param newEmitter The new emitter to use
  75253. * @returns the cloned particle system
  75254. */
  75255. clone(name: string, newEmitter: any): ParticleSystem;
  75256. /**
  75257. * Serializes the particle system to a JSON object.
  75258. * @returns the JSON object
  75259. */
  75260. serialize(): any;
  75261. /** @hidden */
  75262. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  75263. /** @hidden */
  75264. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  75265. /**
  75266. * Parses a JSON object to create a particle system.
  75267. * @param parsedParticleSystem The JSON object to parse
  75268. * @param scene The scene to create the particle system in
  75269. * @param rootUrl The root url to use to load external dependencies like texture
  75270. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75271. * @returns the Parsed particle system
  75272. */
  75273. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  75274. }
  75275. }
  75276. declare module BABYLON {
  75277. /**
  75278. * A particle represents one of the element emitted by a particle system.
  75279. * This is mainly define by its coordinates, direction, velocity and age.
  75280. */
  75281. export class Particle {
  75282. /**
  75283. * The particle system the particle belongs to.
  75284. */
  75285. particleSystem: ParticleSystem;
  75286. private static _Count;
  75287. /**
  75288. * Unique ID of the particle
  75289. */
  75290. id: number;
  75291. /**
  75292. * The world position of the particle in the scene.
  75293. */
  75294. position: Vector3;
  75295. /**
  75296. * The world direction of the particle in the scene.
  75297. */
  75298. direction: Vector3;
  75299. /**
  75300. * The color of the particle.
  75301. */
  75302. color: Color4;
  75303. /**
  75304. * The color change of the particle per step.
  75305. */
  75306. colorStep: Color4;
  75307. /**
  75308. * Defines how long will the life of the particle be.
  75309. */
  75310. lifeTime: number;
  75311. /**
  75312. * The current age of the particle.
  75313. */
  75314. age: number;
  75315. /**
  75316. * The current size of the particle.
  75317. */
  75318. size: number;
  75319. /**
  75320. * The current scale of the particle.
  75321. */
  75322. scale: Vector2;
  75323. /**
  75324. * The current angle of the particle.
  75325. */
  75326. angle: number;
  75327. /**
  75328. * Defines how fast is the angle changing.
  75329. */
  75330. angularSpeed: number;
  75331. /**
  75332. * Defines the cell index used by the particle to be rendered from a sprite.
  75333. */
  75334. cellIndex: number;
  75335. /**
  75336. * The information required to support color remapping
  75337. */
  75338. remapData: Vector4;
  75339. /** @hidden */
  75340. _randomCellOffset?: number;
  75341. /** @hidden */
  75342. _initialDirection: Nullable<Vector3>;
  75343. /** @hidden */
  75344. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  75345. /** @hidden */
  75346. _initialStartSpriteCellID: number;
  75347. /** @hidden */
  75348. _initialEndSpriteCellID: number;
  75349. /** @hidden */
  75350. _currentColorGradient: Nullable<ColorGradient>;
  75351. /** @hidden */
  75352. _currentColor1: Color4;
  75353. /** @hidden */
  75354. _currentColor2: Color4;
  75355. /** @hidden */
  75356. _currentSizeGradient: Nullable<FactorGradient>;
  75357. /** @hidden */
  75358. _currentSize1: number;
  75359. /** @hidden */
  75360. _currentSize2: number;
  75361. /** @hidden */
  75362. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  75363. /** @hidden */
  75364. _currentAngularSpeed1: number;
  75365. /** @hidden */
  75366. _currentAngularSpeed2: number;
  75367. /** @hidden */
  75368. _currentVelocityGradient: Nullable<FactorGradient>;
  75369. /** @hidden */
  75370. _currentVelocity1: number;
  75371. /** @hidden */
  75372. _currentVelocity2: number;
  75373. /** @hidden */
  75374. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  75375. /** @hidden */
  75376. _currentLimitVelocity1: number;
  75377. /** @hidden */
  75378. _currentLimitVelocity2: number;
  75379. /** @hidden */
  75380. _currentDragGradient: Nullable<FactorGradient>;
  75381. /** @hidden */
  75382. _currentDrag1: number;
  75383. /** @hidden */
  75384. _currentDrag2: number;
  75385. /** @hidden */
  75386. _randomNoiseCoordinates1: Vector3;
  75387. /** @hidden */
  75388. _randomNoiseCoordinates2: Vector3;
  75389. /**
  75390. * Creates a new instance Particle
  75391. * @param particleSystem the particle system the particle belongs to
  75392. */
  75393. constructor(
  75394. /**
  75395. * The particle system the particle belongs to.
  75396. */
  75397. particleSystem: ParticleSystem);
  75398. private updateCellInfoFromSystem;
  75399. /**
  75400. * Defines how the sprite cell index is updated for the particle
  75401. */
  75402. updateCellIndex(): void;
  75403. /** @hidden */
  75404. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  75405. /** @hidden */
  75406. _inheritParticleInfoToSubEmitters(): void;
  75407. /** @hidden */
  75408. _reset(): void;
  75409. /**
  75410. * Copy the properties of particle to another one.
  75411. * @param other the particle to copy the information to.
  75412. */
  75413. copyTo(other: Particle): void;
  75414. }
  75415. }
  75416. declare module BABYLON {
  75417. /**
  75418. * Particle emitter represents a volume emitting particles.
  75419. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75420. */
  75421. export interface IParticleEmitterType {
  75422. /**
  75423. * Called by the particle System when the direction is computed for the created particle.
  75424. * @param worldMatrix is the world matrix of the particle system
  75425. * @param directionToUpdate is the direction vector to update with the result
  75426. * @param particle is the particle we are computed the direction for
  75427. */
  75428. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75429. /**
  75430. * Called by the particle System when the position is computed for the created particle.
  75431. * @param worldMatrix is the world matrix of the particle system
  75432. * @param positionToUpdate is the position vector to update with the result
  75433. * @param particle is the particle we are computed the position for
  75434. */
  75435. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75436. /**
  75437. * Clones the current emitter and returns a copy of it
  75438. * @returns the new emitter
  75439. */
  75440. clone(): IParticleEmitterType;
  75441. /**
  75442. * Called by the GPUParticleSystem to setup the update shader
  75443. * @param effect defines the update shader
  75444. */
  75445. applyToShader(effect: Effect): void;
  75446. /**
  75447. * Returns a string to use to update the GPU particles update shader
  75448. * @returns the effect defines string
  75449. */
  75450. getEffectDefines(): string;
  75451. /**
  75452. * Returns a string representing the class name
  75453. * @returns a string containing the class name
  75454. */
  75455. getClassName(): string;
  75456. /**
  75457. * Serializes the particle system to a JSON object.
  75458. * @returns the JSON object
  75459. */
  75460. serialize(): any;
  75461. /**
  75462. * Parse properties from a JSON object
  75463. * @param serializationObject defines the JSON object
  75464. */
  75465. parse(serializationObject: any): void;
  75466. }
  75467. }
  75468. declare module BABYLON {
  75469. /**
  75470. * Particle emitter emitting particles from the inside of a box.
  75471. * It emits the particles randomly between 2 given directions.
  75472. */
  75473. export class BoxParticleEmitter implements IParticleEmitterType {
  75474. /**
  75475. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75476. */
  75477. direction1: Vector3;
  75478. /**
  75479. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75480. */
  75481. direction2: Vector3;
  75482. /**
  75483. * 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.
  75484. */
  75485. minEmitBox: Vector3;
  75486. /**
  75487. * 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.
  75488. */
  75489. maxEmitBox: Vector3;
  75490. /**
  75491. * Creates a new instance BoxParticleEmitter
  75492. */
  75493. constructor();
  75494. /**
  75495. * Called by the particle System when the direction is computed for the created particle.
  75496. * @param worldMatrix is the world matrix of the particle system
  75497. * @param directionToUpdate is the direction vector to update with the result
  75498. * @param particle is the particle we are computed the direction for
  75499. */
  75500. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75501. /**
  75502. * Called by the particle System when the position is computed for the created particle.
  75503. * @param worldMatrix is the world matrix of the particle system
  75504. * @param positionToUpdate is the position vector to update with the result
  75505. * @param particle is the particle we are computed the position for
  75506. */
  75507. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75508. /**
  75509. * Clones the current emitter and returns a copy of it
  75510. * @returns the new emitter
  75511. */
  75512. clone(): BoxParticleEmitter;
  75513. /**
  75514. * Called by the GPUParticleSystem to setup the update shader
  75515. * @param effect defines the update shader
  75516. */
  75517. applyToShader(effect: Effect): void;
  75518. /**
  75519. * Returns a string to use to update the GPU particles update shader
  75520. * @returns a string containng the defines string
  75521. */
  75522. getEffectDefines(): string;
  75523. /**
  75524. * Returns the string "BoxParticleEmitter"
  75525. * @returns a string containing the class name
  75526. */
  75527. getClassName(): string;
  75528. /**
  75529. * Serializes the particle system to a JSON object.
  75530. * @returns the JSON object
  75531. */
  75532. serialize(): any;
  75533. /**
  75534. * Parse properties from a JSON object
  75535. * @param serializationObject defines the JSON object
  75536. */
  75537. parse(serializationObject: any): void;
  75538. }
  75539. }
  75540. declare module BABYLON {
  75541. /**
  75542. * Particle emitter emitting particles from the inside of a cone.
  75543. * It emits the particles alongside the cone volume from the base to the particle.
  75544. * The emission direction might be randomized.
  75545. */
  75546. export class ConeParticleEmitter implements IParticleEmitterType {
  75547. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75548. directionRandomizer: number;
  75549. private _radius;
  75550. private _angle;
  75551. private _height;
  75552. /**
  75553. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75554. */
  75555. radiusRange: number;
  75556. /**
  75557. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75558. */
  75559. heightRange: number;
  75560. /**
  75561. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75562. */
  75563. emitFromSpawnPointOnly: boolean;
  75564. /**
  75565. * Gets or sets the radius of the emission cone
  75566. */
  75567. radius: number;
  75568. /**
  75569. * Gets or sets the angle of the emission cone
  75570. */
  75571. angle: number;
  75572. private _buildHeight;
  75573. /**
  75574. * Creates a new instance ConeParticleEmitter
  75575. * @param radius the radius of the emission cone (1 by default)
  75576. * @param angle the cone base angle (PI by default)
  75577. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75578. */
  75579. constructor(radius?: number, angle?: number,
  75580. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75581. directionRandomizer?: number);
  75582. /**
  75583. * Called by the particle System when the direction is computed for the created particle.
  75584. * @param worldMatrix is the world matrix of the particle system
  75585. * @param directionToUpdate is the direction vector to update with the result
  75586. * @param particle is the particle we are computed the direction for
  75587. */
  75588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75589. /**
  75590. * Called by the particle System when the position is computed for the created particle.
  75591. * @param worldMatrix is the world matrix of the particle system
  75592. * @param positionToUpdate is the position vector to update with the result
  75593. * @param particle is the particle we are computed the position for
  75594. */
  75595. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75596. /**
  75597. * Clones the current emitter and returns a copy of it
  75598. * @returns the new emitter
  75599. */
  75600. clone(): ConeParticleEmitter;
  75601. /**
  75602. * Called by the GPUParticleSystem to setup the update shader
  75603. * @param effect defines the update shader
  75604. */
  75605. applyToShader(effect: Effect): void;
  75606. /**
  75607. * Returns a string to use to update the GPU particles update shader
  75608. * @returns a string containng the defines string
  75609. */
  75610. getEffectDefines(): string;
  75611. /**
  75612. * Returns the string "ConeParticleEmitter"
  75613. * @returns a string containing the class name
  75614. */
  75615. getClassName(): string;
  75616. /**
  75617. * Serializes the particle system to a JSON object.
  75618. * @returns the JSON object
  75619. */
  75620. serialize(): any;
  75621. /**
  75622. * Parse properties from a JSON object
  75623. * @param serializationObject defines the JSON object
  75624. */
  75625. parse(serializationObject: any): void;
  75626. }
  75627. }
  75628. declare module BABYLON {
  75629. /**
  75630. * Particle emitter emitting particles from the inside of a cylinder.
  75631. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75632. */
  75633. export class CylinderParticleEmitter implements IParticleEmitterType {
  75634. /**
  75635. * The radius of the emission cylinder.
  75636. */
  75637. radius: number;
  75638. /**
  75639. * The height of the emission cylinder.
  75640. */
  75641. height: number;
  75642. /**
  75643. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75644. */
  75645. radiusRange: number;
  75646. /**
  75647. * How much to randomize the particle direction [0-1].
  75648. */
  75649. directionRandomizer: number;
  75650. /**
  75651. * Creates a new instance CylinderParticleEmitter
  75652. * @param radius the radius of the emission cylinder (1 by default)
  75653. * @param height the height of the emission cylinder (1 by default)
  75654. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75655. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75656. */
  75657. constructor(
  75658. /**
  75659. * The radius of the emission cylinder.
  75660. */
  75661. radius?: number,
  75662. /**
  75663. * The height of the emission cylinder.
  75664. */
  75665. height?: number,
  75666. /**
  75667. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75668. */
  75669. radiusRange?: number,
  75670. /**
  75671. * How much to randomize the particle direction [0-1].
  75672. */
  75673. directionRandomizer?: number);
  75674. /**
  75675. * Called by the particle System when the direction is computed for the created particle.
  75676. * @param worldMatrix is the world matrix of the particle system
  75677. * @param directionToUpdate is the direction vector to update with the result
  75678. * @param particle is the particle we are computed the direction for
  75679. */
  75680. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75681. /**
  75682. * Called by the particle System when the position is computed for the created particle.
  75683. * @param worldMatrix is the world matrix of the particle system
  75684. * @param positionToUpdate is the position vector to update with the result
  75685. * @param particle is the particle we are computed the position for
  75686. */
  75687. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75688. /**
  75689. * Clones the current emitter and returns a copy of it
  75690. * @returns the new emitter
  75691. */
  75692. clone(): CylinderParticleEmitter;
  75693. /**
  75694. * Called by the GPUParticleSystem to setup the update shader
  75695. * @param effect defines the update shader
  75696. */
  75697. applyToShader(effect: Effect): void;
  75698. /**
  75699. * Returns a string to use to update the GPU particles update shader
  75700. * @returns a string containng the defines string
  75701. */
  75702. getEffectDefines(): string;
  75703. /**
  75704. * Returns the string "CylinderParticleEmitter"
  75705. * @returns a string containing the class name
  75706. */
  75707. getClassName(): string;
  75708. /**
  75709. * Serializes the particle system to a JSON object.
  75710. * @returns the JSON object
  75711. */
  75712. serialize(): any;
  75713. /**
  75714. * Parse properties from a JSON object
  75715. * @param serializationObject defines the JSON object
  75716. */
  75717. parse(serializationObject: any): void;
  75718. }
  75719. /**
  75720. * Particle emitter emitting particles from the inside of a cylinder.
  75721. * It emits the particles randomly between two vectors.
  75722. */
  75723. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75724. /**
  75725. * The min limit of the emission direction.
  75726. */
  75727. direction1: Vector3;
  75728. /**
  75729. * The max limit of the emission direction.
  75730. */
  75731. direction2: Vector3;
  75732. /**
  75733. * Creates a new instance CylinderDirectedParticleEmitter
  75734. * @param radius the radius of the emission cylinder (1 by default)
  75735. * @param height the height of the emission cylinder (1 by default)
  75736. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75737. * @param direction1 the min limit of the emission direction (up vector by default)
  75738. * @param direction2 the max limit of the emission direction (up vector by default)
  75739. */
  75740. constructor(radius?: number, height?: number, radiusRange?: number,
  75741. /**
  75742. * The min limit of the emission direction.
  75743. */
  75744. direction1?: Vector3,
  75745. /**
  75746. * The max limit of the emission direction.
  75747. */
  75748. direction2?: Vector3);
  75749. /**
  75750. * Called by the particle System when the direction is computed for the created particle.
  75751. * @param worldMatrix is the world matrix of the particle system
  75752. * @param directionToUpdate is the direction vector to update with the result
  75753. * @param particle is the particle we are computed the direction for
  75754. */
  75755. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75756. /**
  75757. * Clones the current emitter and returns a copy of it
  75758. * @returns the new emitter
  75759. */
  75760. clone(): CylinderDirectedParticleEmitter;
  75761. /**
  75762. * Called by the GPUParticleSystem to setup the update shader
  75763. * @param effect defines the update shader
  75764. */
  75765. applyToShader(effect: Effect): void;
  75766. /**
  75767. * Returns a string to use to update the GPU particles update shader
  75768. * @returns a string containng the defines string
  75769. */
  75770. getEffectDefines(): string;
  75771. /**
  75772. * Returns the string "CylinderDirectedParticleEmitter"
  75773. * @returns a string containing the class name
  75774. */
  75775. getClassName(): string;
  75776. /**
  75777. * Serializes the particle system to a JSON object.
  75778. * @returns the JSON object
  75779. */
  75780. serialize(): any;
  75781. /**
  75782. * Parse properties from a JSON object
  75783. * @param serializationObject defines the JSON object
  75784. */
  75785. parse(serializationObject: any): void;
  75786. }
  75787. }
  75788. declare module BABYLON {
  75789. /**
  75790. * Particle emitter emitting particles from the inside of a hemisphere.
  75791. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75792. */
  75793. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75794. /**
  75795. * The radius of the emission hemisphere.
  75796. */
  75797. radius: number;
  75798. /**
  75799. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75800. */
  75801. radiusRange: number;
  75802. /**
  75803. * How much to randomize the particle direction [0-1].
  75804. */
  75805. directionRandomizer: number;
  75806. /**
  75807. * Creates a new instance HemisphericParticleEmitter
  75808. * @param radius the radius of the emission hemisphere (1 by default)
  75809. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75810. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75811. */
  75812. constructor(
  75813. /**
  75814. * The radius of the emission hemisphere.
  75815. */
  75816. radius?: number,
  75817. /**
  75818. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75819. */
  75820. radiusRange?: number,
  75821. /**
  75822. * How much to randomize the particle direction [0-1].
  75823. */
  75824. directionRandomizer?: number);
  75825. /**
  75826. * Called by the particle System when the direction is computed for the created particle.
  75827. * @param worldMatrix is the world matrix of the particle system
  75828. * @param directionToUpdate is the direction vector to update with the result
  75829. * @param particle is the particle we are computed the direction for
  75830. */
  75831. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75832. /**
  75833. * Called by the particle System when the position is computed for the created particle.
  75834. * @param worldMatrix is the world matrix of the particle system
  75835. * @param positionToUpdate is the position vector to update with the result
  75836. * @param particle is the particle we are computed the position for
  75837. */
  75838. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75839. /**
  75840. * Clones the current emitter and returns a copy of it
  75841. * @returns the new emitter
  75842. */
  75843. clone(): HemisphericParticleEmitter;
  75844. /**
  75845. * Called by the GPUParticleSystem to setup the update shader
  75846. * @param effect defines the update shader
  75847. */
  75848. applyToShader(effect: Effect): void;
  75849. /**
  75850. * Returns a string to use to update the GPU particles update shader
  75851. * @returns a string containng the defines string
  75852. */
  75853. getEffectDefines(): string;
  75854. /**
  75855. * Returns the string "HemisphericParticleEmitter"
  75856. * @returns a string containing the class name
  75857. */
  75858. getClassName(): string;
  75859. /**
  75860. * Serializes the particle system to a JSON object.
  75861. * @returns the JSON object
  75862. */
  75863. serialize(): any;
  75864. /**
  75865. * Parse properties from a JSON object
  75866. * @param serializationObject defines the JSON object
  75867. */
  75868. parse(serializationObject: any): void;
  75869. }
  75870. }
  75871. declare module BABYLON {
  75872. /**
  75873. * Particle emitter emitting particles from a point.
  75874. * It emits the particles randomly between 2 given directions.
  75875. */
  75876. export class PointParticleEmitter implements IParticleEmitterType {
  75877. /**
  75878. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75879. */
  75880. direction1: Vector3;
  75881. /**
  75882. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75883. */
  75884. direction2: Vector3;
  75885. /**
  75886. * Creates a new instance PointParticleEmitter
  75887. */
  75888. constructor();
  75889. /**
  75890. * Called by the particle System when the direction is computed for the created particle.
  75891. * @param worldMatrix is the world matrix of the particle system
  75892. * @param directionToUpdate is the direction vector to update with the result
  75893. * @param particle is the particle we are computed the direction for
  75894. */
  75895. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75896. /**
  75897. * Called by the particle System when the position is computed for the created particle.
  75898. * @param worldMatrix is the world matrix of the particle system
  75899. * @param positionToUpdate is the position vector to update with the result
  75900. * @param particle is the particle we are computed the position for
  75901. */
  75902. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75903. /**
  75904. * Clones the current emitter and returns a copy of it
  75905. * @returns the new emitter
  75906. */
  75907. clone(): PointParticleEmitter;
  75908. /**
  75909. * Called by the GPUParticleSystem to setup the update shader
  75910. * @param effect defines the update shader
  75911. */
  75912. applyToShader(effect: Effect): void;
  75913. /**
  75914. * Returns a string to use to update the GPU particles update shader
  75915. * @returns a string containng the defines string
  75916. */
  75917. getEffectDefines(): string;
  75918. /**
  75919. * Returns the string "PointParticleEmitter"
  75920. * @returns a string containing the class name
  75921. */
  75922. getClassName(): string;
  75923. /**
  75924. * Serializes the particle system to a JSON object.
  75925. * @returns the JSON object
  75926. */
  75927. serialize(): any;
  75928. /**
  75929. * Parse properties from a JSON object
  75930. * @param serializationObject defines the JSON object
  75931. */
  75932. parse(serializationObject: any): void;
  75933. }
  75934. }
  75935. declare module BABYLON {
  75936. /**
  75937. * Particle emitter emitting particles from the inside of a sphere.
  75938. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75939. */
  75940. export class SphereParticleEmitter implements IParticleEmitterType {
  75941. /**
  75942. * The radius of the emission sphere.
  75943. */
  75944. radius: number;
  75945. /**
  75946. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75947. */
  75948. radiusRange: number;
  75949. /**
  75950. * How much to randomize the particle direction [0-1].
  75951. */
  75952. directionRandomizer: number;
  75953. /**
  75954. * Creates a new instance SphereParticleEmitter
  75955. * @param radius the radius of the emission sphere (1 by default)
  75956. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75957. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75958. */
  75959. constructor(
  75960. /**
  75961. * The radius of the emission sphere.
  75962. */
  75963. radius?: number,
  75964. /**
  75965. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75966. */
  75967. radiusRange?: number,
  75968. /**
  75969. * How much to randomize the particle direction [0-1].
  75970. */
  75971. directionRandomizer?: number);
  75972. /**
  75973. * Called by the particle System when the direction is computed for the created particle.
  75974. * @param worldMatrix is the world matrix of the particle system
  75975. * @param directionToUpdate is the direction vector to update with the result
  75976. * @param particle is the particle we are computed the direction for
  75977. */
  75978. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75979. /**
  75980. * Called by the particle System when the position is computed for the created particle.
  75981. * @param worldMatrix is the world matrix of the particle system
  75982. * @param positionToUpdate is the position vector to update with the result
  75983. * @param particle is the particle we are computed the position for
  75984. */
  75985. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75986. /**
  75987. * Clones the current emitter and returns a copy of it
  75988. * @returns the new emitter
  75989. */
  75990. clone(): SphereParticleEmitter;
  75991. /**
  75992. * Called by the GPUParticleSystem to setup the update shader
  75993. * @param effect defines the update shader
  75994. */
  75995. applyToShader(effect: Effect): void;
  75996. /**
  75997. * Returns a string to use to update the GPU particles update shader
  75998. * @returns a string containng the defines string
  75999. */
  76000. getEffectDefines(): string;
  76001. /**
  76002. * Returns the string "SphereParticleEmitter"
  76003. * @returns a string containing the class name
  76004. */
  76005. getClassName(): string;
  76006. /**
  76007. * Serializes the particle system to a JSON object.
  76008. * @returns the JSON object
  76009. */
  76010. serialize(): any;
  76011. /**
  76012. * Parse properties from a JSON object
  76013. * @param serializationObject defines the JSON object
  76014. */
  76015. parse(serializationObject: any): void;
  76016. }
  76017. /**
  76018. * Particle emitter emitting particles from the inside of a sphere.
  76019. * It emits the particles randomly between two vectors.
  76020. */
  76021. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  76022. /**
  76023. * The min limit of the emission direction.
  76024. */
  76025. direction1: Vector3;
  76026. /**
  76027. * The max limit of the emission direction.
  76028. */
  76029. direction2: Vector3;
  76030. /**
  76031. * Creates a new instance SphereDirectedParticleEmitter
  76032. * @param radius the radius of the emission sphere (1 by default)
  76033. * @param direction1 the min limit of the emission direction (up vector by default)
  76034. * @param direction2 the max limit of the emission direction (up vector by default)
  76035. */
  76036. constructor(radius?: number,
  76037. /**
  76038. * The min limit of the emission direction.
  76039. */
  76040. direction1?: Vector3,
  76041. /**
  76042. * The max limit of the emission direction.
  76043. */
  76044. direction2?: Vector3);
  76045. /**
  76046. * Called by the particle System when the direction is computed for the created particle.
  76047. * @param worldMatrix is the world matrix of the particle system
  76048. * @param directionToUpdate is the direction vector to update with the result
  76049. * @param particle is the particle we are computed the direction for
  76050. */
  76051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76052. /**
  76053. * Clones the current emitter and returns a copy of it
  76054. * @returns the new emitter
  76055. */
  76056. clone(): SphereDirectedParticleEmitter;
  76057. /**
  76058. * Called by the GPUParticleSystem to setup the update shader
  76059. * @param effect defines the update shader
  76060. */
  76061. applyToShader(effect: Effect): void;
  76062. /**
  76063. * Returns a string to use to update the GPU particles update shader
  76064. * @returns a string containng the defines string
  76065. */
  76066. getEffectDefines(): string;
  76067. /**
  76068. * Returns the string "SphereDirectedParticleEmitter"
  76069. * @returns a string containing the class name
  76070. */
  76071. getClassName(): string;
  76072. /**
  76073. * Serializes the particle system to a JSON object.
  76074. * @returns the JSON object
  76075. */
  76076. serialize(): any;
  76077. /**
  76078. * Parse properties from a JSON object
  76079. * @param serializationObject defines the JSON object
  76080. */
  76081. parse(serializationObject: any): void;
  76082. }
  76083. }
  76084. declare module BABYLON {
  76085. /**
  76086. * Interface representing a particle system in Babylon.js.
  76087. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  76088. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  76089. */
  76090. export interface IParticleSystem {
  76091. /**
  76092. * List of animations used by the particle system.
  76093. */
  76094. animations: Animation[];
  76095. /**
  76096. * The id of the Particle system.
  76097. */
  76098. id: string;
  76099. /**
  76100. * The name of the Particle system.
  76101. */
  76102. name: string;
  76103. /**
  76104. * The emitter represents the Mesh or position we are attaching the particle system to.
  76105. */
  76106. emitter: Nullable<AbstractMesh | Vector3>;
  76107. /**
  76108. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76109. */
  76110. isBillboardBased: boolean;
  76111. /**
  76112. * The rendering group used by the Particle system to chose when to render.
  76113. */
  76114. renderingGroupId: number;
  76115. /**
  76116. * The layer mask we are rendering the particles through.
  76117. */
  76118. layerMask: number;
  76119. /**
  76120. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76121. */
  76122. updateSpeed: number;
  76123. /**
  76124. * The amount of time the particle system is running (depends of the overall update speed).
  76125. */
  76126. targetStopDuration: number;
  76127. /**
  76128. * The texture used to render each particle. (this can be a spritesheet)
  76129. */
  76130. particleTexture: Nullable<Texture>;
  76131. /**
  76132. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  76133. */
  76134. blendMode: number;
  76135. /**
  76136. * Minimum life time of emitting particles.
  76137. */
  76138. minLifeTime: number;
  76139. /**
  76140. * Maximum life time of emitting particles.
  76141. */
  76142. maxLifeTime: number;
  76143. /**
  76144. * Minimum Size of emitting particles.
  76145. */
  76146. minSize: number;
  76147. /**
  76148. * Maximum Size of emitting particles.
  76149. */
  76150. maxSize: number;
  76151. /**
  76152. * Minimum scale of emitting particles on X axis.
  76153. */
  76154. minScaleX: number;
  76155. /**
  76156. * Maximum scale of emitting particles on X axis.
  76157. */
  76158. maxScaleX: number;
  76159. /**
  76160. * Minimum scale of emitting particles on Y axis.
  76161. */
  76162. minScaleY: number;
  76163. /**
  76164. * Maximum scale of emitting particles on Y axis.
  76165. */
  76166. maxScaleY: number;
  76167. /**
  76168. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76169. */
  76170. color1: Color4;
  76171. /**
  76172. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76173. */
  76174. color2: Color4;
  76175. /**
  76176. * Color the particle will have at the end of its lifetime.
  76177. */
  76178. colorDead: Color4;
  76179. /**
  76180. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  76181. */
  76182. emitRate: number;
  76183. /**
  76184. * You can use gravity if you want to give an orientation to your particles.
  76185. */
  76186. gravity: Vector3;
  76187. /**
  76188. * Minimum power of emitting particles.
  76189. */
  76190. minEmitPower: number;
  76191. /**
  76192. * Maximum power of emitting particles.
  76193. */
  76194. maxEmitPower: number;
  76195. /**
  76196. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76197. */
  76198. minAngularSpeed: number;
  76199. /**
  76200. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76201. */
  76202. maxAngularSpeed: number;
  76203. /**
  76204. * Gets or sets the minimal initial rotation in radians.
  76205. */
  76206. minInitialRotation: number;
  76207. /**
  76208. * Gets or sets the maximal initial rotation in radians.
  76209. */
  76210. maxInitialRotation: number;
  76211. /**
  76212. * The particle emitter type defines the emitter used by the particle system.
  76213. * It can be for example box, sphere, or cone...
  76214. */
  76215. particleEmitterType: Nullable<IParticleEmitterType>;
  76216. /**
  76217. * Defines the delay in milliseconds before starting the system (0 by default)
  76218. */
  76219. startDelay: number;
  76220. /**
  76221. * 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
  76222. */
  76223. preWarmCycles: number;
  76224. /**
  76225. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  76226. */
  76227. preWarmStepOffset: number;
  76228. /**
  76229. * 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)
  76230. */
  76231. spriteCellChangeSpeed: number;
  76232. /**
  76233. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76234. */
  76235. startSpriteCellID: number;
  76236. /**
  76237. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76238. */
  76239. endSpriteCellID: number;
  76240. /**
  76241. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76242. */
  76243. spriteCellWidth: number;
  76244. /**
  76245. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76246. */
  76247. spriteCellHeight: number;
  76248. /**
  76249. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76250. */
  76251. spriteRandomStartCell: boolean;
  76252. /**
  76253. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  76254. */
  76255. isAnimationSheetEnabled: boolean;
  76256. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76257. translationPivot: Vector2;
  76258. /**
  76259. * Gets or sets a texture used to add random noise to particle positions
  76260. */
  76261. noiseTexture: Nullable<BaseTexture>;
  76262. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76263. noiseStrength: Vector3;
  76264. /**
  76265. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76266. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76267. */
  76268. billboardMode: number;
  76269. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76270. limitVelocityDamping: number;
  76271. /**
  76272. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76273. */
  76274. beginAnimationOnStart: boolean;
  76275. /**
  76276. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76277. */
  76278. beginAnimationFrom: number;
  76279. /**
  76280. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76281. */
  76282. beginAnimationTo: number;
  76283. /**
  76284. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76285. */
  76286. beginAnimationLoop: boolean;
  76287. /**
  76288. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76289. */
  76290. disposeOnStop: boolean;
  76291. /**
  76292. * Gets the maximum number of particles active at the same time.
  76293. * @returns The max number of active particles.
  76294. */
  76295. getCapacity(): number;
  76296. /**
  76297. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76298. * @returns True if it has been started, otherwise false.
  76299. */
  76300. isStarted(): boolean;
  76301. /**
  76302. * Animates the particle system for this frame.
  76303. */
  76304. animate(): void;
  76305. /**
  76306. * Renders the particle system in its current state.
  76307. * @returns the current number of particles
  76308. */
  76309. render(): number;
  76310. /**
  76311. * Dispose the particle system and frees its associated resources.
  76312. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76313. */
  76314. dispose(disposeTexture?: boolean): void;
  76315. /**
  76316. * Clones the particle system.
  76317. * @param name The name of the cloned object
  76318. * @param newEmitter The new emitter to use
  76319. * @returns the cloned particle system
  76320. */
  76321. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  76322. /**
  76323. * Serializes the particle system to a JSON object.
  76324. * @returns the JSON object
  76325. */
  76326. serialize(): any;
  76327. /**
  76328. * Rebuild the particle system
  76329. */
  76330. rebuild(): void;
  76331. /**
  76332. * Starts the particle system and begins to emit
  76333. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  76334. */
  76335. start(delay?: number): void;
  76336. /**
  76337. * Stops the particle system.
  76338. */
  76339. stop(): void;
  76340. /**
  76341. * Remove all active particles
  76342. */
  76343. reset(): void;
  76344. /**
  76345. * Is this system ready to be used/rendered
  76346. * @return true if the system is ready
  76347. */
  76348. isReady(): boolean;
  76349. /**
  76350. * Adds a new color gradient
  76351. * @param gradient defines the gradient to use (between 0 and 1)
  76352. * @param color1 defines the color to affect to the specified gradient
  76353. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76354. * @returns the current particle system
  76355. */
  76356. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  76357. /**
  76358. * Remove a specific color gradient
  76359. * @param gradient defines the gradient to remove
  76360. * @returns the current particle system
  76361. */
  76362. removeColorGradient(gradient: number): IParticleSystem;
  76363. /**
  76364. * Adds a new size gradient
  76365. * @param gradient defines the gradient to use (between 0 and 1)
  76366. * @param factor defines the size factor to affect to the specified gradient
  76367. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76368. * @returns the current particle system
  76369. */
  76370. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76371. /**
  76372. * Remove a specific size gradient
  76373. * @param gradient defines the gradient to remove
  76374. * @returns the current particle system
  76375. */
  76376. removeSizeGradient(gradient: number): IParticleSystem;
  76377. /**
  76378. * Gets the current list of color gradients.
  76379. * You must use addColorGradient and removeColorGradient to udpate this list
  76380. * @returns the list of color gradients
  76381. */
  76382. getColorGradients(): Nullable<Array<ColorGradient>>;
  76383. /**
  76384. * Gets the current list of size gradients.
  76385. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76386. * @returns the list of size gradients
  76387. */
  76388. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76389. /**
  76390. * Gets the current list of angular speed gradients.
  76391. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76392. * @returns the list of angular speed gradients
  76393. */
  76394. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76395. /**
  76396. * Adds a new angular speed gradient
  76397. * @param gradient defines the gradient to use (between 0 and 1)
  76398. * @param factor defines the angular speed to affect to the specified gradient
  76399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76400. * @returns the current particle system
  76401. */
  76402. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76403. /**
  76404. * Remove a specific angular speed gradient
  76405. * @param gradient defines the gradient to remove
  76406. * @returns the current particle system
  76407. */
  76408. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  76409. /**
  76410. * Gets the current list of velocity gradients.
  76411. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76412. * @returns the list of velocity gradients
  76413. */
  76414. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76415. /**
  76416. * Adds a new velocity gradient
  76417. * @param gradient defines the gradient to use (between 0 and 1)
  76418. * @param factor defines the velocity to affect to the specified gradient
  76419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76420. * @returns the current particle system
  76421. */
  76422. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76423. /**
  76424. * Remove a specific velocity gradient
  76425. * @param gradient defines the gradient to remove
  76426. * @returns the current particle system
  76427. */
  76428. removeVelocityGradient(gradient: number): IParticleSystem;
  76429. /**
  76430. * Gets the current list of limit velocity gradients.
  76431. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76432. * @returns the list of limit velocity gradients
  76433. */
  76434. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76435. /**
  76436. * Adds a new limit velocity gradient
  76437. * @param gradient defines the gradient to use (between 0 and 1)
  76438. * @param factor defines the limit velocity to affect to the specified gradient
  76439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76440. * @returns the current particle system
  76441. */
  76442. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76443. /**
  76444. * Remove a specific limit velocity gradient
  76445. * @param gradient defines the gradient to remove
  76446. * @returns the current particle system
  76447. */
  76448. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76449. /**
  76450. * Adds a new drag gradient
  76451. * @param gradient defines the gradient to use (between 0 and 1)
  76452. * @param factor defines the drag to affect to the specified gradient
  76453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76454. * @returns the current particle system
  76455. */
  76456. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76457. /**
  76458. * Remove a specific drag gradient
  76459. * @param gradient defines the gradient to remove
  76460. * @returns the current particle system
  76461. */
  76462. removeDragGradient(gradient: number): IParticleSystem;
  76463. /**
  76464. * Gets the current list of drag gradients.
  76465. * You must use addDragGradient and removeDragGradient to udpate this list
  76466. * @returns the list of drag gradients
  76467. */
  76468. getDragGradients(): Nullable<Array<FactorGradient>>;
  76469. /**
  76470. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76471. * @param gradient defines the gradient to use (between 0 and 1)
  76472. * @param factor defines the emit rate to affect to the specified gradient
  76473. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76474. * @returns the current particle system
  76475. */
  76476. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76477. /**
  76478. * Remove a specific emit rate gradient
  76479. * @param gradient defines the gradient to remove
  76480. * @returns the current particle system
  76481. */
  76482. removeEmitRateGradient(gradient: number): IParticleSystem;
  76483. /**
  76484. * Gets the current list of emit rate gradients.
  76485. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76486. * @returns the list of emit rate gradients
  76487. */
  76488. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76489. /**
  76490. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76491. * @param gradient defines the gradient to use (between 0 and 1)
  76492. * @param factor defines the start size to affect to the specified gradient
  76493. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76494. * @returns the current particle system
  76495. */
  76496. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76497. /**
  76498. * Remove a specific start size gradient
  76499. * @param gradient defines the gradient to remove
  76500. * @returns the current particle system
  76501. */
  76502. removeStartSizeGradient(gradient: number): IParticleSystem;
  76503. /**
  76504. * Gets the current list of start size gradients.
  76505. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76506. * @returns the list of start size gradients
  76507. */
  76508. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76509. /**
  76510. * Adds a new life time gradient
  76511. * @param gradient defines the gradient to use (between 0 and 1)
  76512. * @param factor defines the life time factor to affect to the specified gradient
  76513. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76514. * @returns the current particle system
  76515. */
  76516. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76517. /**
  76518. * Remove a specific life time gradient
  76519. * @param gradient defines the gradient to remove
  76520. * @returns the current particle system
  76521. */
  76522. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76523. /**
  76524. * Gets the current list of life time gradients.
  76525. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76526. * @returns the list of life time gradients
  76527. */
  76528. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76529. /**
  76530. * Gets the current list of color gradients.
  76531. * You must use addColorGradient and removeColorGradient to udpate this list
  76532. * @returns the list of color gradients
  76533. */
  76534. getColorGradients(): Nullable<Array<ColorGradient>>;
  76535. /**
  76536. * Adds a new ramp gradient used to remap particle colors
  76537. * @param gradient defines the gradient to use (between 0 and 1)
  76538. * @param color defines the color to affect to the specified gradient
  76539. * @returns the current particle system
  76540. */
  76541. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76542. /**
  76543. * Gets the current list of ramp gradients.
  76544. * You must use addRampGradient and removeRampGradient to udpate this list
  76545. * @returns the list of ramp gradients
  76546. */
  76547. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76548. /** Gets or sets a boolean indicating that ramp gradients must be used
  76549. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76550. */
  76551. useRampGradients: boolean;
  76552. /**
  76553. * Adds a new color remap gradient
  76554. * @param gradient defines the gradient to use (between 0 and 1)
  76555. * @param min defines the color remap minimal range
  76556. * @param max defines the color remap maximal range
  76557. * @returns the current particle system
  76558. */
  76559. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76560. /**
  76561. * Gets the current list of color remap gradients.
  76562. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76563. * @returns the list of color remap gradients
  76564. */
  76565. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76566. /**
  76567. * Adds a new alpha remap gradient
  76568. * @param gradient defines the gradient to use (between 0 and 1)
  76569. * @param min defines the alpha remap minimal range
  76570. * @param max defines the alpha remap maximal range
  76571. * @returns the current particle system
  76572. */
  76573. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76574. /**
  76575. * Gets the current list of alpha remap gradients.
  76576. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76577. * @returns the list of alpha remap gradients
  76578. */
  76579. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76580. /**
  76581. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76582. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76583. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76584. * @returns the emitter
  76585. */
  76586. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76587. /**
  76588. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76589. * @param radius The radius of the hemisphere to emit from
  76590. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76591. * @returns the emitter
  76592. */
  76593. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76594. /**
  76595. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76596. * @param radius The radius of the sphere to emit from
  76597. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76598. * @returns the emitter
  76599. */
  76600. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76601. /**
  76602. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76603. * @param radius The radius of the sphere to emit from
  76604. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76605. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76606. * @returns the emitter
  76607. */
  76608. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76609. /**
  76610. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76611. * @param radius The radius of the emission cylinder
  76612. * @param height The height of the emission cylinder
  76613. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76614. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76615. * @returns the emitter
  76616. */
  76617. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76618. /**
  76619. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76620. * @param radius The radius of the cylinder to emit from
  76621. * @param height The height of the emission cylinder
  76622. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76623. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76624. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76625. * @returns the emitter
  76626. */
  76627. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76628. /**
  76629. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76630. * @param radius The radius of the cone to emit from
  76631. * @param angle The base angle of the cone
  76632. * @returns the emitter
  76633. */
  76634. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76635. /**
  76636. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76637. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76638. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76639. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76640. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76641. * @returns the emitter
  76642. */
  76643. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76644. /**
  76645. * Get hosting scene
  76646. * @returns the scene
  76647. */
  76648. getScene(): Scene;
  76649. }
  76650. }
  76651. declare module BABYLON {
  76652. /**
  76653. * Creates an instance based on a source mesh.
  76654. */
  76655. export class InstancedMesh extends AbstractMesh {
  76656. private _sourceMesh;
  76657. private _currentLOD;
  76658. /** @hidden */
  76659. _indexInSourceMeshInstanceArray: number;
  76660. constructor(name: string, source: Mesh);
  76661. /**
  76662. * Returns the string "InstancedMesh".
  76663. */
  76664. getClassName(): string;
  76665. /** Gets the list of lights affecting that mesh */
  76666. readonly lightSources: Light[];
  76667. _resyncLightSources(): void;
  76668. _resyncLighSource(light: Light): void;
  76669. _removeLightSource(light: Light): void;
  76670. /**
  76671. * If the source mesh receives shadows
  76672. */
  76673. readonly receiveShadows: boolean;
  76674. /**
  76675. * The material of the source mesh
  76676. */
  76677. readonly material: Nullable<Material>;
  76678. /**
  76679. * Visibility of the source mesh
  76680. */
  76681. readonly visibility: number;
  76682. /**
  76683. * Skeleton of the source mesh
  76684. */
  76685. readonly skeleton: Nullable<Skeleton>;
  76686. /**
  76687. * Rendering ground id of the source mesh
  76688. */
  76689. renderingGroupId: number;
  76690. /**
  76691. * Returns the total number of vertices (integer).
  76692. */
  76693. getTotalVertices(): number;
  76694. /**
  76695. * Returns a positive integer : the total number of indices in this mesh geometry.
  76696. * @returns the numner of indices or zero if the mesh has no geometry.
  76697. */
  76698. getTotalIndices(): number;
  76699. /**
  76700. * The source mesh of the instance
  76701. */
  76702. readonly sourceMesh: Mesh;
  76703. /**
  76704. * Is this node ready to be used/rendered
  76705. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76706. * @return {boolean} is it ready
  76707. */
  76708. isReady(completeCheck?: boolean): boolean;
  76709. /**
  76710. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76711. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76712. * @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.
  76713. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76714. */
  76715. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76716. /**
  76717. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76718. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76719. * The `data` are either a numeric array either a Float32Array.
  76720. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76721. * 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).
  76722. * Note that a new underlying VertexBuffer object is created each call.
  76723. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76724. *
  76725. * Possible `kind` values :
  76726. * - VertexBuffer.PositionKind
  76727. * - VertexBuffer.UVKind
  76728. * - VertexBuffer.UV2Kind
  76729. * - VertexBuffer.UV3Kind
  76730. * - VertexBuffer.UV4Kind
  76731. * - VertexBuffer.UV5Kind
  76732. * - VertexBuffer.UV6Kind
  76733. * - VertexBuffer.ColorKind
  76734. * - VertexBuffer.MatricesIndicesKind
  76735. * - VertexBuffer.MatricesIndicesExtraKind
  76736. * - VertexBuffer.MatricesWeightsKind
  76737. * - VertexBuffer.MatricesWeightsExtraKind
  76738. *
  76739. * Returns the Mesh.
  76740. */
  76741. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76742. /**
  76743. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76744. * If the mesh has no geometry, it is simply returned as it is.
  76745. * The `data` are either a numeric array either a Float32Array.
  76746. * No new underlying VertexBuffer object is created.
  76747. * 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.
  76748. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76749. *
  76750. * Possible `kind` values :
  76751. * - VertexBuffer.PositionKind
  76752. * - VertexBuffer.UVKind
  76753. * - VertexBuffer.UV2Kind
  76754. * - VertexBuffer.UV3Kind
  76755. * - VertexBuffer.UV4Kind
  76756. * - VertexBuffer.UV5Kind
  76757. * - VertexBuffer.UV6Kind
  76758. * - VertexBuffer.ColorKind
  76759. * - VertexBuffer.MatricesIndicesKind
  76760. * - VertexBuffer.MatricesIndicesExtraKind
  76761. * - VertexBuffer.MatricesWeightsKind
  76762. * - VertexBuffer.MatricesWeightsExtraKind
  76763. *
  76764. * Returns the Mesh.
  76765. */
  76766. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76767. /**
  76768. * Sets the mesh indices.
  76769. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76770. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76771. * This method creates a new index buffer each call.
  76772. * Returns the Mesh.
  76773. */
  76774. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76775. /**
  76776. * Boolean : True if the mesh owns the requested kind of data.
  76777. */
  76778. isVerticesDataPresent(kind: string): boolean;
  76779. /**
  76780. * Returns an array of indices (IndicesArray).
  76781. */
  76782. getIndices(): Nullable<IndicesArray>;
  76783. readonly _positions: Nullable<Vector3[]>;
  76784. /**
  76785. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76786. * This means the mesh underlying bounding box and sphere are recomputed.
  76787. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76788. * @returns the current mesh
  76789. */
  76790. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76791. /** @hidden */
  76792. _preActivate(): InstancedMesh;
  76793. /** @hidden */
  76794. _activate(renderId: number): boolean;
  76795. getWorldMatrix(): Matrix;
  76796. readonly isAnInstance: boolean;
  76797. /**
  76798. * Returns the current associated LOD AbstractMesh.
  76799. */
  76800. getLOD(camera: Camera): AbstractMesh;
  76801. /** @hidden */
  76802. _syncSubMeshes(): InstancedMesh;
  76803. /** @hidden */
  76804. _generatePointsArray(): boolean;
  76805. /**
  76806. * Creates a new InstancedMesh from the current mesh.
  76807. * - name (string) : the cloned mesh name
  76808. * - newParent (optional Node) : the optional Node to parent the clone to.
  76809. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76810. *
  76811. * Returns the clone.
  76812. */
  76813. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76814. /**
  76815. * Disposes the InstancedMesh.
  76816. * Returns nothing.
  76817. */
  76818. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76819. }
  76820. }
  76821. declare module BABYLON {
  76822. /**
  76823. * Defines the options associated with the creation of a shader material.
  76824. */
  76825. export interface IShaderMaterialOptions {
  76826. /**
  76827. * Does the material work in alpha blend mode
  76828. */
  76829. needAlphaBlending: boolean;
  76830. /**
  76831. * Does the material work in alpha test mode
  76832. */
  76833. needAlphaTesting: boolean;
  76834. /**
  76835. * The list of attribute names used in the shader
  76836. */
  76837. attributes: string[];
  76838. /**
  76839. * The list of unifrom names used in the shader
  76840. */
  76841. uniforms: string[];
  76842. /**
  76843. * The list of UBO names used in the shader
  76844. */
  76845. uniformBuffers: string[];
  76846. /**
  76847. * The list of sampler names used in the shader
  76848. */
  76849. samplers: string[];
  76850. /**
  76851. * The list of defines used in the shader
  76852. */
  76853. defines: string[];
  76854. }
  76855. /**
  76856. * 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.
  76857. *
  76858. * This returned material effects how the mesh will look based on the code in the shaders.
  76859. *
  76860. * @see http://doc.babylonjs.com/how_to/shader_material
  76861. */
  76862. export class ShaderMaterial extends Material {
  76863. private _shaderPath;
  76864. private _options;
  76865. private _textures;
  76866. private _textureArrays;
  76867. private _floats;
  76868. private _ints;
  76869. private _floatsArrays;
  76870. private _colors3;
  76871. private _colors3Arrays;
  76872. private _colors4;
  76873. private _vectors2;
  76874. private _vectors3;
  76875. private _vectors4;
  76876. private _matrices;
  76877. private _matrices3x3;
  76878. private _matrices2x2;
  76879. private _vectors2Arrays;
  76880. private _vectors3Arrays;
  76881. private _cachedWorldViewMatrix;
  76882. private _renderId;
  76883. /**
  76884. * Instantiate a new shader material.
  76885. * 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.
  76886. * This returned material effects how the mesh will look based on the code in the shaders.
  76887. * @see http://doc.babylonjs.com/how_to/shader_material
  76888. * @param name Define the name of the material in the scene
  76889. * @param scene Define the scene the material belongs to
  76890. * @param shaderPath Defines the route to the shader code in one of three ways:
  76891. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76892. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76893. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76894. * @param options Define the options used to create the shader
  76895. */
  76896. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76897. /**
  76898. * Gets the options used to compile the shader.
  76899. * They can be modified to trigger a new compilation
  76900. */
  76901. readonly options: IShaderMaterialOptions;
  76902. /**
  76903. * Gets the current class name of the material e.g. "ShaderMaterial"
  76904. * Mainly use in serialization.
  76905. * @returns the class name
  76906. */
  76907. getClassName(): string;
  76908. /**
  76909. * Specifies if the material will require alpha blending
  76910. * @returns a boolean specifying if alpha blending is needed
  76911. */
  76912. needAlphaBlending(): boolean;
  76913. /**
  76914. * Specifies if this material should be rendered in alpha test mode
  76915. * @returns a boolean specifying if an alpha test is needed.
  76916. */
  76917. needAlphaTesting(): boolean;
  76918. private _checkUniform;
  76919. /**
  76920. * Set a texture in the shader.
  76921. * @param name Define the name of the uniform samplers as defined in the shader
  76922. * @param texture Define the texture to bind to this sampler
  76923. * @return the material itself allowing "fluent" like uniform updates
  76924. */
  76925. setTexture(name: string, texture: Texture): ShaderMaterial;
  76926. /**
  76927. * Set a texture array in the shader.
  76928. * @param name Define the name of the uniform sampler array as defined in the shader
  76929. * @param textures Define the list of textures to bind to this sampler
  76930. * @return the material itself allowing "fluent" like uniform updates
  76931. */
  76932. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76933. /**
  76934. * Set a float in the shader.
  76935. * @param name Define the name of the uniform as defined in the shader
  76936. * @param value Define the value to give to the uniform
  76937. * @return the material itself allowing "fluent" like uniform updates
  76938. */
  76939. setFloat(name: string, value: number): ShaderMaterial;
  76940. /**
  76941. * Set a int in the shader.
  76942. * @param name Define the name of the uniform as defined in the shader
  76943. * @param value Define the value to give to the uniform
  76944. * @return the material itself allowing "fluent" like uniform updates
  76945. */
  76946. setInt(name: string, value: number): ShaderMaterial;
  76947. /**
  76948. * Set an array of floats in the shader.
  76949. * @param name Define the name of the uniform as defined in the shader
  76950. * @param value Define the value to give to the uniform
  76951. * @return the material itself allowing "fluent" like uniform updates
  76952. */
  76953. setFloats(name: string, value: number[]): ShaderMaterial;
  76954. /**
  76955. * Set a vec3 in the shader from a Color3.
  76956. * @param name Define the name of the uniform as defined in the shader
  76957. * @param value Define the value to give to the uniform
  76958. * @return the material itself allowing "fluent" like uniform updates
  76959. */
  76960. setColor3(name: string, value: Color3): ShaderMaterial;
  76961. /**
  76962. * Set a vec3 array in the shader from a Color3 array.
  76963. * @param name Define the name of the uniform as defined in the shader
  76964. * @param value Define the value to give to the uniform
  76965. * @return the material itself allowing "fluent" like uniform updates
  76966. */
  76967. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76968. /**
  76969. * Set a vec4 in the shader from a Color4.
  76970. * @param name Define the name of the uniform as defined in the shader
  76971. * @param value Define the value to give to the uniform
  76972. * @return the material itself allowing "fluent" like uniform updates
  76973. */
  76974. setColor4(name: string, value: Color4): ShaderMaterial;
  76975. /**
  76976. * Set a vec2 in the shader from a Vector2.
  76977. * @param name Define the name of the uniform as defined in the shader
  76978. * @param value Define the value to give to the uniform
  76979. * @return the material itself allowing "fluent" like uniform updates
  76980. */
  76981. setVector2(name: string, value: Vector2): ShaderMaterial;
  76982. /**
  76983. * Set a vec3 in the shader from a Vector3.
  76984. * @param name Define the name of the uniform as defined in the shader
  76985. * @param value Define the value to give to the uniform
  76986. * @return the material itself allowing "fluent" like uniform updates
  76987. */
  76988. setVector3(name: string, value: Vector3): ShaderMaterial;
  76989. /**
  76990. * Set a vec4 in the shader from a Vector4.
  76991. * @param name Define the name of the uniform as defined in the shader
  76992. * @param value Define the value to give to the uniform
  76993. * @return the material itself allowing "fluent" like uniform updates
  76994. */
  76995. setVector4(name: string, value: Vector4): ShaderMaterial;
  76996. /**
  76997. * Set a mat4 in the shader from a Matrix.
  76998. * @param name Define the name of the uniform as defined in the shader
  76999. * @param value Define the value to give to the uniform
  77000. * @return the material itself allowing "fluent" like uniform updates
  77001. */
  77002. setMatrix(name: string, value: Matrix): ShaderMaterial;
  77003. /**
  77004. * Set a mat3 in the shader from a Float32Array.
  77005. * @param name Define the name of the uniform as defined in the shader
  77006. * @param value Define the value to give to the uniform
  77007. * @return the material itself allowing "fluent" like uniform updates
  77008. */
  77009. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  77010. /**
  77011. * Set a mat2 in the shader from a Float32Array.
  77012. * @param name Define the name of the uniform as defined in the shader
  77013. * @param value Define the value to give to the uniform
  77014. * @return the material itself allowing "fluent" like uniform updates
  77015. */
  77016. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  77017. /**
  77018. * Set a vec2 array in the shader from a number array.
  77019. * @param name Define the name of the uniform as defined in the shader
  77020. * @param value Define the value to give to the uniform
  77021. * @return the material itself allowing "fluent" like uniform updates
  77022. */
  77023. setArray2(name: string, value: number[]): ShaderMaterial;
  77024. /**
  77025. * Set a vec3 array in the shader from a number array.
  77026. * @param name Define the name of the uniform as defined in the shader
  77027. * @param value Define the value to give to the uniform
  77028. * @return the material itself allowing "fluent" like uniform updates
  77029. */
  77030. setArray3(name: string, value: number[]): ShaderMaterial;
  77031. private _checkCache;
  77032. /**
  77033. * Specifies that the submesh is ready to be used
  77034. * @param mesh defines the mesh to check
  77035. * @param subMesh defines which submesh to check
  77036. * @param useInstances specifies that instances should be used
  77037. * @returns a boolean indicating that the submesh is ready or not
  77038. */
  77039. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77040. /**
  77041. * Checks if the material is ready to render the requested mesh
  77042. * @param mesh Define the mesh to render
  77043. * @param useInstances Define whether or not the material is used with instances
  77044. * @returns true if ready, otherwise false
  77045. */
  77046. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  77047. /**
  77048. * Binds the world matrix to the material
  77049. * @param world defines the world transformation matrix
  77050. */
  77051. bindOnlyWorldMatrix(world: Matrix): void;
  77052. /**
  77053. * Binds the material to the mesh
  77054. * @param world defines the world transformation matrix
  77055. * @param mesh defines the mesh to bind the material to
  77056. */
  77057. bind(world: Matrix, mesh?: Mesh): void;
  77058. /**
  77059. * Gets the active textures from the material
  77060. * @returns an array of textures
  77061. */
  77062. getActiveTextures(): BaseTexture[];
  77063. /**
  77064. * Specifies if the material uses a texture
  77065. * @param texture defines the texture to check against the material
  77066. * @returns a boolean specifying if the material uses the texture
  77067. */
  77068. hasTexture(texture: BaseTexture): boolean;
  77069. /**
  77070. * Makes a duplicate of the material, and gives it a new name
  77071. * @param name defines the new name for the duplicated material
  77072. * @returns the cloned material
  77073. */
  77074. clone(name: string): ShaderMaterial;
  77075. /**
  77076. * Disposes the material
  77077. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77078. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77079. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77080. */
  77081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77082. /**
  77083. * Serializes this material in a JSON representation
  77084. * @returns the serialized material object
  77085. */
  77086. serialize(): any;
  77087. /**
  77088. * Creates a shader material from parsed shader material data
  77089. * @param source defines the JSON represnetation of the material
  77090. * @param scene defines the hosting scene
  77091. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77092. * @returns a new material
  77093. */
  77094. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  77095. }
  77096. }
  77097. declare module BABYLON {
  77098. /** @hidden */
  77099. export var colorPixelShader: {
  77100. name: string;
  77101. shader: string;
  77102. };
  77103. }
  77104. declare module BABYLON {
  77105. /** @hidden */
  77106. export var colorVertexShader: {
  77107. name: string;
  77108. shader: string;
  77109. };
  77110. }
  77111. declare module BABYLON {
  77112. /**
  77113. * Line mesh
  77114. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  77115. */
  77116. export class LinesMesh extends Mesh {
  77117. /**
  77118. * If vertex color should be applied to the mesh
  77119. */
  77120. useVertexColor?: boolean | undefined;
  77121. /**
  77122. * If vertex alpha should be applied to the mesh
  77123. */
  77124. useVertexAlpha?: boolean | undefined;
  77125. /**
  77126. * Color of the line (Default: White)
  77127. */
  77128. color: Color3;
  77129. /**
  77130. * Alpha of the line (Default: 1)
  77131. */
  77132. alpha: number;
  77133. /**
  77134. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77135. * This margin is expressed in world space coordinates, so its value may vary.
  77136. * Default value is 0.1
  77137. */
  77138. intersectionThreshold: number;
  77139. private _colorShader;
  77140. /**
  77141. * Creates a new LinesMesh
  77142. * @param name defines the name
  77143. * @param scene defines the hosting scene
  77144. * @param parent defines the parent mesh if any
  77145. * @param source defines the optional source LinesMesh used to clone data from
  77146. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77147. * When false, achieved by calling a clone(), also passing False.
  77148. * This will make creation of children, recursive.
  77149. * @param useVertexColor defines if this LinesMesh supports vertex color
  77150. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  77151. */
  77152. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  77153. /**
  77154. * If vertex color should be applied to the mesh
  77155. */
  77156. useVertexColor?: boolean | undefined,
  77157. /**
  77158. * If vertex alpha should be applied to the mesh
  77159. */
  77160. useVertexAlpha?: boolean | undefined);
  77161. private _addClipPlaneDefine;
  77162. private _removeClipPlaneDefine;
  77163. isReady(): boolean;
  77164. /**
  77165. * Returns the string "LineMesh"
  77166. */
  77167. getClassName(): string;
  77168. /**
  77169. * @hidden
  77170. */
  77171. /**
  77172. * @hidden
  77173. */
  77174. material: Material;
  77175. /**
  77176. * @hidden
  77177. */
  77178. readonly checkCollisions: boolean;
  77179. /** @hidden */
  77180. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  77181. /** @hidden */
  77182. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  77183. /**
  77184. * Disposes of the line mesh
  77185. * @param doNotRecurse If children should be disposed
  77186. */
  77187. dispose(doNotRecurse?: boolean): void;
  77188. /**
  77189. * Returns a new LineMesh object cloned from the current one.
  77190. */
  77191. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  77192. /**
  77193. * Creates a new InstancedLinesMesh object from the mesh model.
  77194. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77195. * @param name defines the name of the new instance
  77196. * @returns a new InstancedLinesMesh
  77197. */
  77198. createInstance(name: string): InstancedLinesMesh;
  77199. }
  77200. /**
  77201. * Creates an instance based on a source LinesMesh
  77202. */
  77203. export class InstancedLinesMesh extends InstancedMesh {
  77204. /**
  77205. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77206. * This margin is expressed in world space coordinates, so its value may vary.
  77207. * Initilized with the intersectionThreshold value of the source LinesMesh
  77208. */
  77209. intersectionThreshold: number;
  77210. constructor(name: string, source: LinesMesh);
  77211. /**
  77212. * Returns the string "InstancedLinesMesh".
  77213. */
  77214. getClassName(): string;
  77215. }
  77216. }
  77217. declare module BABYLON {
  77218. /** @hidden */
  77219. export var linePixelShader: {
  77220. name: string;
  77221. shader: string;
  77222. };
  77223. }
  77224. declare module BABYLON {
  77225. /** @hidden */
  77226. export var lineVertexShader: {
  77227. name: string;
  77228. shader: string;
  77229. };
  77230. }
  77231. declare module BABYLON {
  77232. interface AbstractMesh {
  77233. /**
  77234. * Disables the mesh edge rendering mode
  77235. * @returns the currentAbstractMesh
  77236. */
  77237. disableEdgesRendering(): AbstractMesh;
  77238. /**
  77239. * Enables the edge rendering mode on the mesh.
  77240. * This mode makes the mesh edges visible
  77241. * @param epsilon defines the maximal distance between two angles to detect a face
  77242. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77243. * @returns the currentAbstractMesh
  77244. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77245. */
  77246. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77247. /**
  77248. * Gets the edgesRenderer associated with the mesh
  77249. */
  77250. edgesRenderer: Nullable<EdgesRenderer>;
  77251. }
  77252. interface LinesMesh {
  77253. /**
  77254. * Enables the edge rendering mode on the mesh.
  77255. * This mode makes the mesh edges visible
  77256. * @param epsilon defines the maximal distance between two angles to detect a face
  77257. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77258. * @returns the currentAbstractMesh
  77259. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77260. */
  77261. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77262. }
  77263. interface InstancedLinesMesh {
  77264. /**
  77265. * Enables the edge rendering mode on the mesh.
  77266. * This mode makes the mesh edges visible
  77267. * @param epsilon defines the maximal distance between two angles to detect a face
  77268. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77269. * @returns the current InstancedLinesMesh
  77270. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77271. */
  77272. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  77273. }
  77274. /**
  77275. * Defines the minimum contract an Edges renderer should follow.
  77276. */
  77277. export interface IEdgesRenderer extends IDisposable {
  77278. /**
  77279. * Gets or sets a boolean indicating if the edgesRenderer is active
  77280. */
  77281. isEnabled: boolean;
  77282. /**
  77283. * Renders the edges of the attached mesh,
  77284. */
  77285. render(): void;
  77286. /**
  77287. * Checks wether or not the edges renderer is ready to render.
  77288. * @return true if ready, otherwise false.
  77289. */
  77290. isReady(): boolean;
  77291. }
  77292. /**
  77293. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  77294. */
  77295. export class EdgesRenderer implements IEdgesRenderer {
  77296. /**
  77297. * Define the size of the edges with an orthographic camera
  77298. */
  77299. edgesWidthScalerForOrthographic: number;
  77300. /**
  77301. * Define the size of the edges with a perspective camera
  77302. */
  77303. edgesWidthScalerForPerspective: number;
  77304. protected _source: AbstractMesh;
  77305. protected _linesPositions: number[];
  77306. protected _linesNormals: number[];
  77307. protected _linesIndices: number[];
  77308. protected _epsilon: number;
  77309. protected _indicesCount: number;
  77310. protected _lineShader: ShaderMaterial;
  77311. protected _ib: DataBuffer;
  77312. protected _buffers: {
  77313. [key: string]: Nullable<VertexBuffer>;
  77314. };
  77315. protected _checkVerticesInsteadOfIndices: boolean;
  77316. private _meshRebuildObserver;
  77317. private _meshDisposeObserver;
  77318. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  77319. isEnabled: boolean;
  77320. /**
  77321. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  77322. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  77323. * @param source Mesh used to create edges
  77324. * @param epsilon sum of angles in adjacency to check for edge
  77325. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  77326. * @param generateEdgesLines - should generate Lines or only prepare resources.
  77327. */
  77328. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  77329. protected _prepareRessources(): void;
  77330. /** @hidden */
  77331. _rebuild(): void;
  77332. /**
  77333. * Releases the required resources for the edges renderer
  77334. */
  77335. dispose(): void;
  77336. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  77337. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  77338. /**
  77339. * Checks if the pair of p0 and p1 is en edge
  77340. * @param faceIndex
  77341. * @param edge
  77342. * @param faceNormals
  77343. * @param p0
  77344. * @param p1
  77345. * @private
  77346. */
  77347. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  77348. /**
  77349. * push line into the position, normal and index buffer
  77350. * @protected
  77351. */
  77352. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  77353. /**
  77354. * Generates lines edges from adjacencjes
  77355. * @private
  77356. */
  77357. _generateEdgesLines(): void;
  77358. /**
  77359. * Checks wether or not the edges renderer is ready to render.
  77360. * @return true if ready, otherwise false.
  77361. */
  77362. isReady(): boolean;
  77363. /**
  77364. * Renders the edges of the attached mesh,
  77365. */
  77366. render(): void;
  77367. }
  77368. /**
  77369. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  77370. */
  77371. export class LineEdgesRenderer extends EdgesRenderer {
  77372. /**
  77373. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  77374. * @param source LineMesh used to generate edges
  77375. * @param epsilon not important (specified angle for edge detection)
  77376. * @param checkVerticesInsteadOfIndices not important for LineMesh
  77377. */
  77378. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  77379. /**
  77380. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  77381. */
  77382. _generateEdgesLines(): void;
  77383. }
  77384. }
  77385. declare module BABYLON {
  77386. /**
  77387. * This represents the object necessary to create a rendering group.
  77388. * This is exclusively used and created by the rendering manager.
  77389. * To modify the behavior, you use the available helpers in your scene or meshes.
  77390. * @hidden
  77391. */
  77392. export class RenderingGroup {
  77393. index: number;
  77394. private _scene;
  77395. private _opaqueSubMeshes;
  77396. private _transparentSubMeshes;
  77397. private _alphaTestSubMeshes;
  77398. private _depthOnlySubMeshes;
  77399. private _particleSystems;
  77400. private _spriteManagers;
  77401. private _opaqueSortCompareFn;
  77402. private _alphaTestSortCompareFn;
  77403. private _transparentSortCompareFn;
  77404. private _renderOpaque;
  77405. private _renderAlphaTest;
  77406. private _renderTransparent;
  77407. /** @hidden */
  77408. _edgesRenderers: SmartArray<IEdgesRenderer>;
  77409. onBeforeTransparentRendering: () => void;
  77410. /**
  77411. * Set the opaque sort comparison function.
  77412. * If null the sub meshes will be render in the order they were created
  77413. */
  77414. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77415. /**
  77416. * Set the alpha test sort comparison function.
  77417. * If null the sub meshes will be render in the order they were created
  77418. */
  77419. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77420. /**
  77421. * Set the transparent sort comparison function.
  77422. * If null the sub meshes will be render in the order they were created
  77423. */
  77424. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77425. /**
  77426. * Creates a new rendering group.
  77427. * @param index The rendering group index
  77428. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77429. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77430. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77431. */
  77432. 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>);
  77433. /**
  77434. * Render all the sub meshes contained in the group.
  77435. * @param customRenderFunction Used to override the default render behaviour of the group.
  77436. * @returns true if rendered some submeshes.
  77437. */
  77438. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77439. /**
  77440. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77441. * @param subMeshes The submeshes to render
  77442. */
  77443. private renderOpaqueSorted;
  77444. /**
  77445. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77446. * @param subMeshes The submeshes to render
  77447. */
  77448. private renderAlphaTestSorted;
  77449. /**
  77450. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77451. * @param subMeshes The submeshes to render
  77452. */
  77453. private renderTransparentSorted;
  77454. /**
  77455. * Renders the submeshes in a specified order.
  77456. * @param subMeshes The submeshes to sort before render
  77457. * @param sortCompareFn The comparison function use to sort
  77458. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77459. * @param transparent Specifies to activate blending if true
  77460. */
  77461. private static renderSorted;
  77462. /**
  77463. * Renders the submeshes in the order they were dispatched (no sort applied).
  77464. * @param subMeshes The submeshes to render
  77465. */
  77466. private static renderUnsorted;
  77467. /**
  77468. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77469. * are rendered back to front if in the same alpha index.
  77470. *
  77471. * @param a The first submesh
  77472. * @param b The second submesh
  77473. * @returns The result of the comparison
  77474. */
  77475. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77476. /**
  77477. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77478. * are rendered back to front.
  77479. *
  77480. * @param a The first submesh
  77481. * @param b The second submesh
  77482. * @returns The result of the comparison
  77483. */
  77484. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77485. /**
  77486. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77487. * are rendered front to back (prevent overdraw).
  77488. *
  77489. * @param a The first submesh
  77490. * @param b The second submesh
  77491. * @returns The result of the comparison
  77492. */
  77493. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77494. /**
  77495. * Resets the different lists of submeshes to prepare a new frame.
  77496. */
  77497. prepare(): void;
  77498. dispose(): void;
  77499. /**
  77500. * Inserts the submesh in its correct queue depending on its material.
  77501. * @param subMesh The submesh to dispatch
  77502. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77503. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77504. */
  77505. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77506. dispatchSprites(spriteManager: ISpriteManager): void;
  77507. dispatchParticles(particleSystem: IParticleSystem): void;
  77508. private _renderParticles;
  77509. private _renderSprites;
  77510. }
  77511. }
  77512. declare module BABYLON {
  77513. /**
  77514. * Interface describing the different options available in the rendering manager
  77515. * regarding Auto Clear between groups.
  77516. */
  77517. export interface IRenderingManagerAutoClearSetup {
  77518. /**
  77519. * Defines whether or not autoclear is enable.
  77520. */
  77521. autoClear: boolean;
  77522. /**
  77523. * Defines whether or not to autoclear the depth buffer.
  77524. */
  77525. depth: boolean;
  77526. /**
  77527. * Defines whether or not to autoclear the stencil buffer.
  77528. */
  77529. stencil: boolean;
  77530. }
  77531. /**
  77532. * This class is used by the onRenderingGroupObservable
  77533. */
  77534. export class RenderingGroupInfo {
  77535. /**
  77536. * The Scene that being rendered
  77537. */
  77538. scene: Scene;
  77539. /**
  77540. * The camera currently used for the rendering pass
  77541. */
  77542. camera: Nullable<Camera>;
  77543. /**
  77544. * The ID of the renderingGroup being processed
  77545. */
  77546. renderingGroupId: number;
  77547. }
  77548. /**
  77549. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77550. * It is enable to manage the different groups as well as the different necessary sort functions.
  77551. * This should not be used directly aside of the few static configurations
  77552. */
  77553. export class RenderingManager {
  77554. /**
  77555. * The max id used for rendering groups (not included)
  77556. */
  77557. static MAX_RENDERINGGROUPS: number;
  77558. /**
  77559. * The min id used for rendering groups (included)
  77560. */
  77561. static MIN_RENDERINGGROUPS: number;
  77562. /**
  77563. * Used to globally prevent autoclearing scenes.
  77564. */
  77565. static AUTOCLEAR: boolean;
  77566. /**
  77567. * @hidden
  77568. */
  77569. _useSceneAutoClearSetup: boolean;
  77570. private _scene;
  77571. private _renderingGroups;
  77572. private _depthStencilBufferAlreadyCleaned;
  77573. private _autoClearDepthStencil;
  77574. private _customOpaqueSortCompareFn;
  77575. private _customAlphaTestSortCompareFn;
  77576. private _customTransparentSortCompareFn;
  77577. private _renderingGroupInfo;
  77578. /**
  77579. * Instantiates a new rendering group for a particular scene
  77580. * @param scene Defines the scene the groups belongs to
  77581. */
  77582. constructor(scene: Scene);
  77583. private _clearDepthStencilBuffer;
  77584. /**
  77585. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77586. * @hidden
  77587. */
  77588. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77589. /**
  77590. * Resets the different information of the group to prepare a new frame
  77591. * @hidden
  77592. */
  77593. reset(): void;
  77594. /**
  77595. * Dispose and release the group and its associated resources.
  77596. * @hidden
  77597. */
  77598. dispose(): void;
  77599. /**
  77600. * Clear the info related to rendering groups preventing retention points during dispose.
  77601. */
  77602. freeRenderingGroups(): void;
  77603. private _prepareRenderingGroup;
  77604. /**
  77605. * Add a sprite manager to the rendering manager in order to render it this frame.
  77606. * @param spriteManager Define the sprite manager to render
  77607. */
  77608. dispatchSprites(spriteManager: ISpriteManager): void;
  77609. /**
  77610. * Add a particle system to the rendering manager in order to render it this frame.
  77611. * @param particleSystem Define the particle system to render
  77612. */
  77613. dispatchParticles(particleSystem: IParticleSystem): void;
  77614. /**
  77615. * Add a submesh to the manager in order to render it this frame
  77616. * @param subMesh The submesh to dispatch
  77617. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77618. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77619. */
  77620. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77621. /**
  77622. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77623. * This allowed control for front to back rendering or reversly depending of the special needs.
  77624. *
  77625. * @param renderingGroupId The rendering group id corresponding to its index
  77626. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77627. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77628. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77629. */
  77630. 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;
  77631. /**
  77632. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77633. *
  77634. * @param renderingGroupId The rendering group id corresponding to its index
  77635. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77636. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77637. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77638. */
  77639. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77640. /**
  77641. * Gets the current auto clear configuration for one rendering group of the rendering
  77642. * manager.
  77643. * @param index the rendering group index to get the information for
  77644. * @returns The auto clear setup for the requested rendering group
  77645. */
  77646. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77647. }
  77648. }
  77649. declare module BABYLON {
  77650. /**
  77651. * This Helps creating a texture that will be created from a camera in your scene.
  77652. * It is basically a dynamic texture that could be used to create special effects for instance.
  77653. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77654. */
  77655. export class RenderTargetTexture extends Texture {
  77656. isCube: boolean;
  77657. /**
  77658. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77659. */
  77660. static readonly REFRESHRATE_RENDER_ONCE: number;
  77661. /**
  77662. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77663. */
  77664. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77665. /**
  77666. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77667. * the central point of your effect and can save a lot of performances.
  77668. */
  77669. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77670. /**
  77671. * Use this predicate to dynamically define the list of mesh you want to render.
  77672. * If set, the renderList property will be overwritten.
  77673. */
  77674. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77675. private _renderList;
  77676. /**
  77677. * Use this list to define the list of mesh you want to render.
  77678. */
  77679. renderList: Nullable<Array<AbstractMesh>>;
  77680. private _hookArray;
  77681. /**
  77682. * Define if particles should be rendered in your texture.
  77683. */
  77684. renderParticles: boolean;
  77685. /**
  77686. * Define if sprites should be rendered in your texture.
  77687. */
  77688. renderSprites: boolean;
  77689. /**
  77690. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77691. */
  77692. coordinatesMode: number;
  77693. /**
  77694. * Define the camera used to render the texture.
  77695. */
  77696. activeCamera: Nullable<Camera>;
  77697. /**
  77698. * Override the render function of the texture with your own one.
  77699. */
  77700. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77701. /**
  77702. * Define if camera post processes should be use while rendering the texture.
  77703. */
  77704. useCameraPostProcesses: boolean;
  77705. /**
  77706. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77707. */
  77708. ignoreCameraViewport: boolean;
  77709. private _postProcessManager;
  77710. private _postProcesses;
  77711. private _resizeObserver;
  77712. /**
  77713. * An event triggered when the texture is unbind.
  77714. */
  77715. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77716. /**
  77717. * An event triggered when the texture is unbind.
  77718. */
  77719. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77720. private _onAfterUnbindObserver;
  77721. /**
  77722. * Set a after unbind callback in the texture.
  77723. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77724. */
  77725. onAfterUnbind: () => void;
  77726. /**
  77727. * An event triggered before rendering the texture
  77728. */
  77729. onBeforeRenderObservable: Observable<number>;
  77730. private _onBeforeRenderObserver;
  77731. /**
  77732. * Set a before render callback in the texture.
  77733. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77734. */
  77735. onBeforeRender: (faceIndex: number) => void;
  77736. /**
  77737. * An event triggered after rendering the texture
  77738. */
  77739. onAfterRenderObservable: Observable<number>;
  77740. private _onAfterRenderObserver;
  77741. /**
  77742. * Set a after render callback in the texture.
  77743. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77744. */
  77745. onAfterRender: (faceIndex: number) => void;
  77746. /**
  77747. * An event triggered after the texture clear
  77748. */
  77749. onClearObservable: Observable<Engine>;
  77750. private _onClearObserver;
  77751. /**
  77752. * Set a clear callback in the texture.
  77753. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77754. */
  77755. onClear: (Engine: Engine) => void;
  77756. /**
  77757. * Define the clear color of the Render Target if it should be different from the scene.
  77758. */
  77759. clearColor: Color4;
  77760. protected _size: number | {
  77761. width: number;
  77762. height: number;
  77763. };
  77764. protected _initialSizeParameter: number | {
  77765. width: number;
  77766. height: number;
  77767. } | {
  77768. ratio: number;
  77769. };
  77770. protected _sizeRatio: Nullable<number>;
  77771. /** @hidden */
  77772. _generateMipMaps: boolean;
  77773. protected _renderingManager: RenderingManager;
  77774. /** @hidden */
  77775. _waitingRenderList: string[];
  77776. protected _doNotChangeAspectRatio: boolean;
  77777. protected _currentRefreshId: number;
  77778. protected _refreshRate: number;
  77779. protected _textureMatrix: Matrix;
  77780. protected _samples: number;
  77781. protected _renderTargetOptions: RenderTargetCreationOptions;
  77782. /**
  77783. * Gets render target creation options that were used.
  77784. */
  77785. readonly renderTargetOptions: RenderTargetCreationOptions;
  77786. protected _engine: Engine;
  77787. protected _onRatioRescale(): void;
  77788. /**
  77789. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77790. * It must define where the camera used to render the texture is set
  77791. */
  77792. boundingBoxPosition: Vector3;
  77793. private _boundingBoxSize;
  77794. /**
  77795. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77796. * When defined, the cubemap will switch to local mode
  77797. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77798. * @example https://www.babylonjs-playground.com/#RNASML
  77799. */
  77800. boundingBoxSize: Vector3;
  77801. /**
  77802. * In case the RTT has been created with a depth texture, get the associated
  77803. * depth texture.
  77804. * Otherwise, return null.
  77805. */
  77806. depthStencilTexture: Nullable<InternalTexture>;
  77807. /**
  77808. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77809. * or used a shadow, depth texture...
  77810. * @param name The friendly name of the texture
  77811. * @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)
  77812. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77813. * @param generateMipMaps True if mip maps need to be generated after render.
  77814. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77815. * @param type The type of the buffer in the RTT (int, half float, float...)
  77816. * @param isCube True if a cube texture needs to be created
  77817. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77818. * @param generateDepthBuffer True to generate a depth buffer
  77819. * @param generateStencilBuffer True to generate a stencil buffer
  77820. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77821. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77822. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77823. */
  77824. constructor(name: string, size: number | {
  77825. width: number;
  77826. height: number;
  77827. } | {
  77828. ratio: number;
  77829. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77830. /**
  77831. * Creates a depth stencil texture.
  77832. * This is only available in WebGL 2 or with the depth texture extension available.
  77833. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77834. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77835. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77836. */
  77837. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77838. private _processSizeParameter;
  77839. /**
  77840. * Define the number of samples to use in case of MSAA.
  77841. * It defaults to one meaning no MSAA has been enabled.
  77842. */
  77843. samples: number;
  77844. /**
  77845. * Resets the refresh counter of the texture and start bak from scratch.
  77846. * Could be useful to regenerate the texture if it is setup to render only once.
  77847. */
  77848. resetRefreshCounter(): void;
  77849. /**
  77850. * Define the refresh rate of the texture or the rendering frequency.
  77851. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77852. */
  77853. refreshRate: number;
  77854. /**
  77855. * Adds a post process to the render target rendering passes.
  77856. * @param postProcess define the post process to add
  77857. */
  77858. addPostProcess(postProcess: PostProcess): void;
  77859. /**
  77860. * Clear all the post processes attached to the render target
  77861. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77862. */
  77863. clearPostProcesses(dispose?: boolean): void;
  77864. /**
  77865. * Remove one of the post process from the list of attached post processes to the texture
  77866. * @param postProcess define the post process to remove from the list
  77867. */
  77868. removePostProcess(postProcess: PostProcess): void;
  77869. /** @hidden */
  77870. _shouldRender(): boolean;
  77871. /**
  77872. * Gets the actual render size of the texture.
  77873. * @returns the width of the render size
  77874. */
  77875. getRenderSize(): number;
  77876. /**
  77877. * Gets the actual render width of the texture.
  77878. * @returns the width of the render size
  77879. */
  77880. getRenderWidth(): number;
  77881. /**
  77882. * Gets the actual render height of the texture.
  77883. * @returns the height of the render size
  77884. */
  77885. getRenderHeight(): number;
  77886. /**
  77887. * Get if the texture can be rescaled or not.
  77888. */
  77889. readonly canRescale: boolean;
  77890. /**
  77891. * Resize the texture using a ratio.
  77892. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77893. */
  77894. scale(ratio: number): void;
  77895. /**
  77896. * Get the texture reflection matrix used to rotate/transform the reflection.
  77897. * @returns the reflection matrix
  77898. */
  77899. getReflectionTextureMatrix(): Matrix;
  77900. /**
  77901. * Resize the texture to a new desired size.
  77902. * Be carrefull as it will recreate all the data in the new texture.
  77903. * @param size Define the new size. It can be:
  77904. * - a number for squared texture,
  77905. * - an object containing { width: number, height: number }
  77906. * - or an object containing a ratio { ratio: number }
  77907. */
  77908. resize(size: number | {
  77909. width: number;
  77910. height: number;
  77911. } | {
  77912. ratio: number;
  77913. }): void;
  77914. /**
  77915. * Renders all the objects from the render list into the texture.
  77916. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77917. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77918. */
  77919. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77920. private _bestReflectionRenderTargetDimension;
  77921. /**
  77922. * @hidden
  77923. * @param faceIndex face index to bind to if this is a cubetexture
  77924. */
  77925. _bindFrameBuffer(faceIndex?: number): void;
  77926. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77927. private renderToTarget;
  77928. /**
  77929. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77930. * This allowed control for front to back rendering or reversly depending of the special needs.
  77931. *
  77932. * @param renderingGroupId The rendering group id corresponding to its index
  77933. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77934. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77935. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77936. */
  77937. 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;
  77938. /**
  77939. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77940. *
  77941. * @param renderingGroupId The rendering group id corresponding to its index
  77942. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77943. */
  77944. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77945. /**
  77946. * Clones the texture.
  77947. * @returns the cloned texture
  77948. */
  77949. clone(): RenderTargetTexture;
  77950. /**
  77951. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77952. * @returns The JSON representation of the texture
  77953. */
  77954. serialize(): any;
  77955. /**
  77956. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77957. */
  77958. disposeFramebufferObjects(): void;
  77959. /**
  77960. * Dispose the texture and release its associated resources.
  77961. */
  77962. dispose(): void;
  77963. /** @hidden */
  77964. _rebuild(): void;
  77965. /**
  77966. * Clear the info related to rendering groups preventing retention point in material dispose.
  77967. */
  77968. freeRenderingGroups(): void;
  77969. /**
  77970. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77971. * @returns the view count
  77972. */
  77973. getViewCount(): number;
  77974. }
  77975. }
  77976. declare module BABYLON {
  77977. /**
  77978. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77979. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77980. * You can then easily use it as a reflectionTexture on a flat surface.
  77981. * In case the surface is not a plane, please consider relying on reflection probes.
  77982. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77983. */
  77984. export class MirrorTexture extends RenderTargetTexture {
  77985. private scene;
  77986. /**
  77987. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  77988. * 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.
  77989. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77990. */
  77991. mirrorPlane: Plane;
  77992. /**
  77993. * Define the blur ratio used to blur the reflection if needed.
  77994. */
  77995. blurRatio: number;
  77996. /**
  77997. * Define the adaptive blur kernel used to blur the reflection if needed.
  77998. * This will autocompute the closest best match for the `blurKernel`
  77999. */
  78000. adaptiveBlurKernel: number;
  78001. /**
  78002. * Define the blur kernel used to blur the reflection if needed.
  78003. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78004. */
  78005. blurKernel: number;
  78006. /**
  78007. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  78008. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78009. */
  78010. blurKernelX: number;
  78011. /**
  78012. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  78013. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78014. */
  78015. blurKernelY: number;
  78016. private _autoComputeBlurKernel;
  78017. protected _onRatioRescale(): void;
  78018. private _updateGammaSpace;
  78019. private _imageProcessingConfigChangeObserver;
  78020. private _transformMatrix;
  78021. private _mirrorMatrix;
  78022. private _savedViewMatrix;
  78023. private _blurX;
  78024. private _blurY;
  78025. private _adaptiveBlurKernel;
  78026. private _blurKernelX;
  78027. private _blurKernelY;
  78028. private _blurRatio;
  78029. /**
  78030. * Instantiates a Mirror Texture.
  78031. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78032. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78033. * You can then easily use it as a reflectionTexture on a flat surface.
  78034. * In case the surface is not a plane, please consider relying on reflection probes.
  78035. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78036. * @param name
  78037. * @param size
  78038. * @param scene
  78039. * @param generateMipMaps
  78040. * @param type
  78041. * @param samplingMode
  78042. * @param generateDepthBuffer
  78043. */
  78044. constructor(name: string, size: number | {
  78045. width: number;
  78046. height: number;
  78047. } | {
  78048. ratio: number;
  78049. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  78050. private _preparePostProcesses;
  78051. /**
  78052. * Clone the mirror texture.
  78053. * @returns the cloned texture
  78054. */
  78055. clone(): MirrorTexture;
  78056. /**
  78057. * Serialize the texture to a JSON representation you could use in Parse later on
  78058. * @returns the serialized JSON representation
  78059. */
  78060. serialize(): any;
  78061. /**
  78062. * Dispose the texture and release its associated resources.
  78063. */
  78064. dispose(): void;
  78065. }
  78066. }
  78067. declare module BABYLON {
  78068. /**
  78069. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78070. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78071. */
  78072. export class Texture extends BaseTexture {
  78073. /** @hidden */
  78074. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  78075. /** @hidden */
  78076. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  78077. /** @hidden */
  78078. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  78079. /** nearest is mag = nearest and min = nearest and mip = linear */
  78080. static readonly NEAREST_SAMPLINGMODE: number;
  78081. /** nearest is mag = nearest and min = nearest and mip = linear */
  78082. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  78083. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78084. static readonly BILINEAR_SAMPLINGMODE: number;
  78085. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78086. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  78087. /** Trilinear is mag = linear and min = linear and mip = linear */
  78088. static readonly TRILINEAR_SAMPLINGMODE: number;
  78089. /** Trilinear is mag = linear and min = linear and mip = linear */
  78090. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  78091. /** mag = nearest and min = nearest and mip = nearest */
  78092. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  78093. /** mag = nearest and min = linear and mip = nearest */
  78094. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  78095. /** mag = nearest and min = linear and mip = linear */
  78096. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  78097. /** mag = nearest and min = linear and mip = none */
  78098. static readonly NEAREST_LINEAR: number;
  78099. /** mag = nearest and min = nearest and mip = none */
  78100. static readonly NEAREST_NEAREST: number;
  78101. /** mag = linear and min = nearest and mip = nearest */
  78102. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  78103. /** mag = linear and min = nearest and mip = linear */
  78104. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  78105. /** mag = linear and min = linear and mip = none */
  78106. static readonly LINEAR_LINEAR: number;
  78107. /** mag = linear and min = nearest and mip = none */
  78108. static readonly LINEAR_NEAREST: number;
  78109. /** Explicit coordinates mode */
  78110. static readonly EXPLICIT_MODE: number;
  78111. /** Spherical coordinates mode */
  78112. static readonly SPHERICAL_MODE: number;
  78113. /** Planar coordinates mode */
  78114. static readonly PLANAR_MODE: number;
  78115. /** Cubic coordinates mode */
  78116. static readonly CUBIC_MODE: number;
  78117. /** Projection coordinates mode */
  78118. static readonly PROJECTION_MODE: number;
  78119. /** Inverse Cubic coordinates mode */
  78120. static readonly SKYBOX_MODE: number;
  78121. /** Inverse Cubic coordinates mode */
  78122. static readonly INVCUBIC_MODE: number;
  78123. /** Equirectangular coordinates mode */
  78124. static readonly EQUIRECTANGULAR_MODE: number;
  78125. /** Equirectangular Fixed coordinates mode */
  78126. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  78127. /** Equirectangular Fixed Mirrored coordinates mode */
  78128. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78129. /** Texture is not repeating outside of 0..1 UVs */
  78130. static readonly CLAMP_ADDRESSMODE: number;
  78131. /** Texture is repeating outside of 0..1 UVs */
  78132. static readonly WRAP_ADDRESSMODE: number;
  78133. /** Texture is repeating and mirrored */
  78134. static readonly MIRROR_ADDRESSMODE: number;
  78135. /**
  78136. * 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
  78137. */
  78138. static UseSerializedUrlIfAny: boolean;
  78139. /**
  78140. * Define the url of the texture.
  78141. */
  78142. url: Nullable<string>;
  78143. /**
  78144. * Define an offset on the texture to offset the u coordinates of the UVs
  78145. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78146. */
  78147. uOffset: number;
  78148. /**
  78149. * Define an offset on the texture to offset the v coordinates of the UVs
  78150. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78151. */
  78152. vOffset: number;
  78153. /**
  78154. * Define an offset on the texture to scale the u coordinates of the UVs
  78155. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78156. */
  78157. uScale: number;
  78158. /**
  78159. * Define an offset on the texture to scale the v coordinates of the UVs
  78160. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78161. */
  78162. vScale: number;
  78163. /**
  78164. * Define an offset on the texture to rotate around the u coordinates of the UVs
  78165. * @see http://doc.babylonjs.com/how_to/more_materials
  78166. */
  78167. uAng: number;
  78168. /**
  78169. * Define an offset on the texture to rotate around the v coordinates of the UVs
  78170. * @see http://doc.babylonjs.com/how_to/more_materials
  78171. */
  78172. vAng: number;
  78173. /**
  78174. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  78175. * @see http://doc.babylonjs.com/how_to/more_materials
  78176. */
  78177. wAng: number;
  78178. /**
  78179. * Defines the center of rotation (U)
  78180. */
  78181. uRotationCenter: number;
  78182. /**
  78183. * Defines the center of rotation (V)
  78184. */
  78185. vRotationCenter: number;
  78186. /**
  78187. * Defines the center of rotation (W)
  78188. */
  78189. wRotationCenter: number;
  78190. /**
  78191. * Are mip maps generated for this texture or not.
  78192. */
  78193. readonly noMipmap: boolean;
  78194. /**
  78195. * List of inspectable custom properties (used by the Inspector)
  78196. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78197. */
  78198. inspectableCustomProperties: Nullable<IInspectable[]>;
  78199. private _noMipmap;
  78200. /** @hidden */
  78201. _invertY: boolean;
  78202. private _rowGenerationMatrix;
  78203. private _cachedTextureMatrix;
  78204. private _projectionModeMatrix;
  78205. private _t0;
  78206. private _t1;
  78207. private _t2;
  78208. private _cachedUOffset;
  78209. private _cachedVOffset;
  78210. private _cachedUScale;
  78211. private _cachedVScale;
  78212. private _cachedUAng;
  78213. private _cachedVAng;
  78214. private _cachedWAng;
  78215. private _cachedProjectionMatrixId;
  78216. private _cachedCoordinatesMode;
  78217. /** @hidden */
  78218. protected _initialSamplingMode: number;
  78219. /** @hidden */
  78220. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  78221. private _deleteBuffer;
  78222. protected _format: Nullable<number>;
  78223. private _delayedOnLoad;
  78224. private _delayedOnError;
  78225. /**
  78226. * Observable triggered once the texture has been loaded.
  78227. */
  78228. onLoadObservable: Observable<Texture>;
  78229. protected _isBlocking: boolean;
  78230. /**
  78231. * Is the texture preventing material to render while loading.
  78232. * If false, a default texture will be used instead of the loading one during the preparation step.
  78233. */
  78234. isBlocking: boolean;
  78235. /**
  78236. * Get the current sampling mode associated with the texture.
  78237. */
  78238. readonly samplingMode: number;
  78239. /**
  78240. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  78241. */
  78242. readonly invertY: boolean;
  78243. /**
  78244. * Instantiates a new texture.
  78245. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78246. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78247. * @param url define the url of the picture to load as a texture
  78248. * @param scene define the scene the texture will belong to
  78249. * @param noMipmap define if the texture will require mip maps or not
  78250. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78251. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78252. * @param onLoad define a callback triggered when the texture has been loaded
  78253. * @param onError define a callback triggered when an error occurred during the loading session
  78254. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78255. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78256. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78257. */
  78258. constructor(url: Nullable<string>, scene: Nullable<Scene>, 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);
  78259. /**
  78260. * Update the url (and optional buffer) of this texture if url was null during construction.
  78261. * @param url the url of the texture
  78262. * @param buffer the buffer of the texture (defaults to null)
  78263. * @param onLoad callback called when the texture is loaded (defaults to null)
  78264. */
  78265. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  78266. /**
  78267. * Finish the loading sequence of a texture flagged as delayed load.
  78268. * @hidden
  78269. */
  78270. delayLoad(): void;
  78271. private _prepareRowForTextureGeneration;
  78272. /**
  78273. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  78274. * @returns the transform matrix of the texture.
  78275. */
  78276. getTextureMatrix(): Matrix;
  78277. /**
  78278. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  78279. * @returns The reflection texture transform
  78280. */
  78281. getReflectionTextureMatrix(): Matrix;
  78282. /**
  78283. * Clones the texture.
  78284. * @returns the cloned texture
  78285. */
  78286. clone(): Texture;
  78287. /**
  78288. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78289. * @returns The JSON representation of the texture
  78290. */
  78291. serialize(): any;
  78292. /**
  78293. * Get the current class name of the texture useful for serialization or dynamic coding.
  78294. * @returns "Texture"
  78295. */
  78296. getClassName(): string;
  78297. /**
  78298. * Dispose the texture and release its associated resources.
  78299. */
  78300. dispose(): void;
  78301. /**
  78302. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78303. * @param parsedTexture Define the JSON representation of the texture
  78304. * @param scene Define the scene the parsed texture should be instantiated in
  78305. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78306. * @returns The parsed texture if successful
  78307. */
  78308. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78309. /**
  78310. * Creates a texture from its base 64 representation.
  78311. * @param data Define the base64 payload without the data: prefix
  78312. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78313. * @param scene Define the scene the texture should belong to
  78314. * @param noMipmap Forces the texture to not create mip map information if true
  78315. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78316. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78317. * @param onLoad define a callback triggered when the texture has been loaded
  78318. * @param onError define a callback triggered when an error occurred during the loading session
  78319. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78320. * @returns the created texture
  78321. */
  78322. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78323. /**
  78324. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78325. * @param data Define the base64 payload without the data: prefix
  78326. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78327. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78328. * @param scene Define the scene the texture should belong to
  78329. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78330. * @param noMipmap Forces the texture to not create mip map information if true
  78331. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78332. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78333. * @param onLoad define a callback triggered when the texture has been loaded
  78334. * @param onError define a callback triggered when an error occurred during the loading session
  78335. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78336. * @returns the created texture
  78337. */
  78338. 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;
  78339. }
  78340. }
  78341. declare module BABYLON {
  78342. interface Engine {
  78343. /**
  78344. * Creates a raw texture
  78345. * @param data defines the data to store in the texture
  78346. * @param width defines the width of the texture
  78347. * @param height defines the height of the texture
  78348. * @param format defines the format of the data
  78349. * @param generateMipMaps defines if the engine should generate the mip levels
  78350. * @param invertY defines if data must be stored with Y axis inverted
  78351. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78352. * @param compression defines the compression used (null by default)
  78353. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78354. * @returns the raw texture inside an InternalTexture
  78355. */
  78356. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78357. /**
  78358. * Update a raw texture
  78359. * @param texture defines the texture to update
  78360. * @param data defines the data to store in the texture
  78361. * @param format defines the format of the data
  78362. * @param invertY defines if data must be stored with Y axis inverted
  78363. */
  78364. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78365. /**
  78366. * Update a raw texture
  78367. * @param texture defines the texture to update
  78368. * @param data defines the data to store in the texture
  78369. * @param format defines the format of the data
  78370. * @param invertY defines if data must be stored with Y axis inverted
  78371. * @param compression defines the compression used (null by default)
  78372. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78373. */
  78374. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78375. /**
  78376. * Creates a new raw cube texture
  78377. * @param data defines the array of data to use to create each face
  78378. * @param size defines the size of the textures
  78379. * @param format defines the format of the data
  78380. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78381. * @param generateMipMaps defines if the engine should generate the mip levels
  78382. * @param invertY defines if data must be stored with Y axis inverted
  78383. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78384. * @param compression defines the compression used (null by default)
  78385. * @returns the cube texture as an InternalTexture
  78386. */
  78387. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78388. /**
  78389. * Update a raw cube texture
  78390. * @param texture defines the texture to udpdate
  78391. * @param data defines the data to store
  78392. * @param format defines the data format
  78393. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78394. * @param invertY defines if data must be stored with Y axis inverted
  78395. */
  78396. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78397. /**
  78398. * Update a raw cube texture
  78399. * @param texture defines the texture to udpdate
  78400. * @param data defines the data to store
  78401. * @param format defines the data format
  78402. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78403. * @param invertY defines if data must be stored with Y axis inverted
  78404. * @param compression defines the compression used (null by default)
  78405. */
  78406. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78407. /**
  78408. * Update a raw cube texture
  78409. * @param texture defines the texture to udpdate
  78410. * @param data defines the data to store
  78411. * @param format defines the data format
  78412. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78413. * @param invertY defines if data must be stored with Y axis inverted
  78414. * @param compression defines the compression used (null by default)
  78415. * @param level defines which level of the texture to update
  78416. */
  78417. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78418. /**
  78419. * Creates a new raw cube texture from a specified url
  78420. * @param url defines the url where the data is located
  78421. * @param scene defines the current scene
  78422. * @param size defines the size of the textures
  78423. * @param format defines the format of the data
  78424. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78425. * @param noMipmap defines if the engine should avoid generating the mip levels
  78426. * @param callback defines a callback used to extract texture data from loaded data
  78427. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78428. * @param onLoad defines a callback called when texture is loaded
  78429. * @param onError defines a callback called if there is an error
  78430. * @returns the cube texture as an InternalTexture
  78431. */
  78432. 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;
  78433. /**
  78434. * Creates a new raw cube texture from a specified url
  78435. * @param url defines the url where the data is located
  78436. * @param scene defines the current scene
  78437. * @param size defines the size of the textures
  78438. * @param format defines the format of the data
  78439. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78440. * @param noMipmap defines if the engine should avoid generating the mip levels
  78441. * @param callback defines a callback used to extract texture data from loaded data
  78442. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78443. * @param onLoad defines a callback called when texture is loaded
  78444. * @param onError defines a callback called if there is an error
  78445. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78446. * @param invertY defines if data must be stored with Y axis inverted
  78447. * @returns the cube texture as an InternalTexture
  78448. */
  78449. 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;
  78450. /**
  78451. * Creates a new raw 3D texture
  78452. * @param data defines the data used to create the texture
  78453. * @param width defines the width of the texture
  78454. * @param height defines the height of the texture
  78455. * @param depth defines the depth of the texture
  78456. * @param format defines the format of the texture
  78457. * @param generateMipMaps defines if the engine must generate mip levels
  78458. * @param invertY defines if data must be stored with Y axis inverted
  78459. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78460. * @param compression defines the compressed used (can be null)
  78461. * @param textureType defines the compressed used (can be null)
  78462. * @returns a new raw 3D texture (stored in an InternalTexture)
  78463. */
  78464. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78465. /**
  78466. * Update a raw 3D texture
  78467. * @param texture defines the texture to update
  78468. * @param data defines the data to store
  78469. * @param format defines the data format
  78470. * @param invertY defines if data must be stored with Y axis inverted
  78471. */
  78472. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78473. /**
  78474. * Update a raw 3D texture
  78475. * @param texture defines the texture to update
  78476. * @param data defines the data to store
  78477. * @param format defines the data format
  78478. * @param invertY defines if data must be stored with Y axis inverted
  78479. * @param compression defines the used compression (can be null)
  78480. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78481. */
  78482. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78483. }
  78484. }
  78485. declare module BABYLON {
  78486. /**
  78487. * Raw texture can help creating a texture directly from an array of data.
  78488. * This can be super useful if you either get the data from an uncompressed source or
  78489. * if you wish to create your texture pixel by pixel.
  78490. */
  78491. export class RawTexture extends Texture {
  78492. /**
  78493. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78494. */
  78495. format: number;
  78496. private _engine;
  78497. /**
  78498. * Instantiates a new RawTexture.
  78499. * Raw texture can help creating a texture directly from an array of data.
  78500. * This can be super useful if you either get the data from an uncompressed source or
  78501. * if you wish to create your texture pixel by pixel.
  78502. * @param data define the array of data to use to create the texture
  78503. * @param width define the width of the texture
  78504. * @param height define the height of the texture
  78505. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78506. * @param scene define the scene the texture belongs to
  78507. * @param generateMipMaps define whether mip maps should be generated or not
  78508. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78509. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78510. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78511. */
  78512. constructor(data: ArrayBufferView, width: number, height: number,
  78513. /**
  78514. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78515. */
  78516. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78517. /**
  78518. * Updates the texture underlying data.
  78519. * @param data Define the new data of the texture
  78520. */
  78521. update(data: ArrayBufferView): void;
  78522. /**
  78523. * Creates a luminance texture from some data.
  78524. * @param data Define the texture data
  78525. * @param width Define the width of the texture
  78526. * @param height Define the height of the texture
  78527. * @param scene Define the scene the texture belongs to
  78528. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78529. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78530. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78531. * @returns the luminance texture
  78532. */
  78533. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78534. /**
  78535. * Creates a luminance alpha texture from some data.
  78536. * @param data Define the texture data
  78537. * @param width Define the width of the texture
  78538. * @param height Define the height of the texture
  78539. * @param scene Define the scene the texture belongs to
  78540. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78541. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78542. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78543. * @returns the luminance alpha texture
  78544. */
  78545. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78546. /**
  78547. * Creates an alpha texture from some data.
  78548. * @param data Define the texture data
  78549. * @param width Define the width of the texture
  78550. * @param height Define the height of the texture
  78551. * @param scene Define the scene the texture belongs to
  78552. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78553. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78554. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78555. * @returns the alpha texture
  78556. */
  78557. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78558. /**
  78559. * Creates a RGB texture from some data.
  78560. * @param data Define the texture data
  78561. * @param width Define the width of the texture
  78562. * @param height Define the height of the texture
  78563. * @param scene Define the scene the texture belongs to
  78564. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78565. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78566. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78567. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78568. * @returns the RGB alpha texture
  78569. */
  78570. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78571. /**
  78572. * Creates a RGBA texture from some data.
  78573. * @param data Define the texture data
  78574. * @param width Define the width of the texture
  78575. * @param height Define the height of the texture
  78576. * @param scene Define the scene the texture belongs to
  78577. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78578. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78579. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78580. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78581. * @returns the RGBA texture
  78582. */
  78583. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78584. /**
  78585. * Creates a R texture from some data.
  78586. * @param data Define the texture data
  78587. * @param width Define the width of the texture
  78588. * @param height Define the height of the texture
  78589. * @param scene Define the scene the texture belongs to
  78590. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78591. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78592. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78593. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78594. * @returns the R texture
  78595. */
  78596. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78597. }
  78598. }
  78599. declare module BABYLON {
  78600. /**
  78601. * Defines a runtime animation
  78602. */
  78603. export class RuntimeAnimation {
  78604. private _events;
  78605. /**
  78606. * The current frame of the runtime animation
  78607. */
  78608. private _currentFrame;
  78609. /**
  78610. * The animation used by the runtime animation
  78611. */
  78612. private _animation;
  78613. /**
  78614. * The target of the runtime animation
  78615. */
  78616. private _target;
  78617. /**
  78618. * The initiating animatable
  78619. */
  78620. private _host;
  78621. /**
  78622. * The original value of the runtime animation
  78623. */
  78624. private _originalValue;
  78625. /**
  78626. * The original blend value of the runtime animation
  78627. */
  78628. private _originalBlendValue;
  78629. /**
  78630. * The offsets cache of the runtime animation
  78631. */
  78632. private _offsetsCache;
  78633. /**
  78634. * The high limits cache of the runtime animation
  78635. */
  78636. private _highLimitsCache;
  78637. /**
  78638. * Specifies if the runtime animation has been stopped
  78639. */
  78640. private _stopped;
  78641. /**
  78642. * The blending factor of the runtime animation
  78643. */
  78644. private _blendingFactor;
  78645. /**
  78646. * The BabylonJS scene
  78647. */
  78648. private _scene;
  78649. /**
  78650. * The current value of the runtime animation
  78651. */
  78652. private _currentValue;
  78653. /** @hidden */
  78654. _animationState: _IAnimationState;
  78655. /**
  78656. * The active target of the runtime animation
  78657. */
  78658. private _activeTargets;
  78659. private _currentActiveTarget;
  78660. private _directTarget;
  78661. /**
  78662. * The target path of the runtime animation
  78663. */
  78664. private _targetPath;
  78665. /**
  78666. * The weight of the runtime animation
  78667. */
  78668. private _weight;
  78669. /**
  78670. * The ratio offset of the runtime animation
  78671. */
  78672. private _ratioOffset;
  78673. /**
  78674. * The previous delay of the runtime animation
  78675. */
  78676. private _previousDelay;
  78677. /**
  78678. * The previous ratio of the runtime animation
  78679. */
  78680. private _previousRatio;
  78681. private _enableBlending;
  78682. private _keys;
  78683. private _minFrame;
  78684. private _maxFrame;
  78685. private _minValue;
  78686. private _maxValue;
  78687. private _targetIsArray;
  78688. /**
  78689. * Gets the current frame of the runtime animation
  78690. */
  78691. readonly currentFrame: number;
  78692. /**
  78693. * Gets the weight of the runtime animation
  78694. */
  78695. readonly weight: number;
  78696. /**
  78697. * Gets the current value of the runtime animation
  78698. */
  78699. readonly currentValue: any;
  78700. /**
  78701. * Gets the target path of the runtime animation
  78702. */
  78703. readonly targetPath: string;
  78704. /**
  78705. * Gets the actual target of the runtime animation
  78706. */
  78707. readonly target: any;
  78708. /** @hidden */
  78709. _onLoop: () => void;
  78710. /**
  78711. * Create a new RuntimeAnimation object
  78712. * @param target defines the target of the animation
  78713. * @param animation defines the source animation object
  78714. * @param scene defines the hosting scene
  78715. * @param host defines the initiating Animatable
  78716. */
  78717. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78718. private _preparePath;
  78719. /**
  78720. * Gets the animation from the runtime animation
  78721. */
  78722. readonly animation: Animation;
  78723. /**
  78724. * Resets the runtime animation to the beginning
  78725. * @param restoreOriginal defines whether to restore the target property to the original value
  78726. */
  78727. reset(restoreOriginal?: boolean): void;
  78728. /**
  78729. * Specifies if the runtime animation is stopped
  78730. * @returns Boolean specifying if the runtime animation is stopped
  78731. */
  78732. isStopped(): boolean;
  78733. /**
  78734. * Disposes of the runtime animation
  78735. */
  78736. dispose(): void;
  78737. /**
  78738. * Apply the interpolated value to the target
  78739. * @param currentValue defines the value computed by the animation
  78740. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78741. */
  78742. setValue(currentValue: any, weight: number): void;
  78743. private _getOriginalValues;
  78744. private _setValue;
  78745. /**
  78746. * Gets the loop pmode of the runtime animation
  78747. * @returns Loop Mode
  78748. */
  78749. private _getCorrectLoopMode;
  78750. /**
  78751. * Move the current animation to a given frame
  78752. * @param frame defines the frame to move to
  78753. */
  78754. goToFrame(frame: number): void;
  78755. /**
  78756. * @hidden Internal use only
  78757. */
  78758. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78759. /**
  78760. * Execute the current animation
  78761. * @param delay defines the delay to add to the current frame
  78762. * @param from defines the lower bound of the animation range
  78763. * @param to defines the upper bound of the animation range
  78764. * @param loop defines if the current animation must loop
  78765. * @param speedRatio defines the current speed ratio
  78766. * @param weight defines the weight of the animation (default is -1 so no weight)
  78767. * @param onLoop optional callback called when animation loops
  78768. * @returns a boolean indicating if the animation is running
  78769. */
  78770. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78771. }
  78772. }
  78773. declare module BABYLON {
  78774. /**
  78775. * Class used to store an actual running animation
  78776. */
  78777. export class Animatable {
  78778. /** defines the target object */
  78779. target: any;
  78780. /** defines the starting frame number (default is 0) */
  78781. fromFrame: number;
  78782. /** defines the ending frame number (default is 100) */
  78783. toFrame: number;
  78784. /** defines if the animation must loop (default is false) */
  78785. loopAnimation: boolean;
  78786. /** defines a callback to call when animation ends if it is not looping */
  78787. onAnimationEnd?: (() => void) | null | undefined;
  78788. /** defines a callback to call when animation loops */
  78789. onAnimationLoop?: (() => void) | null | undefined;
  78790. private _localDelayOffset;
  78791. private _pausedDelay;
  78792. private _runtimeAnimations;
  78793. private _paused;
  78794. private _scene;
  78795. private _speedRatio;
  78796. private _weight;
  78797. private _syncRoot;
  78798. /**
  78799. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78800. * This will only apply for non looping animation (default is true)
  78801. */
  78802. disposeOnEnd: boolean;
  78803. /**
  78804. * Gets a boolean indicating if the animation has started
  78805. */
  78806. animationStarted: boolean;
  78807. /**
  78808. * Observer raised when the animation ends
  78809. */
  78810. onAnimationEndObservable: Observable<Animatable>;
  78811. /**
  78812. * Observer raised when the animation loops
  78813. */
  78814. onAnimationLoopObservable: Observable<Animatable>;
  78815. /**
  78816. * Gets the root Animatable used to synchronize and normalize animations
  78817. */
  78818. readonly syncRoot: Nullable<Animatable>;
  78819. /**
  78820. * Gets the current frame of the first RuntimeAnimation
  78821. * Used to synchronize Animatables
  78822. */
  78823. readonly masterFrame: number;
  78824. /**
  78825. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78826. */
  78827. weight: number;
  78828. /**
  78829. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78830. */
  78831. speedRatio: number;
  78832. /**
  78833. * Creates a new Animatable
  78834. * @param scene defines the hosting scene
  78835. * @param target defines the target object
  78836. * @param fromFrame defines the starting frame number (default is 0)
  78837. * @param toFrame defines the ending frame number (default is 100)
  78838. * @param loopAnimation defines if the animation must loop (default is false)
  78839. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78840. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78841. * @param animations defines a group of animation to add to the new Animatable
  78842. * @param onAnimationLoop defines a callback to call when animation loops
  78843. */
  78844. constructor(scene: Scene,
  78845. /** defines the target object */
  78846. target: any,
  78847. /** defines the starting frame number (default is 0) */
  78848. fromFrame?: number,
  78849. /** defines the ending frame number (default is 100) */
  78850. toFrame?: number,
  78851. /** defines if the animation must loop (default is false) */
  78852. loopAnimation?: boolean, speedRatio?: number,
  78853. /** defines a callback to call when animation ends if it is not looping */
  78854. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78855. /** defines a callback to call when animation loops */
  78856. onAnimationLoop?: (() => void) | null | undefined);
  78857. /**
  78858. * Synchronize and normalize current Animatable with a source Animatable
  78859. * This is useful when using animation weights and when animations are not of the same length
  78860. * @param root defines the root Animatable to synchronize with
  78861. * @returns the current Animatable
  78862. */
  78863. syncWith(root: Animatable): Animatable;
  78864. /**
  78865. * Gets the list of runtime animations
  78866. * @returns an array of RuntimeAnimation
  78867. */
  78868. getAnimations(): RuntimeAnimation[];
  78869. /**
  78870. * Adds more animations to the current animatable
  78871. * @param target defines the target of the animations
  78872. * @param animations defines the new animations to add
  78873. */
  78874. appendAnimations(target: any, animations: Animation[]): void;
  78875. /**
  78876. * Gets the source animation for a specific property
  78877. * @param property defines the propertyu to look for
  78878. * @returns null or the source animation for the given property
  78879. */
  78880. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78881. /**
  78882. * Gets the runtime animation for a specific property
  78883. * @param property defines the propertyu to look for
  78884. * @returns null or the runtime animation for the given property
  78885. */
  78886. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78887. /**
  78888. * Resets the animatable to its original state
  78889. */
  78890. reset(): void;
  78891. /**
  78892. * Allows the animatable to blend with current running animations
  78893. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78894. * @param blendingSpeed defines the blending speed to use
  78895. */
  78896. enableBlending(blendingSpeed: number): void;
  78897. /**
  78898. * Disable animation blending
  78899. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78900. */
  78901. disableBlending(): void;
  78902. /**
  78903. * Jump directly to a given frame
  78904. * @param frame defines the frame to jump to
  78905. */
  78906. goToFrame(frame: number): void;
  78907. /**
  78908. * Pause the animation
  78909. */
  78910. pause(): void;
  78911. /**
  78912. * Restart the animation
  78913. */
  78914. restart(): void;
  78915. private _raiseOnAnimationEnd;
  78916. /**
  78917. * Stop and delete the current animation
  78918. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78919. * @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)
  78920. */
  78921. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78922. /**
  78923. * Wait asynchronously for the animation to end
  78924. * @returns a promise which will be fullfilled when the animation ends
  78925. */
  78926. waitAsync(): Promise<Animatable>;
  78927. /** @hidden */
  78928. _animate(delay: number): boolean;
  78929. }
  78930. interface Scene {
  78931. /** @hidden */
  78932. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78933. /** @hidden */
  78934. _processLateAnimationBindingsForMatrices(holder: {
  78935. totalWeight: number;
  78936. animations: RuntimeAnimation[];
  78937. originalValue: Matrix;
  78938. }): any;
  78939. /** @hidden */
  78940. _processLateAnimationBindingsForQuaternions(holder: {
  78941. totalWeight: number;
  78942. animations: RuntimeAnimation[];
  78943. originalValue: Quaternion;
  78944. }, refQuaternion: Quaternion): Quaternion;
  78945. /** @hidden */
  78946. _processLateAnimationBindings(): void;
  78947. /**
  78948. * Will start the animation sequence of a given target
  78949. * @param target defines the target
  78950. * @param from defines from which frame should animation start
  78951. * @param to defines until which frame should animation run.
  78952. * @param weight defines the weight to apply to the animation (1.0 by default)
  78953. * @param loop defines if the animation loops
  78954. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78955. * @param onAnimationEnd defines the function to be executed when the animation ends
  78956. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78957. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78958. * @param onAnimationLoop defines the callback to call when an animation loops
  78959. * @returns the animatable object created for this animation
  78960. */
  78961. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78962. /**
  78963. * Will start the animation sequence of a given target
  78964. * @param target defines the target
  78965. * @param from defines from which frame should animation start
  78966. * @param to defines until which frame should animation run.
  78967. * @param loop defines if the animation loops
  78968. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78969. * @param onAnimationEnd defines the function to be executed when the animation ends
  78970. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78971. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78972. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78973. * @param onAnimationLoop defines the callback to call when an animation loops
  78974. * @returns the animatable object created for this animation
  78975. */
  78976. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78977. /**
  78978. * Will start the animation sequence of a given target and its hierarchy
  78979. * @param target defines the target
  78980. * @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.
  78981. * @param from defines from which frame should animation start
  78982. * @param to defines until which frame should animation run.
  78983. * @param loop defines if the animation loops
  78984. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78985. * @param onAnimationEnd defines the function to be executed when the animation ends
  78986. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78987. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78988. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78989. * @param onAnimationLoop defines the callback to call when an animation loops
  78990. * @returns the list of created animatables
  78991. */
  78992. 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[];
  78993. /**
  78994. * Begin a new animation on a given node
  78995. * @param target defines the target where the animation will take place
  78996. * @param animations defines the list of animations to start
  78997. * @param from defines the initial value
  78998. * @param to defines the final value
  78999. * @param loop defines if you want animation to loop (off by default)
  79000. * @param speedRatio defines the speed ratio to apply to all animations
  79001. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79002. * @param onAnimationLoop defines the callback to call when an animation loops
  79003. * @returns the list of created animatables
  79004. */
  79005. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79006. /**
  79007. * Begin a new animation on a given node and its hierarchy
  79008. * @param target defines the root node where the animation will take place
  79009. * @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.
  79010. * @param animations defines the list of animations to start
  79011. * @param from defines the initial value
  79012. * @param to defines the final value
  79013. * @param loop defines if you want animation to loop (off by default)
  79014. * @param speedRatio defines the speed ratio to apply to all animations
  79015. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79016. * @param onAnimationLoop defines the callback to call when an animation loops
  79017. * @returns the list of animatables created for all nodes
  79018. */
  79019. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79020. /**
  79021. * Gets the animatable associated with a specific target
  79022. * @param target defines the target of the animatable
  79023. * @returns the required animatable if found
  79024. */
  79025. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79026. /**
  79027. * Gets all animatables associated with a given target
  79028. * @param target defines the target to look animatables for
  79029. * @returns an array of Animatables
  79030. */
  79031. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79032. /**
  79033. * Stops and removes all animations that have been applied to the scene
  79034. */
  79035. stopAllAnimations(): void;
  79036. }
  79037. interface Bone {
  79038. /**
  79039. * Copy an animation range from another bone
  79040. * @param source defines the source bone
  79041. * @param rangeName defines the range name to copy
  79042. * @param frameOffset defines the frame offset
  79043. * @param rescaleAsRequired defines if rescaling must be applied if required
  79044. * @param skelDimensionsRatio defines the scaling ratio
  79045. * @returns true if operation was successful
  79046. */
  79047. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79048. }
  79049. }
  79050. declare module BABYLON {
  79051. /**
  79052. * Class used to handle skinning animations
  79053. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79054. */
  79055. export class Skeleton implements IAnimatable {
  79056. /** defines the skeleton name */
  79057. name: string;
  79058. /** defines the skeleton Id */
  79059. id: string;
  79060. /**
  79061. * Defines the list of child bones
  79062. */
  79063. bones: Bone[];
  79064. /**
  79065. * Defines an estimate of the dimension of the skeleton at rest
  79066. */
  79067. dimensionsAtRest: Vector3;
  79068. /**
  79069. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79070. */
  79071. needInitialSkinMatrix: boolean;
  79072. /**
  79073. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79074. */
  79075. overrideMesh: Nullable<AbstractMesh>;
  79076. /**
  79077. * Gets the list of animations attached to this skeleton
  79078. */
  79079. animations: Array<Animation>;
  79080. private _scene;
  79081. private _isDirty;
  79082. private _transformMatrices;
  79083. private _transformMatrixTexture;
  79084. private _meshesWithPoseMatrix;
  79085. private _animatables;
  79086. private _identity;
  79087. private _synchronizedWithMesh;
  79088. private _ranges;
  79089. private _lastAbsoluteTransformsUpdateId;
  79090. private _canUseTextureForBones;
  79091. private _uniqueId;
  79092. /** @hidden */
  79093. _numBonesWithLinkedTransformNode: number;
  79094. /**
  79095. * Specifies if the skeleton should be serialized
  79096. */
  79097. doNotSerialize: boolean;
  79098. private _useTextureToStoreBoneMatrices;
  79099. /**
  79100. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79101. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79102. */
  79103. useTextureToStoreBoneMatrices: boolean;
  79104. private _animationPropertiesOverride;
  79105. /**
  79106. * Gets or sets the animation properties override
  79107. */
  79108. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79109. /**
  79110. * List of inspectable custom properties (used by the Inspector)
  79111. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79112. */
  79113. inspectableCustomProperties: IInspectable[];
  79114. /**
  79115. * An observable triggered before computing the skeleton's matrices
  79116. */
  79117. onBeforeComputeObservable: Observable<Skeleton>;
  79118. /**
  79119. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79120. */
  79121. readonly isUsingTextureForMatrices: boolean;
  79122. /**
  79123. * Gets the unique ID of this skeleton
  79124. */
  79125. readonly uniqueId: number;
  79126. /**
  79127. * Creates a new skeleton
  79128. * @param name defines the skeleton name
  79129. * @param id defines the skeleton Id
  79130. * @param scene defines the hosting scene
  79131. */
  79132. constructor(
  79133. /** defines the skeleton name */
  79134. name: string,
  79135. /** defines the skeleton Id */
  79136. id: string, scene: Scene);
  79137. /**
  79138. * Gets the current object class name.
  79139. * @return the class name
  79140. */
  79141. getClassName(): string;
  79142. /**
  79143. * Returns an array containing the root bones
  79144. * @returns an array containing the root bones
  79145. */
  79146. getChildren(): Array<Bone>;
  79147. /**
  79148. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79149. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79150. * @returns a Float32Array containing matrices data
  79151. */
  79152. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79153. /**
  79154. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79155. * @returns a raw texture containing the data
  79156. */
  79157. getTransformMatrixTexture(): Nullable<RawTexture>;
  79158. /**
  79159. * Gets the current hosting scene
  79160. * @returns a scene object
  79161. */
  79162. getScene(): Scene;
  79163. /**
  79164. * Gets a string representing the current skeleton data
  79165. * @param fullDetails defines a boolean indicating if we want a verbose version
  79166. * @returns a string representing the current skeleton data
  79167. */
  79168. toString(fullDetails?: boolean): string;
  79169. /**
  79170. * Get bone's index searching by name
  79171. * @param name defines bone's name to search for
  79172. * @return the indice of the bone. Returns -1 if not found
  79173. */
  79174. getBoneIndexByName(name: string): number;
  79175. /**
  79176. * Creater a new animation range
  79177. * @param name defines the name of the range
  79178. * @param from defines the start key
  79179. * @param to defines the end key
  79180. */
  79181. createAnimationRange(name: string, from: number, to: number): void;
  79182. /**
  79183. * Delete a specific animation range
  79184. * @param name defines the name of the range
  79185. * @param deleteFrames defines if frames must be removed as well
  79186. */
  79187. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79188. /**
  79189. * Gets a specific animation range
  79190. * @param name defines the name of the range to look for
  79191. * @returns the requested animation range or null if not found
  79192. */
  79193. getAnimationRange(name: string): Nullable<AnimationRange>;
  79194. /**
  79195. * Gets the list of all animation ranges defined on this skeleton
  79196. * @returns an array
  79197. */
  79198. getAnimationRanges(): Nullable<AnimationRange>[];
  79199. /**
  79200. * Copy animation range from a source skeleton.
  79201. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79202. * @param source defines the source skeleton
  79203. * @param name defines the name of the range to copy
  79204. * @param rescaleAsRequired defines if rescaling must be applied if required
  79205. * @returns true if operation was successful
  79206. */
  79207. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79208. /**
  79209. * Forces the skeleton to go to rest pose
  79210. */
  79211. returnToRest(): void;
  79212. private _getHighestAnimationFrame;
  79213. /**
  79214. * Begin a specific animation range
  79215. * @param name defines the name of the range to start
  79216. * @param loop defines if looping must be turned on (false by default)
  79217. * @param speedRatio defines the speed ratio to apply (1 by default)
  79218. * @param onAnimationEnd defines a callback which will be called when animation will end
  79219. * @returns a new animatable
  79220. */
  79221. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79222. /** @hidden */
  79223. _markAsDirty(): void;
  79224. /** @hidden */
  79225. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79226. /** @hidden */
  79227. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79228. private _computeTransformMatrices;
  79229. /**
  79230. * Build all resources required to render a skeleton
  79231. */
  79232. prepare(): void;
  79233. /**
  79234. * Gets the list of animatables currently running for this skeleton
  79235. * @returns an array of animatables
  79236. */
  79237. getAnimatables(): IAnimatable[];
  79238. /**
  79239. * Clone the current skeleton
  79240. * @param name defines the name of the new skeleton
  79241. * @param id defines the id of the new skeleton
  79242. * @returns the new skeleton
  79243. */
  79244. clone(name: string, id: string): Skeleton;
  79245. /**
  79246. * Enable animation blending for this skeleton
  79247. * @param blendingSpeed defines the blending speed to apply
  79248. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79249. */
  79250. enableBlending(blendingSpeed?: number): void;
  79251. /**
  79252. * Releases all resources associated with the current skeleton
  79253. */
  79254. dispose(): void;
  79255. /**
  79256. * Serialize the skeleton in a JSON object
  79257. * @returns a JSON object
  79258. */
  79259. serialize(): any;
  79260. /**
  79261. * Creates a new skeleton from serialized data
  79262. * @param parsedSkeleton defines the serialized data
  79263. * @param scene defines the hosting scene
  79264. * @returns a new skeleton
  79265. */
  79266. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79267. /**
  79268. * Compute all node absolute transforms
  79269. * @param forceUpdate defines if computation must be done even if cache is up to date
  79270. */
  79271. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79272. /**
  79273. * Gets the root pose matrix
  79274. * @returns a matrix
  79275. */
  79276. getPoseMatrix(): Nullable<Matrix>;
  79277. /**
  79278. * Sorts bones per internal index
  79279. */
  79280. sortBones(): void;
  79281. private _sortBones;
  79282. }
  79283. }
  79284. declare module BABYLON {
  79285. /**
  79286. * Defines a target to use with MorphTargetManager
  79287. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79288. */
  79289. export class MorphTarget implements IAnimatable {
  79290. /** defines the name of the target */
  79291. name: string;
  79292. /**
  79293. * Gets or sets the list of animations
  79294. */
  79295. animations: Animation[];
  79296. private _scene;
  79297. private _positions;
  79298. private _normals;
  79299. private _tangents;
  79300. private _influence;
  79301. /**
  79302. * Observable raised when the influence changes
  79303. */
  79304. onInfluenceChanged: Observable<boolean>;
  79305. /** @hidden */
  79306. _onDataLayoutChanged: Observable<void>;
  79307. /**
  79308. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  79309. */
  79310. influence: number;
  79311. /**
  79312. * Gets or sets the id of the morph Target
  79313. */
  79314. id: string;
  79315. private _animationPropertiesOverride;
  79316. /**
  79317. * Gets or sets the animation properties override
  79318. */
  79319. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79320. /**
  79321. * Creates a new MorphTarget
  79322. * @param name defines the name of the target
  79323. * @param influence defines the influence to use
  79324. * @param scene defines the scene the morphtarget belongs to
  79325. */
  79326. constructor(
  79327. /** defines the name of the target */
  79328. name: string, influence?: number, scene?: Nullable<Scene>);
  79329. /**
  79330. * Gets a boolean defining if the target contains position data
  79331. */
  79332. readonly hasPositions: boolean;
  79333. /**
  79334. * Gets a boolean defining if the target contains normal data
  79335. */
  79336. readonly hasNormals: boolean;
  79337. /**
  79338. * Gets a boolean defining if the target contains tangent data
  79339. */
  79340. readonly hasTangents: boolean;
  79341. /**
  79342. * Affects position data to this target
  79343. * @param data defines the position data to use
  79344. */
  79345. setPositions(data: Nullable<FloatArray>): void;
  79346. /**
  79347. * Gets the position data stored in this target
  79348. * @returns a FloatArray containing the position data (or null if not present)
  79349. */
  79350. getPositions(): Nullable<FloatArray>;
  79351. /**
  79352. * Affects normal data to this target
  79353. * @param data defines the normal data to use
  79354. */
  79355. setNormals(data: Nullable<FloatArray>): void;
  79356. /**
  79357. * Gets the normal data stored in this target
  79358. * @returns a FloatArray containing the normal data (or null if not present)
  79359. */
  79360. getNormals(): Nullable<FloatArray>;
  79361. /**
  79362. * Affects tangent data to this target
  79363. * @param data defines the tangent data to use
  79364. */
  79365. setTangents(data: Nullable<FloatArray>): void;
  79366. /**
  79367. * Gets the tangent data stored in this target
  79368. * @returns a FloatArray containing the tangent data (or null if not present)
  79369. */
  79370. getTangents(): Nullable<FloatArray>;
  79371. /**
  79372. * Serializes the current target into a Serialization object
  79373. * @returns the serialized object
  79374. */
  79375. serialize(): any;
  79376. /**
  79377. * Returns the string "MorphTarget"
  79378. * @returns "MorphTarget"
  79379. */
  79380. getClassName(): string;
  79381. /**
  79382. * Creates a new target from serialized data
  79383. * @param serializationObject defines the serialized data to use
  79384. * @returns a new MorphTarget
  79385. */
  79386. static Parse(serializationObject: any): MorphTarget;
  79387. /**
  79388. * Creates a MorphTarget from mesh data
  79389. * @param mesh defines the source mesh
  79390. * @param name defines the name to use for the new target
  79391. * @param influence defines the influence to attach to the target
  79392. * @returns a new MorphTarget
  79393. */
  79394. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  79395. }
  79396. }
  79397. declare module BABYLON {
  79398. /**
  79399. * This class is used to deform meshes using morphing between different targets
  79400. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79401. */
  79402. export class MorphTargetManager {
  79403. private _targets;
  79404. private _targetInfluenceChangedObservers;
  79405. private _targetDataLayoutChangedObservers;
  79406. private _activeTargets;
  79407. private _scene;
  79408. private _influences;
  79409. private _supportsNormals;
  79410. private _supportsTangents;
  79411. private _vertexCount;
  79412. private _uniqueId;
  79413. private _tempInfluences;
  79414. /**
  79415. * Creates a new MorphTargetManager
  79416. * @param scene defines the current scene
  79417. */
  79418. constructor(scene?: Nullable<Scene>);
  79419. /**
  79420. * Gets the unique ID of this manager
  79421. */
  79422. readonly uniqueId: number;
  79423. /**
  79424. * Gets the number of vertices handled by this manager
  79425. */
  79426. readonly vertexCount: number;
  79427. /**
  79428. * Gets a boolean indicating if this manager supports morphing of normals
  79429. */
  79430. readonly supportsNormals: boolean;
  79431. /**
  79432. * Gets a boolean indicating if this manager supports morphing of tangents
  79433. */
  79434. readonly supportsTangents: boolean;
  79435. /**
  79436. * Gets the number of targets stored in this manager
  79437. */
  79438. readonly numTargets: number;
  79439. /**
  79440. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79441. */
  79442. readonly numInfluencers: number;
  79443. /**
  79444. * Gets the list of influences (one per target)
  79445. */
  79446. readonly influences: Float32Array;
  79447. /**
  79448. * Gets the active target at specified index. An active target is a target with an influence > 0
  79449. * @param index defines the index to check
  79450. * @returns the requested target
  79451. */
  79452. getActiveTarget(index: number): MorphTarget;
  79453. /**
  79454. * Gets the target at specified index
  79455. * @param index defines the index to check
  79456. * @returns the requested target
  79457. */
  79458. getTarget(index: number): MorphTarget;
  79459. /**
  79460. * Add a new target to this manager
  79461. * @param target defines the target to add
  79462. */
  79463. addTarget(target: MorphTarget): void;
  79464. /**
  79465. * Removes a target from the manager
  79466. * @param target defines the target to remove
  79467. */
  79468. removeTarget(target: MorphTarget): void;
  79469. /**
  79470. * Serializes the current manager into a Serialization object
  79471. * @returns the serialized object
  79472. */
  79473. serialize(): any;
  79474. private _syncActiveTargets;
  79475. /**
  79476. * Syncrhonize the targets with all the meshes using this morph target manager
  79477. */
  79478. synchronize(): void;
  79479. /**
  79480. * Creates a new MorphTargetManager from serialized data
  79481. * @param serializationObject defines the serialized data
  79482. * @param scene defines the hosting scene
  79483. * @returns the new MorphTargetManager
  79484. */
  79485. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79486. }
  79487. }
  79488. declare module BABYLON {
  79489. /**
  79490. * Class used to represent a specific level of detail of a mesh
  79491. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79492. */
  79493. export class MeshLODLevel {
  79494. /** Defines the distance where this level should star being displayed */
  79495. distance: number;
  79496. /** Defines the mesh to use to render this level */
  79497. mesh: Nullable<Mesh>;
  79498. /**
  79499. * Creates a new LOD level
  79500. * @param distance defines the distance where this level should star being displayed
  79501. * @param mesh defines the mesh to use to render this level
  79502. */
  79503. constructor(
  79504. /** Defines the distance where this level should star being displayed */
  79505. distance: number,
  79506. /** Defines the mesh to use to render this level */
  79507. mesh: Nullable<Mesh>);
  79508. }
  79509. }
  79510. declare module BABYLON {
  79511. /**
  79512. * Mesh representing the gorund
  79513. */
  79514. export class GroundMesh extends Mesh {
  79515. /** If octree should be generated */
  79516. generateOctree: boolean;
  79517. private _heightQuads;
  79518. /** @hidden */
  79519. _subdivisionsX: number;
  79520. /** @hidden */
  79521. _subdivisionsY: number;
  79522. /** @hidden */
  79523. _width: number;
  79524. /** @hidden */
  79525. _height: number;
  79526. /** @hidden */
  79527. _minX: number;
  79528. /** @hidden */
  79529. _maxX: number;
  79530. /** @hidden */
  79531. _minZ: number;
  79532. /** @hidden */
  79533. _maxZ: number;
  79534. constructor(name: string, scene: Scene);
  79535. /**
  79536. * "GroundMesh"
  79537. * @returns "GroundMesh"
  79538. */
  79539. getClassName(): string;
  79540. /**
  79541. * The minimum of x and y subdivisions
  79542. */
  79543. readonly subdivisions: number;
  79544. /**
  79545. * X subdivisions
  79546. */
  79547. readonly subdivisionsX: number;
  79548. /**
  79549. * Y subdivisions
  79550. */
  79551. readonly subdivisionsY: number;
  79552. /**
  79553. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79554. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79555. * @param chunksCount the number of subdivisions for x and y
  79556. * @param octreeBlocksSize (Default: 32)
  79557. */
  79558. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79559. /**
  79560. * Returns a height (y) value in the Worl system :
  79561. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79562. * @param x x coordinate
  79563. * @param z z coordinate
  79564. * @returns the ground y position if (x, z) are outside the ground surface.
  79565. */
  79566. getHeightAtCoordinates(x: number, z: number): number;
  79567. /**
  79568. * Returns a normalized vector (Vector3) orthogonal to the ground
  79569. * at the ground coordinates (x, z) expressed in the World system.
  79570. * @param x x coordinate
  79571. * @param z z coordinate
  79572. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79573. */
  79574. getNormalAtCoordinates(x: number, z: number): Vector3;
  79575. /**
  79576. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79577. * at the ground coordinates (x, z) expressed in the World system.
  79578. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79579. * @param x x coordinate
  79580. * @param z z coordinate
  79581. * @param ref vector to store the result
  79582. * @returns the GroundMesh.
  79583. */
  79584. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79585. /**
  79586. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79587. * if the ground has been updated.
  79588. * This can be used in the render loop.
  79589. * @returns the GroundMesh.
  79590. */
  79591. updateCoordinateHeights(): GroundMesh;
  79592. private _getFacetAt;
  79593. private _initHeightQuads;
  79594. private _computeHeightQuads;
  79595. /**
  79596. * Serializes this ground mesh
  79597. * @param serializationObject object to write serialization to
  79598. */
  79599. serialize(serializationObject: any): void;
  79600. /**
  79601. * Parses a serialized ground mesh
  79602. * @param parsedMesh the serialized mesh
  79603. * @param scene the scene to create the ground mesh in
  79604. * @returns the created ground mesh
  79605. */
  79606. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79607. }
  79608. }
  79609. declare module BABYLON {
  79610. /**
  79611. * Interface for Physics-Joint data
  79612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79613. */
  79614. export interface PhysicsJointData {
  79615. /**
  79616. * The main pivot of the joint
  79617. */
  79618. mainPivot?: Vector3;
  79619. /**
  79620. * The connected pivot of the joint
  79621. */
  79622. connectedPivot?: Vector3;
  79623. /**
  79624. * The main axis of the joint
  79625. */
  79626. mainAxis?: Vector3;
  79627. /**
  79628. * The connected axis of the joint
  79629. */
  79630. connectedAxis?: Vector3;
  79631. /**
  79632. * The collision of the joint
  79633. */
  79634. collision?: boolean;
  79635. /**
  79636. * Native Oimo/Cannon/Energy data
  79637. */
  79638. nativeParams?: any;
  79639. }
  79640. /**
  79641. * This is a holder class for the physics joint created by the physics plugin
  79642. * It holds a set of functions to control the underlying joint
  79643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79644. */
  79645. export class PhysicsJoint {
  79646. /**
  79647. * The type of the physics joint
  79648. */
  79649. type: number;
  79650. /**
  79651. * The data for the physics joint
  79652. */
  79653. jointData: PhysicsJointData;
  79654. private _physicsJoint;
  79655. protected _physicsPlugin: IPhysicsEnginePlugin;
  79656. /**
  79657. * Initializes the physics joint
  79658. * @param type The type of the physics joint
  79659. * @param jointData The data for the physics joint
  79660. */
  79661. constructor(
  79662. /**
  79663. * The type of the physics joint
  79664. */
  79665. type: number,
  79666. /**
  79667. * The data for the physics joint
  79668. */
  79669. jointData: PhysicsJointData);
  79670. /**
  79671. * Gets the physics joint
  79672. */
  79673. /**
  79674. * Sets the physics joint
  79675. */
  79676. physicsJoint: any;
  79677. /**
  79678. * Sets the physics plugin
  79679. */
  79680. physicsPlugin: IPhysicsEnginePlugin;
  79681. /**
  79682. * Execute a function that is physics-plugin specific.
  79683. * @param {Function} func the function that will be executed.
  79684. * It accepts two parameters: the physics world and the physics joint
  79685. */
  79686. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79687. /**
  79688. * Distance-Joint type
  79689. */
  79690. static DistanceJoint: number;
  79691. /**
  79692. * Hinge-Joint type
  79693. */
  79694. static HingeJoint: number;
  79695. /**
  79696. * Ball-and-Socket joint type
  79697. */
  79698. static BallAndSocketJoint: number;
  79699. /**
  79700. * Wheel-Joint type
  79701. */
  79702. static WheelJoint: number;
  79703. /**
  79704. * Slider-Joint type
  79705. */
  79706. static SliderJoint: number;
  79707. /**
  79708. * Prismatic-Joint type
  79709. */
  79710. static PrismaticJoint: number;
  79711. /**
  79712. * Universal-Joint type
  79713. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79714. */
  79715. static UniversalJoint: number;
  79716. /**
  79717. * Hinge-Joint 2 type
  79718. */
  79719. static Hinge2Joint: number;
  79720. /**
  79721. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79722. */
  79723. static PointToPointJoint: number;
  79724. /**
  79725. * Spring-Joint type
  79726. */
  79727. static SpringJoint: number;
  79728. /**
  79729. * Lock-Joint type
  79730. */
  79731. static LockJoint: number;
  79732. }
  79733. /**
  79734. * A class representing a physics distance joint
  79735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79736. */
  79737. export class DistanceJoint extends PhysicsJoint {
  79738. /**
  79739. *
  79740. * @param jointData The data for the Distance-Joint
  79741. */
  79742. constructor(jointData: DistanceJointData);
  79743. /**
  79744. * Update the predefined distance.
  79745. * @param maxDistance The maximum preferred distance
  79746. * @param minDistance The minimum preferred distance
  79747. */
  79748. updateDistance(maxDistance: number, minDistance?: number): void;
  79749. }
  79750. /**
  79751. * Represents a Motor-Enabled Joint
  79752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79753. */
  79754. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79755. /**
  79756. * Initializes the Motor-Enabled Joint
  79757. * @param type The type of the joint
  79758. * @param jointData The physica joint data for the joint
  79759. */
  79760. constructor(type: number, jointData: PhysicsJointData);
  79761. /**
  79762. * Set the motor values.
  79763. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79764. * @param force the force to apply
  79765. * @param maxForce max force for this motor.
  79766. */
  79767. setMotor(force?: number, maxForce?: number): void;
  79768. /**
  79769. * Set the motor's limits.
  79770. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79771. * @param upperLimit The upper limit of the motor
  79772. * @param lowerLimit The lower limit of the motor
  79773. */
  79774. setLimit(upperLimit: number, lowerLimit?: number): void;
  79775. }
  79776. /**
  79777. * This class represents a single physics Hinge-Joint
  79778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79779. */
  79780. export class HingeJoint extends MotorEnabledJoint {
  79781. /**
  79782. * Initializes the Hinge-Joint
  79783. * @param jointData The joint data for the Hinge-Joint
  79784. */
  79785. constructor(jointData: PhysicsJointData);
  79786. /**
  79787. * Set the motor values.
  79788. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79789. * @param {number} force the force to apply
  79790. * @param {number} maxForce max force for this motor.
  79791. */
  79792. setMotor(force?: number, maxForce?: number): void;
  79793. /**
  79794. * Set the motor's limits.
  79795. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79796. * @param upperLimit The upper limit of the motor
  79797. * @param lowerLimit The lower limit of the motor
  79798. */
  79799. setLimit(upperLimit: number, lowerLimit?: number): void;
  79800. }
  79801. /**
  79802. * This class represents a dual hinge physics joint (same as wheel joint)
  79803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79804. */
  79805. export class Hinge2Joint extends MotorEnabledJoint {
  79806. /**
  79807. * Initializes the Hinge2-Joint
  79808. * @param jointData The joint data for the Hinge2-Joint
  79809. */
  79810. constructor(jointData: PhysicsJointData);
  79811. /**
  79812. * Set the motor values.
  79813. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79814. * @param {number} targetSpeed the speed the motor is to reach
  79815. * @param {number} maxForce max force for this motor.
  79816. * @param {motorIndex} the motor's index, 0 or 1.
  79817. */
  79818. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79819. /**
  79820. * Set the motor limits.
  79821. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79822. * @param {number} upperLimit the upper limit
  79823. * @param {number} lowerLimit lower limit
  79824. * @param {motorIndex} the motor's index, 0 or 1.
  79825. */
  79826. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79827. }
  79828. /**
  79829. * Interface for a motor enabled joint
  79830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79831. */
  79832. export interface IMotorEnabledJoint {
  79833. /**
  79834. * Physics joint
  79835. */
  79836. physicsJoint: any;
  79837. /**
  79838. * Sets the motor of the motor-enabled joint
  79839. * @param force The force of the motor
  79840. * @param maxForce The maximum force of the motor
  79841. * @param motorIndex The index of the motor
  79842. */
  79843. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79844. /**
  79845. * Sets the limit of the motor
  79846. * @param upperLimit The upper limit of the motor
  79847. * @param lowerLimit The lower limit of the motor
  79848. * @param motorIndex The index of the motor
  79849. */
  79850. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79851. }
  79852. /**
  79853. * Joint data for a Distance-Joint
  79854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79855. */
  79856. export interface DistanceJointData extends PhysicsJointData {
  79857. /**
  79858. * Max distance the 2 joint objects can be apart
  79859. */
  79860. maxDistance: number;
  79861. }
  79862. /**
  79863. * Joint data from a spring joint
  79864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79865. */
  79866. export interface SpringJointData extends PhysicsJointData {
  79867. /**
  79868. * Length of the spring
  79869. */
  79870. length: number;
  79871. /**
  79872. * Stiffness of the spring
  79873. */
  79874. stiffness: number;
  79875. /**
  79876. * Damping of the spring
  79877. */
  79878. damping: number;
  79879. /** this callback will be called when applying the force to the impostors. */
  79880. forceApplicationCallback: () => void;
  79881. }
  79882. }
  79883. declare module BABYLON {
  79884. /**
  79885. * Holds the data for the raycast result
  79886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79887. */
  79888. export class PhysicsRaycastResult {
  79889. private _hasHit;
  79890. private _hitDistance;
  79891. private _hitNormalWorld;
  79892. private _hitPointWorld;
  79893. private _rayFromWorld;
  79894. private _rayToWorld;
  79895. /**
  79896. * Gets if there was a hit
  79897. */
  79898. readonly hasHit: boolean;
  79899. /**
  79900. * Gets the distance from the hit
  79901. */
  79902. readonly hitDistance: number;
  79903. /**
  79904. * Gets the hit normal/direction in the world
  79905. */
  79906. readonly hitNormalWorld: Vector3;
  79907. /**
  79908. * Gets the hit point in the world
  79909. */
  79910. readonly hitPointWorld: Vector3;
  79911. /**
  79912. * Gets the ray "start point" of the ray in the world
  79913. */
  79914. readonly rayFromWorld: Vector3;
  79915. /**
  79916. * Gets the ray "end point" of the ray in the world
  79917. */
  79918. readonly rayToWorld: Vector3;
  79919. /**
  79920. * Sets the hit data (normal & point in world space)
  79921. * @param hitNormalWorld defines the normal in world space
  79922. * @param hitPointWorld defines the point in world space
  79923. */
  79924. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79925. /**
  79926. * Sets the distance from the start point to the hit point
  79927. * @param distance
  79928. */
  79929. setHitDistance(distance: number): void;
  79930. /**
  79931. * Calculates the distance manually
  79932. */
  79933. calculateHitDistance(): void;
  79934. /**
  79935. * Resets all the values to default
  79936. * @param from The from point on world space
  79937. * @param to The to point on world space
  79938. */
  79939. reset(from?: Vector3, to?: Vector3): void;
  79940. }
  79941. /**
  79942. * Interface for the size containing width and height
  79943. */
  79944. interface IXYZ {
  79945. /**
  79946. * X
  79947. */
  79948. x: number;
  79949. /**
  79950. * Y
  79951. */
  79952. y: number;
  79953. /**
  79954. * Z
  79955. */
  79956. z: number;
  79957. }
  79958. }
  79959. declare module BABYLON {
  79960. /**
  79961. * Interface used to describe a physics joint
  79962. */
  79963. export interface PhysicsImpostorJoint {
  79964. /** Defines the main impostor to which the joint is linked */
  79965. mainImpostor: PhysicsImpostor;
  79966. /** Defines the impostor that is connected to the main impostor using this joint */
  79967. connectedImpostor: PhysicsImpostor;
  79968. /** Defines the joint itself */
  79969. joint: PhysicsJoint;
  79970. }
  79971. /** @hidden */
  79972. export interface IPhysicsEnginePlugin {
  79973. world: any;
  79974. name: string;
  79975. setGravity(gravity: Vector3): void;
  79976. setTimeStep(timeStep: number): void;
  79977. getTimeStep(): number;
  79978. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79979. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79980. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79981. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79982. removePhysicsBody(impostor: PhysicsImpostor): void;
  79983. generateJoint(joint: PhysicsImpostorJoint): void;
  79984. removeJoint(joint: PhysicsImpostorJoint): void;
  79985. isSupported(): boolean;
  79986. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  79987. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  79988. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79989. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79990. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79991. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79992. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  79993. getBodyMass(impostor: PhysicsImpostor): number;
  79994. getBodyFriction(impostor: PhysicsImpostor): number;
  79995. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  79996. getBodyRestitution(impostor: PhysicsImpostor): number;
  79997. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  79998. getBodyPressure?(impostor: PhysicsImpostor): number;
  79999. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  80000. getBodyStiffness?(impostor: PhysicsImpostor): number;
  80001. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  80002. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  80003. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  80004. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  80005. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  80006. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80007. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80008. sleepBody(impostor: PhysicsImpostor): void;
  80009. wakeUpBody(impostor: PhysicsImpostor): void;
  80010. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80011. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  80012. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  80013. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  80014. getRadius(impostor: PhysicsImpostor): number;
  80015. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  80016. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  80017. dispose(): void;
  80018. }
  80019. /**
  80020. * Interface used to define a physics engine
  80021. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  80022. */
  80023. export interface IPhysicsEngine {
  80024. /**
  80025. * Gets the gravity vector used by the simulation
  80026. */
  80027. gravity: Vector3;
  80028. /**
  80029. * Sets the gravity vector used by the simulation
  80030. * @param gravity defines the gravity vector to use
  80031. */
  80032. setGravity(gravity: Vector3): void;
  80033. /**
  80034. * Set the time step of the physics engine.
  80035. * Default is 1/60.
  80036. * To slow it down, enter 1/600 for example.
  80037. * To speed it up, 1/30
  80038. * @param newTimeStep the new timestep to apply to this world.
  80039. */
  80040. setTimeStep(newTimeStep: number): void;
  80041. /**
  80042. * Get the time step of the physics engine.
  80043. * @returns the current time step
  80044. */
  80045. getTimeStep(): number;
  80046. /**
  80047. * Release all resources
  80048. */
  80049. dispose(): void;
  80050. /**
  80051. * Gets the name of the current physics plugin
  80052. * @returns the name of the plugin
  80053. */
  80054. getPhysicsPluginName(): string;
  80055. /**
  80056. * Adding a new impostor for the impostor tracking.
  80057. * This will be done by the impostor itself.
  80058. * @param impostor the impostor to add
  80059. */
  80060. addImpostor(impostor: PhysicsImpostor): void;
  80061. /**
  80062. * Remove an impostor from the engine.
  80063. * This impostor and its mesh will not longer be updated by the physics engine.
  80064. * @param impostor the impostor to remove
  80065. */
  80066. removeImpostor(impostor: PhysicsImpostor): void;
  80067. /**
  80068. * Add a joint to the physics engine
  80069. * @param mainImpostor defines the main impostor to which the joint is added.
  80070. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  80071. * @param joint defines the joint that will connect both impostors.
  80072. */
  80073. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80074. /**
  80075. * Removes a joint from the simulation
  80076. * @param mainImpostor defines the impostor used with the joint
  80077. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  80078. * @param joint defines the joint to remove
  80079. */
  80080. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80081. /**
  80082. * Gets the current plugin used to run the simulation
  80083. * @returns current plugin
  80084. */
  80085. getPhysicsPlugin(): IPhysicsEnginePlugin;
  80086. /**
  80087. * Gets the list of physic impostors
  80088. * @returns an array of PhysicsImpostor
  80089. */
  80090. getImpostors(): Array<PhysicsImpostor>;
  80091. /**
  80092. * Gets the impostor for a physics enabled object
  80093. * @param object defines the object impersonated by the impostor
  80094. * @returns the PhysicsImpostor or null if not found
  80095. */
  80096. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80097. /**
  80098. * Gets the impostor for a physics body object
  80099. * @param body defines physics body used by the impostor
  80100. * @returns the PhysicsImpostor or null if not found
  80101. */
  80102. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  80103. /**
  80104. * Does a raycast in the physics world
  80105. * @param from when should the ray start?
  80106. * @param to when should the ray end?
  80107. * @returns PhysicsRaycastResult
  80108. */
  80109. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80110. /**
  80111. * Called by the scene. No need to call it.
  80112. * @param delta defines the timespam between frames
  80113. */
  80114. _step(delta: number): void;
  80115. }
  80116. }
  80117. declare module BABYLON {
  80118. /**
  80119. * The interface for the physics imposter parameters
  80120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80121. */
  80122. export interface PhysicsImpostorParameters {
  80123. /**
  80124. * The mass of the physics imposter
  80125. */
  80126. mass: number;
  80127. /**
  80128. * The friction of the physics imposter
  80129. */
  80130. friction?: number;
  80131. /**
  80132. * The coefficient of restitution of the physics imposter
  80133. */
  80134. restitution?: number;
  80135. /**
  80136. * The native options of the physics imposter
  80137. */
  80138. nativeOptions?: any;
  80139. /**
  80140. * Specifies if the parent should be ignored
  80141. */
  80142. ignoreParent?: boolean;
  80143. /**
  80144. * Specifies if bi-directional transformations should be disabled
  80145. */
  80146. disableBidirectionalTransformation?: boolean;
  80147. /**
  80148. * The pressure inside the physics imposter, soft object only
  80149. */
  80150. pressure?: number;
  80151. /**
  80152. * The stiffness the physics imposter, soft object only
  80153. */
  80154. stiffness?: number;
  80155. /**
  80156. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  80157. */
  80158. velocityIterations?: number;
  80159. /**
  80160. * The number of iterations used in maintaining consistent vertex positions, soft object only
  80161. */
  80162. positionIterations?: number;
  80163. /**
  80164. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  80165. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  80166. * Add to fix multiple points
  80167. */
  80168. fixedPoints?: number;
  80169. /**
  80170. * The collision margin around a soft object
  80171. */
  80172. margin?: number;
  80173. /**
  80174. * The collision margin around a soft object
  80175. */
  80176. damping?: number;
  80177. /**
  80178. * The path for a rope based on an extrusion
  80179. */
  80180. path?: any;
  80181. /**
  80182. * The shape of an extrusion used for a rope based on an extrusion
  80183. */
  80184. shape?: any;
  80185. }
  80186. /**
  80187. * Interface for a physics-enabled object
  80188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80189. */
  80190. export interface IPhysicsEnabledObject {
  80191. /**
  80192. * The position of the physics-enabled object
  80193. */
  80194. position: Vector3;
  80195. /**
  80196. * The rotation of the physics-enabled object
  80197. */
  80198. rotationQuaternion: Nullable<Quaternion>;
  80199. /**
  80200. * The scale of the physics-enabled object
  80201. */
  80202. scaling: Vector3;
  80203. /**
  80204. * The rotation of the physics-enabled object
  80205. */
  80206. rotation?: Vector3;
  80207. /**
  80208. * The parent of the physics-enabled object
  80209. */
  80210. parent?: any;
  80211. /**
  80212. * The bounding info of the physics-enabled object
  80213. * @returns The bounding info of the physics-enabled object
  80214. */
  80215. getBoundingInfo(): BoundingInfo;
  80216. /**
  80217. * Computes the world matrix
  80218. * @param force Specifies if the world matrix should be computed by force
  80219. * @returns A world matrix
  80220. */
  80221. computeWorldMatrix(force: boolean): Matrix;
  80222. /**
  80223. * Gets the world matrix
  80224. * @returns A world matrix
  80225. */
  80226. getWorldMatrix?(): Matrix;
  80227. /**
  80228. * Gets the child meshes
  80229. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  80230. * @returns An array of abstract meshes
  80231. */
  80232. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  80233. /**
  80234. * Gets the vertex data
  80235. * @param kind The type of vertex data
  80236. * @returns A nullable array of numbers, or a float32 array
  80237. */
  80238. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  80239. /**
  80240. * Gets the indices from the mesh
  80241. * @returns A nullable array of index arrays
  80242. */
  80243. getIndices?(): Nullable<IndicesArray>;
  80244. /**
  80245. * Gets the scene from the mesh
  80246. * @returns the indices array or null
  80247. */
  80248. getScene?(): Scene;
  80249. /**
  80250. * Gets the absolute position from the mesh
  80251. * @returns the absolute position
  80252. */
  80253. getAbsolutePosition(): Vector3;
  80254. /**
  80255. * Gets the absolute pivot point from the mesh
  80256. * @returns the absolute pivot point
  80257. */
  80258. getAbsolutePivotPoint(): Vector3;
  80259. /**
  80260. * Rotates the mesh
  80261. * @param axis The axis of rotation
  80262. * @param amount The amount of rotation
  80263. * @param space The space of the rotation
  80264. * @returns The rotation transform node
  80265. */
  80266. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80267. /**
  80268. * Translates the mesh
  80269. * @param axis The axis of translation
  80270. * @param distance The distance of translation
  80271. * @param space The space of the translation
  80272. * @returns The transform node
  80273. */
  80274. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80275. /**
  80276. * Sets the absolute position of the mesh
  80277. * @param absolutePosition The absolute position of the mesh
  80278. * @returns The transform node
  80279. */
  80280. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80281. /**
  80282. * Gets the class name of the mesh
  80283. * @returns The class name
  80284. */
  80285. getClassName(): string;
  80286. }
  80287. /**
  80288. * Represents a physics imposter
  80289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80290. */
  80291. export class PhysicsImpostor {
  80292. /**
  80293. * The physics-enabled object used as the physics imposter
  80294. */
  80295. object: IPhysicsEnabledObject;
  80296. /**
  80297. * The type of the physics imposter
  80298. */
  80299. type: number;
  80300. private _options;
  80301. private _scene?;
  80302. /**
  80303. * The default object size of the imposter
  80304. */
  80305. static DEFAULT_OBJECT_SIZE: Vector3;
  80306. /**
  80307. * The identity quaternion of the imposter
  80308. */
  80309. static IDENTITY_QUATERNION: Quaternion;
  80310. /** @hidden */
  80311. _pluginData: any;
  80312. private _physicsEngine;
  80313. private _physicsBody;
  80314. private _bodyUpdateRequired;
  80315. private _onBeforePhysicsStepCallbacks;
  80316. private _onAfterPhysicsStepCallbacks;
  80317. /** @hidden */
  80318. _onPhysicsCollideCallbacks: Array<{
  80319. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  80320. otherImpostors: Array<PhysicsImpostor>;
  80321. }>;
  80322. private _deltaPosition;
  80323. private _deltaRotation;
  80324. private _deltaRotationConjugated;
  80325. /** hidden */
  80326. _isFromLine: boolean;
  80327. private _parent;
  80328. private _isDisposed;
  80329. private static _tmpVecs;
  80330. private static _tmpQuat;
  80331. /**
  80332. * Specifies if the physics imposter is disposed
  80333. */
  80334. readonly isDisposed: boolean;
  80335. /**
  80336. * Gets the mass of the physics imposter
  80337. */
  80338. mass: number;
  80339. /**
  80340. * Gets the coefficient of friction
  80341. */
  80342. /**
  80343. * Sets the coefficient of friction
  80344. */
  80345. friction: number;
  80346. /**
  80347. * Gets the coefficient of restitution
  80348. */
  80349. /**
  80350. * Sets the coefficient of restitution
  80351. */
  80352. restitution: number;
  80353. /**
  80354. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  80355. */
  80356. /**
  80357. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  80358. */
  80359. pressure: number;
  80360. /**
  80361. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80362. */
  80363. /**
  80364. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80365. */
  80366. stiffness: number;
  80367. /**
  80368. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80369. */
  80370. /**
  80371. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80372. */
  80373. velocityIterations: number;
  80374. /**
  80375. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80376. */
  80377. /**
  80378. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80379. */
  80380. positionIterations: number;
  80381. /**
  80382. * The unique id of the physics imposter
  80383. * set by the physics engine when adding this impostor to the array
  80384. */
  80385. uniqueId: number;
  80386. /**
  80387. * @hidden
  80388. */
  80389. soft: boolean;
  80390. /**
  80391. * @hidden
  80392. */
  80393. segments: number;
  80394. private _joints;
  80395. /**
  80396. * Initializes the physics imposter
  80397. * @param object The physics-enabled object used as the physics imposter
  80398. * @param type The type of the physics imposter
  80399. * @param _options The options for the physics imposter
  80400. * @param _scene The Babylon scene
  80401. */
  80402. constructor(
  80403. /**
  80404. * The physics-enabled object used as the physics imposter
  80405. */
  80406. object: IPhysicsEnabledObject,
  80407. /**
  80408. * The type of the physics imposter
  80409. */
  80410. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  80411. /**
  80412. * This function will completly initialize this impostor.
  80413. * It will create a new body - but only if this mesh has no parent.
  80414. * If it has, this impostor will not be used other than to define the impostor
  80415. * of the child mesh.
  80416. * @hidden
  80417. */
  80418. _init(): void;
  80419. private _getPhysicsParent;
  80420. /**
  80421. * Should a new body be generated.
  80422. * @returns boolean specifying if body initialization is required
  80423. */
  80424. isBodyInitRequired(): boolean;
  80425. /**
  80426. * Sets the updated scaling
  80427. * @param updated Specifies if the scaling is updated
  80428. */
  80429. setScalingUpdated(): void;
  80430. /**
  80431. * Force a regeneration of this or the parent's impostor's body.
  80432. * Use under cautious - This will remove all joints already implemented.
  80433. */
  80434. forceUpdate(): void;
  80435. /**
  80436. * Gets the body that holds this impostor. Either its own, or its parent.
  80437. */
  80438. /**
  80439. * Set the physics body. Used mainly by the physics engine/plugin
  80440. */
  80441. physicsBody: any;
  80442. /**
  80443. * Get the parent of the physics imposter
  80444. * @returns Physics imposter or null
  80445. */
  80446. /**
  80447. * Sets the parent of the physics imposter
  80448. */
  80449. parent: Nullable<PhysicsImpostor>;
  80450. /**
  80451. * Resets the update flags
  80452. */
  80453. resetUpdateFlags(): void;
  80454. /**
  80455. * Gets the object extend size
  80456. * @returns the object extend size
  80457. */
  80458. getObjectExtendSize(): Vector3;
  80459. /**
  80460. * Gets the object center
  80461. * @returns The object center
  80462. */
  80463. getObjectCenter(): Vector3;
  80464. /**
  80465. * Get a specific parametes from the options parameter
  80466. * @param paramName The object parameter name
  80467. * @returns The object parameter
  80468. */
  80469. getParam(paramName: string): any;
  80470. /**
  80471. * Sets a specific parameter in the options given to the physics plugin
  80472. * @param paramName The parameter name
  80473. * @param value The value of the parameter
  80474. */
  80475. setParam(paramName: string, value: number): void;
  80476. /**
  80477. * Specifically change the body's mass option. Won't recreate the physics body object
  80478. * @param mass The mass of the physics imposter
  80479. */
  80480. setMass(mass: number): void;
  80481. /**
  80482. * Gets the linear velocity
  80483. * @returns linear velocity or null
  80484. */
  80485. getLinearVelocity(): Nullable<Vector3>;
  80486. /**
  80487. * Sets the linear velocity
  80488. * @param velocity linear velocity or null
  80489. */
  80490. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80491. /**
  80492. * Gets the angular velocity
  80493. * @returns angular velocity or null
  80494. */
  80495. getAngularVelocity(): Nullable<Vector3>;
  80496. /**
  80497. * Sets the angular velocity
  80498. * @param velocity The velocity or null
  80499. */
  80500. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80501. /**
  80502. * Execute a function with the physics plugin native code
  80503. * Provide a function the will have two variables - the world object and the physics body object
  80504. * @param func The function to execute with the physics plugin native code
  80505. */
  80506. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80507. /**
  80508. * Register a function that will be executed before the physics world is stepping forward
  80509. * @param func The function to execute before the physics world is stepped forward
  80510. */
  80511. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80512. /**
  80513. * Unregister a function that will be executed before the physics world is stepping forward
  80514. * @param func The function to execute before the physics world is stepped forward
  80515. */
  80516. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80517. /**
  80518. * Register a function that will be executed after the physics step
  80519. * @param func The function to execute after physics step
  80520. */
  80521. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80522. /**
  80523. * Unregisters a function that will be executed after the physics step
  80524. * @param func The function to execute after physics step
  80525. */
  80526. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80527. /**
  80528. * register a function that will be executed when this impostor collides against a different body
  80529. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80530. * @param func Callback that is executed on collision
  80531. */
  80532. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80533. /**
  80534. * Unregisters the physics imposter on contact
  80535. * @param collideAgainst The physics object to collide against
  80536. * @param func Callback to execute on collision
  80537. */
  80538. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80539. private _tmpQuat;
  80540. private _tmpQuat2;
  80541. /**
  80542. * Get the parent rotation
  80543. * @returns The parent rotation
  80544. */
  80545. getParentsRotation(): Quaternion;
  80546. /**
  80547. * this function is executed by the physics engine.
  80548. */
  80549. beforeStep: () => void;
  80550. /**
  80551. * this function is executed by the physics engine
  80552. */
  80553. afterStep: () => void;
  80554. /**
  80555. * Legacy collision detection event support
  80556. */
  80557. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80558. /**
  80559. * event and body object due to cannon's event-based architecture.
  80560. */
  80561. onCollide: (e: {
  80562. body: any;
  80563. }) => void;
  80564. /**
  80565. * Apply a force
  80566. * @param force The force to apply
  80567. * @param contactPoint The contact point for the force
  80568. * @returns The physics imposter
  80569. */
  80570. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80571. /**
  80572. * Apply an impulse
  80573. * @param force The impulse force
  80574. * @param contactPoint The contact point for the impulse force
  80575. * @returns The physics imposter
  80576. */
  80577. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80578. /**
  80579. * A help function to create a joint
  80580. * @param otherImpostor A physics imposter used to create a joint
  80581. * @param jointType The type of joint
  80582. * @param jointData The data for the joint
  80583. * @returns The physics imposter
  80584. */
  80585. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80586. /**
  80587. * Add a joint to this impostor with a different impostor
  80588. * @param otherImpostor A physics imposter used to add a joint
  80589. * @param joint The joint to add
  80590. * @returns The physics imposter
  80591. */
  80592. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80593. /**
  80594. * Add an anchor to a cloth impostor
  80595. * @param otherImpostor rigid impostor to anchor to
  80596. * @param width ratio across width from 0 to 1
  80597. * @param height ratio up height from 0 to 1
  80598. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80599. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80600. * @returns impostor the soft imposter
  80601. */
  80602. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80603. /**
  80604. * Add a hook to a rope impostor
  80605. * @param otherImpostor rigid impostor to anchor to
  80606. * @param length ratio across rope from 0 to 1
  80607. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80608. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80609. * @returns impostor the rope imposter
  80610. */
  80611. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80612. /**
  80613. * Will keep this body still, in a sleep mode.
  80614. * @returns the physics imposter
  80615. */
  80616. sleep(): PhysicsImpostor;
  80617. /**
  80618. * Wake the body up.
  80619. * @returns The physics imposter
  80620. */
  80621. wakeUp(): PhysicsImpostor;
  80622. /**
  80623. * Clones the physics imposter
  80624. * @param newObject The physics imposter clones to this physics-enabled object
  80625. * @returns A nullable physics imposter
  80626. */
  80627. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80628. /**
  80629. * Disposes the physics imposter
  80630. */
  80631. dispose(): void;
  80632. /**
  80633. * Sets the delta position
  80634. * @param position The delta position amount
  80635. */
  80636. setDeltaPosition(position: Vector3): void;
  80637. /**
  80638. * Sets the delta rotation
  80639. * @param rotation The delta rotation amount
  80640. */
  80641. setDeltaRotation(rotation: Quaternion): void;
  80642. /**
  80643. * Gets the box size of the physics imposter and stores the result in the input parameter
  80644. * @param result Stores the box size
  80645. * @returns The physics imposter
  80646. */
  80647. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80648. /**
  80649. * Gets the radius of the physics imposter
  80650. * @returns Radius of the physics imposter
  80651. */
  80652. getRadius(): number;
  80653. /**
  80654. * Sync a bone with this impostor
  80655. * @param bone The bone to sync to the impostor.
  80656. * @param boneMesh The mesh that the bone is influencing.
  80657. * @param jointPivot The pivot of the joint / bone in local space.
  80658. * @param distToJoint Optional distance from the impostor to the joint.
  80659. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80660. */
  80661. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80662. /**
  80663. * Sync impostor to a bone
  80664. * @param bone The bone that the impostor will be synced to.
  80665. * @param boneMesh The mesh that the bone is influencing.
  80666. * @param jointPivot The pivot of the joint / bone in local space.
  80667. * @param distToJoint Optional distance from the impostor to the joint.
  80668. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80669. * @param boneAxis Optional vector3 axis the bone is aligned with
  80670. */
  80671. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80672. /**
  80673. * No-Imposter type
  80674. */
  80675. static NoImpostor: number;
  80676. /**
  80677. * Sphere-Imposter type
  80678. */
  80679. static SphereImpostor: number;
  80680. /**
  80681. * Box-Imposter type
  80682. */
  80683. static BoxImpostor: number;
  80684. /**
  80685. * Plane-Imposter type
  80686. */
  80687. static PlaneImpostor: number;
  80688. /**
  80689. * Mesh-imposter type
  80690. */
  80691. static MeshImpostor: number;
  80692. /**
  80693. * Cylinder-Imposter type
  80694. */
  80695. static CylinderImpostor: number;
  80696. /**
  80697. * Particle-Imposter type
  80698. */
  80699. static ParticleImpostor: number;
  80700. /**
  80701. * Heightmap-Imposter type
  80702. */
  80703. static HeightmapImpostor: number;
  80704. /**
  80705. * ConvexHull-Impostor type (Ammo.js plugin only)
  80706. */
  80707. static ConvexHullImpostor: number;
  80708. /**
  80709. * Rope-Imposter type
  80710. */
  80711. static RopeImpostor: number;
  80712. /**
  80713. * Cloth-Imposter type
  80714. */
  80715. static ClothImpostor: number;
  80716. /**
  80717. * Softbody-Imposter type
  80718. */
  80719. static SoftbodyImpostor: number;
  80720. }
  80721. }
  80722. declare module BABYLON {
  80723. /**
  80724. * @hidden
  80725. **/
  80726. export class _CreationDataStorage {
  80727. closePath?: boolean;
  80728. closeArray?: boolean;
  80729. idx: number[];
  80730. dashSize: number;
  80731. gapSize: number;
  80732. path3D: Path3D;
  80733. pathArray: Vector3[][];
  80734. arc: number;
  80735. radius: number;
  80736. cap: number;
  80737. tessellation: number;
  80738. }
  80739. /**
  80740. * @hidden
  80741. **/
  80742. class _InstanceDataStorage {
  80743. visibleInstances: any;
  80744. batchCache: _InstancesBatch;
  80745. instancesBufferSize: number;
  80746. instancesBuffer: Nullable<Buffer>;
  80747. instancesData: Float32Array;
  80748. overridenInstanceCount: number;
  80749. isFrozen: boolean;
  80750. previousBatch: _InstancesBatch;
  80751. hardwareInstancedRendering: boolean;
  80752. sideOrientation: number;
  80753. }
  80754. /**
  80755. * @hidden
  80756. **/
  80757. export class _InstancesBatch {
  80758. mustReturn: boolean;
  80759. visibleInstances: Nullable<InstancedMesh[]>[];
  80760. renderSelf: boolean[];
  80761. hardwareInstancedRendering: boolean[];
  80762. }
  80763. /**
  80764. * Class used to represent renderable models
  80765. */
  80766. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80767. /**
  80768. * Mesh side orientation : usually the external or front surface
  80769. */
  80770. static readonly FRONTSIDE: number;
  80771. /**
  80772. * Mesh side orientation : usually the internal or back surface
  80773. */
  80774. static readonly BACKSIDE: number;
  80775. /**
  80776. * Mesh side orientation : both internal and external or front and back surfaces
  80777. */
  80778. static readonly DOUBLESIDE: number;
  80779. /**
  80780. * Mesh side orientation : by default, `FRONTSIDE`
  80781. */
  80782. static readonly DEFAULTSIDE: number;
  80783. /**
  80784. * Mesh cap setting : no cap
  80785. */
  80786. static readonly NO_CAP: number;
  80787. /**
  80788. * Mesh cap setting : one cap at the beginning of the mesh
  80789. */
  80790. static readonly CAP_START: number;
  80791. /**
  80792. * Mesh cap setting : one cap at the end of the mesh
  80793. */
  80794. static readonly CAP_END: number;
  80795. /**
  80796. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80797. */
  80798. static readonly CAP_ALL: number;
  80799. /**
  80800. * Gets the default side orientation.
  80801. * @param orientation the orientation to value to attempt to get
  80802. * @returns the default orientation
  80803. * @hidden
  80804. */
  80805. static _GetDefaultSideOrientation(orientation?: number): number;
  80806. private _onBeforeRenderObservable;
  80807. private _onBeforeBindObservable;
  80808. private _onAfterRenderObservable;
  80809. private _onBeforeDrawObservable;
  80810. /**
  80811. * An event triggered before rendering the mesh
  80812. */
  80813. readonly onBeforeRenderObservable: Observable<Mesh>;
  80814. /**
  80815. * An event triggered before binding the mesh
  80816. */
  80817. readonly onBeforeBindObservable: Observable<Mesh>;
  80818. /**
  80819. * An event triggered after rendering the mesh
  80820. */
  80821. readonly onAfterRenderObservable: Observable<Mesh>;
  80822. /**
  80823. * An event triggered before drawing the mesh
  80824. */
  80825. readonly onBeforeDrawObservable: Observable<Mesh>;
  80826. private _onBeforeDrawObserver;
  80827. /**
  80828. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80829. */
  80830. onBeforeDraw: () => void;
  80831. /**
  80832. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80833. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80834. */
  80835. delayLoadState: number;
  80836. /**
  80837. * Gets the list of instances created from this mesh
  80838. * it is not supposed to be modified manually.
  80839. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80840. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80841. */
  80842. instances: InstancedMesh[];
  80843. /**
  80844. * Gets the file containing delay loading data for this mesh
  80845. */
  80846. delayLoadingFile: string;
  80847. /** @hidden */
  80848. _binaryInfo: any;
  80849. private _LODLevels;
  80850. /**
  80851. * User defined function used to change how LOD level selection is done
  80852. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80853. */
  80854. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80855. private _morphTargetManager;
  80856. /**
  80857. * Gets or sets the morph target manager
  80858. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80859. */
  80860. morphTargetManager: Nullable<MorphTargetManager>;
  80861. /** @hidden */
  80862. _creationDataStorage: Nullable<_CreationDataStorage>;
  80863. /** @hidden */
  80864. _geometry: Nullable<Geometry>;
  80865. /** @hidden */
  80866. _delayInfo: Array<string>;
  80867. /** @hidden */
  80868. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80869. /** @hidden */
  80870. _instanceDataStorage: _InstanceDataStorage;
  80871. private _effectiveMaterial;
  80872. /** @hidden */
  80873. _shouldGenerateFlatShading: boolean;
  80874. private _preActivateId;
  80875. /** @hidden */
  80876. _originalBuilderSideOrientation: number;
  80877. /**
  80878. * Use this property to change the original side orientation defined at construction time
  80879. */
  80880. overrideMaterialSideOrientation: Nullable<number>;
  80881. private _areNormalsFrozen;
  80882. private _sourcePositions;
  80883. private _sourceNormals;
  80884. private _source;
  80885. private meshMap;
  80886. /**
  80887. * Gets the source mesh (the one used to clone this one from)
  80888. */
  80889. readonly source: Nullable<Mesh>;
  80890. /**
  80891. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80892. */
  80893. isUnIndexed: boolean;
  80894. /**
  80895. * @constructor
  80896. * @param name The value used by scene.getMeshByName() to do a lookup.
  80897. * @param scene The scene to add this mesh to.
  80898. * @param parent The parent of this mesh, if it has one
  80899. * @param source An optional Mesh from which geometry is shared, cloned.
  80900. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80901. * When false, achieved by calling a clone(), also passing False.
  80902. * This will make creation of children, recursive.
  80903. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80904. */
  80905. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80906. /**
  80907. * Gets the class name
  80908. * @returns the string "Mesh".
  80909. */
  80910. getClassName(): string;
  80911. /** @hidden */
  80912. readonly _isMesh: boolean;
  80913. /**
  80914. * Returns a description of this mesh
  80915. * @param fullDetails define if full details about this mesh must be used
  80916. * @returns a descriptive string representing this mesh
  80917. */
  80918. toString(fullDetails?: boolean): string;
  80919. /** @hidden */
  80920. _unBindEffect(): void;
  80921. /**
  80922. * Gets a boolean indicating if this mesh has LOD
  80923. */
  80924. readonly hasLODLevels: boolean;
  80925. /**
  80926. * Gets the list of MeshLODLevel associated with the current mesh
  80927. * @returns an array of MeshLODLevel
  80928. */
  80929. getLODLevels(): MeshLODLevel[];
  80930. private _sortLODLevels;
  80931. /**
  80932. * Add a mesh as LOD level triggered at the given distance.
  80933. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80934. * @param distance The distance from the center of the object to show this level
  80935. * @param mesh The mesh to be added as LOD level (can be null)
  80936. * @return This mesh (for chaining)
  80937. */
  80938. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80939. /**
  80940. * Returns the LOD level mesh at the passed distance or null if not found.
  80941. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80942. * @param distance The distance from the center of the object to show this level
  80943. * @returns a Mesh or `null`
  80944. */
  80945. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80946. /**
  80947. * Remove a mesh from the LOD array
  80948. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80949. * @param mesh defines the mesh to be removed
  80950. * @return This mesh (for chaining)
  80951. */
  80952. removeLODLevel(mesh: Mesh): Mesh;
  80953. /**
  80954. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80955. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80956. * @param camera defines the camera to use to compute distance
  80957. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80958. * @return This mesh (for chaining)
  80959. */
  80960. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80961. /**
  80962. * Gets the mesh internal Geometry object
  80963. */
  80964. readonly geometry: Nullable<Geometry>;
  80965. /**
  80966. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80967. * @returns the total number of vertices
  80968. */
  80969. getTotalVertices(): number;
  80970. /**
  80971. * Returns the content of an associated vertex buffer
  80972. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80973. * - VertexBuffer.PositionKind
  80974. * - VertexBuffer.UVKind
  80975. * - VertexBuffer.UV2Kind
  80976. * - VertexBuffer.UV3Kind
  80977. * - VertexBuffer.UV4Kind
  80978. * - VertexBuffer.UV5Kind
  80979. * - VertexBuffer.UV6Kind
  80980. * - VertexBuffer.ColorKind
  80981. * - VertexBuffer.MatricesIndicesKind
  80982. * - VertexBuffer.MatricesIndicesExtraKind
  80983. * - VertexBuffer.MatricesWeightsKind
  80984. * - VertexBuffer.MatricesWeightsExtraKind
  80985. * @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
  80986. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80987. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80988. */
  80989. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80990. /**
  80991. * Returns the mesh VertexBuffer object from the requested `kind`
  80992. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80993. * - VertexBuffer.PositionKind
  80994. * - VertexBuffer.UVKind
  80995. * - VertexBuffer.UV2Kind
  80996. * - VertexBuffer.UV3Kind
  80997. * - VertexBuffer.UV4Kind
  80998. * - VertexBuffer.UV5Kind
  80999. * - VertexBuffer.UV6Kind
  81000. * - VertexBuffer.ColorKind
  81001. * - VertexBuffer.MatricesIndicesKind
  81002. * - VertexBuffer.MatricesIndicesExtraKind
  81003. * - VertexBuffer.MatricesWeightsKind
  81004. * - VertexBuffer.MatricesWeightsExtraKind
  81005. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  81006. */
  81007. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81008. /**
  81009. * Tests if a specific vertex buffer is associated with this mesh
  81010. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81011. * - VertexBuffer.PositionKind
  81012. * - VertexBuffer.UVKind
  81013. * - VertexBuffer.UV2Kind
  81014. * - VertexBuffer.UV3Kind
  81015. * - VertexBuffer.UV4Kind
  81016. * - VertexBuffer.UV5Kind
  81017. * - VertexBuffer.UV6Kind
  81018. * - VertexBuffer.ColorKind
  81019. * - VertexBuffer.MatricesIndicesKind
  81020. * - VertexBuffer.MatricesIndicesExtraKind
  81021. * - VertexBuffer.MatricesWeightsKind
  81022. * - VertexBuffer.MatricesWeightsExtraKind
  81023. * @returns a boolean
  81024. */
  81025. isVerticesDataPresent(kind: string): boolean;
  81026. /**
  81027. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  81028. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81029. * - VertexBuffer.PositionKind
  81030. * - VertexBuffer.UVKind
  81031. * - VertexBuffer.UV2Kind
  81032. * - VertexBuffer.UV3Kind
  81033. * - VertexBuffer.UV4Kind
  81034. * - VertexBuffer.UV5Kind
  81035. * - VertexBuffer.UV6Kind
  81036. * - VertexBuffer.ColorKind
  81037. * - VertexBuffer.MatricesIndicesKind
  81038. * - VertexBuffer.MatricesIndicesExtraKind
  81039. * - VertexBuffer.MatricesWeightsKind
  81040. * - VertexBuffer.MatricesWeightsExtraKind
  81041. * @returns a boolean
  81042. */
  81043. isVertexBufferUpdatable(kind: string): boolean;
  81044. /**
  81045. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  81046. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81047. * - VertexBuffer.PositionKind
  81048. * - VertexBuffer.UVKind
  81049. * - VertexBuffer.UV2Kind
  81050. * - VertexBuffer.UV3Kind
  81051. * - VertexBuffer.UV4Kind
  81052. * - VertexBuffer.UV5Kind
  81053. * - VertexBuffer.UV6Kind
  81054. * - VertexBuffer.ColorKind
  81055. * - VertexBuffer.MatricesIndicesKind
  81056. * - VertexBuffer.MatricesIndicesExtraKind
  81057. * - VertexBuffer.MatricesWeightsKind
  81058. * - VertexBuffer.MatricesWeightsExtraKind
  81059. * @returns an array of strings
  81060. */
  81061. getVerticesDataKinds(): string[];
  81062. /**
  81063. * Returns a positive integer : the total number of indices in this mesh geometry.
  81064. * @returns the numner of indices or zero if the mesh has no geometry.
  81065. */
  81066. getTotalIndices(): number;
  81067. /**
  81068. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81069. * @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.
  81070. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81071. * @returns the indices array or an empty array if the mesh has no geometry
  81072. */
  81073. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81074. readonly isBlocked: boolean;
  81075. /**
  81076. * Determine if the current mesh is ready to be rendered
  81077. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81078. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  81079. * @returns true if all associated assets are ready (material, textures, shaders)
  81080. */
  81081. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  81082. /**
  81083. * 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.
  81084. */
  81085. readonly areNormalsFrozen: boolean;
  81086. /**
  81087. * 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.
  81088. * @returns the current mesh
  81089. */
  81090. freezeNormals(): Mesh;
  81091. /**
  81092. * 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
  81093. * @returns the current mesh
  81094. */
  81095. unfreezeNormals(): Mesh;
  81096. /**
  81097. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  81098. */
  81099. overridenInstanceCount: number;
  81100. /** @hidden */
  81101. _preActivate(): Mesh;
  81102. /** @hidden */
  81103. _preActivateForIntermediateRendering(renderId: number): Mesh;
  81104. /** @hidden */
  81105. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  81106. /**
  81107. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81108. * This means the mesh underlying bounding box and sphere are recomputed.
  81109. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81110. * @returns the current mesh
  81111. */
  81112. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  81113. /** @hidden */
  81114. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  81115. /**
  81116. * This function will subdivide the mesh into multiple submeshes
  81117. * @param count defines the expected number of submeshes
  81118. */
  81119. subdivide(count: number): void;
  81120. /**
  81121. * Copy a FloatArray into a specific associated vertex buffer
  81122. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81123. * - VertexBuffer.PositionKind
  81124. * - VertexBuffer.UVKind
  81125. * - VertexBuffer.UV2Kind
  81126. * - VertexBuffer.UV3Kind
  81127. * - VertexBuffer.UV4Kind
  81128. * - VertexBuffer.UV5Kind
  81129. * - VertexBuffer.UV6Kind
  81130. * - VertexBuffer.ColorKind
  81131. * - VertexBuffer.MatricesIndicesKind
  81132. * - VertexBuffer.MatricesIndicesExtraKind
  81133. * - VertexBuffer.MatricesWeightsKind
  81134. * - VertexBuffer.MatricesWeightsExtraKind
  81135. * @param data defines the data source
  81136. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81137. * @param stride defines the data stride size (can be null)
  81138. * @returns the current mesh
  81139. */
  81140. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  81141. /**
  81142. * Flags an associated vertex buffer as updatable
  81143. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81144. * - VertexBuffer.PositionKind
  81145. * - VertexBuffer.UVKind
  81146. * - VertexBuffer.UV2Kind
  81147. * - VertexBuffer.UV3Kind
  81148. * - VertexBuffer.UV4Kind
  81149. * - VertexBuffer.UV5Kind
  81150. * - VertexBuffer.UV6Kind
  81151. * - VertexBuffer.ColorKind
  81152. * - VertexBuffer.MatricesIndicesKind
  81153. * - VertexBuffer.MatricesIndicesExtraKind
  81154. * - VertexBuffer.MatricesWeightsKind
  81155. * - VertexBuffer.MatricesWeightsExtraKind
  81156. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81157. */
  81158. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  81159. /**
  81160. * Sets the mesh global Vertex Buffer
  81161. * @param buffer defines the buffer to use
  81162. * @returns the current mesh
  81163. */
  81164. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  81165. /**
  81166. * Update a specific associated vertex buffer
  81167. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81168. * - VertexBuffer.PositionKind
  81169. * - VertexBuffer.UVKind
  81170. * - VertexBuffer.UV2Kind
  81171. * - VertexBuffer.UV3Kind
  81172. * - VertexBuffer.UV4Kind
  81173. * - VertexBuffer.UV5Kind
  81174. * - VertexBuffer.UV6Kind
  81175. * - VertexBuffer.ColorKind
  81176. * - VertexBuffer.MatricesIndicesKind
  81177. * - VertexBuffer.MatricesIndicesExtraKind
  81178. * - VertexBuffer.MatricesWeightsKind
  81179. * - VertexBuffer.MatricesWeightsExtraKind
  81180. * @param data defines the data source
  81181. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81182. * @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)
  81183. * @returns the current mesh
  81184. */
  81185. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  81186. /**
  81187. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81188. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81189. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81190. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81191. * @returns the current mesh
  81192. */
  81193. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  81194. /**
  81195. * Creates a un-shared specific occurence of the geometry for the mesh.
  81196. * @returns the current mesh
  81197. */
  81198. makeGeometryUnique(): Mesh;
  81199. /**
  81200. * Set the index buffer of this mesh
  81201. * @param indices defines the source data
  81202. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81203. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81204. * @returns the current mesh
  81205. */
  81206. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  81207. /**
  81208. * Update the current index buffer
  81209. * @param indices defines the source data
  81210. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81211. * @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)
  81212. * @returns the current mesh
  81213. */
  81214. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  81215. /**
  81216. * Invert the geometry to move from a right handed system to a left handed one.
  81217. * @returns the current mesh
  81218. */
  81219. toLeftHanded(): Mesh;
  81220. /** @hidden */
  81221. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  81222. /** @hidden */
  81223. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  81224. /**
  81225. * Registers for this mesh a javascript function called just before the rendering process
  81226. * @param func defines the function to call before rendering this mesh
  81227. * @returns the current mesh
  81228. */
  81229. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81230. /**
  81231. * Disposes a previously registered javascript function called before the rendering
  81232. * @param func defines the function to remove
  81233. * @returns the current mesh
  81234. */
  81235. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81236. /**
  81237. * Registers for this mesh a javascript function called just after the rendering is complete
  81238. * @param func defines the function to call after rendering this mesh
  81239. * @returns the current mesh
  81240. */
  81241. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81242. /**
  81243. * Disposes a previously registered javascript function called after the rendering.
  81244. * @param func defines the function to remove
  81245. * @returns the current mesh
  81246. */
  81247. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81248. /** @hidden */
  81249. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  81250. /** @hidden */
  81251. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  81252. /** @hidden */
  81253. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  81254. /** @hidden */
  81255. _freeze(): void;
  81256. /** @hidden */
  81257. _unFreeze(): void;
  81258. /**
  81259. * 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
  81260. * @param subMesh defines the subMesh to render
  81261. * @param enableAlphaMode defines if alpha mode can be changed
  81262. * @returns the current mesh
  81263. */
  81264. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  81265. private _onBeforeDraw;
  81266. /**
  81267. * Renormalize the mesh and patch it up if there are no weights
  81268. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81269. * However in the case of zero weights then we set just a single influence to 1.
  81270. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81271. */
  81272. cleanMatrixWeights(): void;
  81273. private normalizeSkinFourWeights;
  81274. private normalizeSkinWeightsAndExtra;
  81275. /**
  81276. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81277. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81278. * the user know there was an issue with importing the mesh
  81279. * @returns a validation object with skinned, valid and report string
  81280. */
  81281. validateSkinning(): {
  81282. skinned: boolean;
  81283. valid: boolean;
  81284. report: string;
  81285. };
  81286. /** @hidden */
  81287. _checkDelayState(): Mesh;
  81288. private _queueLoad;
  81289. /**
  81290. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81291. * A mesh is in the frustum if its bounding box intersects the frustum
  81292. * @param frustumPlanes defines the frustum to test
  81293. * @returns true if the mesh is in the frustum planes
  81294. */
  81295. isInFrustum(frustumPlanes: Plane[]): boolean;
  81296. /**
  81297. * Sets the mesh material by the material or multiMaterial `id` property
  81298. * @param id is a string identifying the material or the multiMaterial
  81299. * @returns the current mesh
  81300. */
  81301. setMaterialByID(id: string): Mesh;
  81302. /**
  81303. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81304. * @returns an array of IAnimatable
  81305. */
  81306. getAnimatables(): IAnimatable[];
  81307. /**
  81308. * Modifies the mesh geometry according to the passed transformation matrix.
  81309. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81310. * The mesh normals are modified using the same transformation.
  81311. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81312. * @param transform defines the transform matrix to use
  81313. * @see http://doc.babylonjs.com/resources/baking_transformations
  81314. * @returns the current mesh
  81315. */
  81316. bakeTransformIntoVertices(transform: Matrix): Mesh;
  81317. /**
  81318. * Modifies the mesh geometry according to its own current World Matrix.
  81319. * The mesh World Matrix is then reset.
  81320. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81321. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81322. * @see http://doc.babylonjs.com/resources/baking_transformations
  81323. * @returns the current mesh
  81324. */
  81325. bakeCurrentTransformIntoVertices(): Mesh;
  81326. /** @hidden */
  81327. readonly _positions: Nullable<Vector3[]>;
  81328. /** @hidden */
  81329. _resetPointsArrayCache(): Mesh;
  81330. /** @hidden */
  81331. _generatePointsArray(): boolean;
  81332. /**
  81333. * Returns a new Mesh object generated from the current mesh properties.
  81334. * This method must not get confused with createInstance()
  81335. * @param name is a string, the name given to the new mesh
  81336. * @param newParent can be any Node object (default `null`)
  81337. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81338. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81339. * @returns a new mesh
  81340. */
  81341. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  81342. /**
  81343. * Releases resources associated with this mesh.
  81344. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81345. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81346. */
  81347. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81348. /**
  81349. * Modifies the mesh geometry according to a displacement map.
  81350. * 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.
  81351. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81352. * @param url is a string, the URL from the image file is to be downloaded.
  81353. * @param minHeight is the lower limit of the displacement.
  81354. * @param maxHeight is the upper limit of the displacement.
  81355. * @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.
  81356. * @param uvOffset is an optional vector2 used to offset UV.
  81357. * @param uvScale is an optional vector2 used to scale UV.
  81358. * @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.
  81359. * @returns the Mesh.
  81360. */
  81361. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81362. /**
  81363. * Modifies the mesh geometry according to a displacementMap buffer.
  81364. * 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.
  81365. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81366. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81367. * @param heightMapWidth is the width of the buffer image.
  81368. * @param heightMapHeight is the height of the buffer image.
  81369. * @param minHeight is the lower limit of the displacement.
  81370. * @param maxHeight is the upper limit of the displacement.
  81371. * @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.
  81372. * @param uvOffset is an optional vector2 used to offset UV.
  81373. * @param uvScale is an optional vector2 used to scale UV.
  81374. * @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.
  81375. * @returns the Mesh.
  81376. */
  81377. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81378. /**
  81379. * Modify the mesh to get a flat shading rendering.
  81380. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81381. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81382. * @returns current mesh
  81383. */
  81384. convertToFlatShadedMesh(): Mesh;
  81385. /**
  81386. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  81387. * In other words, more vertices, no more indices and a single bigger VBO.
  81388. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  81389. * @returns current mesh
  81390. */
  81391. convertToUnIndexedMesh(): Mesh;
  81392. /**
  81393. * Inverses facet orientations.
  81394. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81395. * @param flipNormals will also inverts the normals
  81396. * @returns current mesh
  81397. */
  81398. flipFaces(flipNormals?: boolean): Mesh;
  81399. /**
  81400. * Increase the number of facets and hence vertices in a mesh
  81401. * Vertex normals are interpolated from existing vertex normals
  81402. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81403. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  81404. */
  81405. increaseVertices(numberPerEdge: number): void;
  81406. /**
  81407. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  81408. * This will undo any application of covertToFlatShadedMesh
  81409. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81410. */
  81411. forceSharedVertices(): void;
  81412. /** @hidden */
  81413. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  81414. /** @hidden */
  81415. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81416. /**
  81417. * Creates a new InstancedMesh object from the mesh model.
  81418. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81419. * @param name defines the name of the new instance
  81420. * @returns a new InstancedMesh
  81421. */
  81422. createInstance(name: string): InstancedMesh;
  81423. /**
  81424. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81425. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81426. * @returns the current mesh
  81427. */
  81428. synchronizeInstances(): Mesh;
  81429. /**
  81430. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81431. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81432. * This should be used together with the simplification to avoid disappearing triangles.
  81433. * @param successCallback an optional success callback to be called after the optimization finished.
  81434. * @returns the current mesh
  81435. */
  81436. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81437. /**
  81438. * Serialize current mesh
  81439. * @param serializationObject defines the object which will receive the serialization data
  81440. */
  81441. serialize(serializationObject: any): void;
  81442. /** @hidden */
  81443. _syncGeometryWithMorphTargetManager(): void;
  81444. /** @hidden */
  81445. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81446. /**
  81447. * Returns a new Mesh object parsed from the source provided.
  81448. * @param parsedMesh is the source
  81449. * @param scene defines the hosting scene
  81450. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81451. * @returns a new Mesh
  81452. */
  81453. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81454. /**
  81455. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81456. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81457. * @param name defines the name of the mesh to create
  81458. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81459. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81460. * @param closePath creates a seam between the first and the last points of each path of the path array
  81461. * @param offset is taken in account only if the `pathArray` is containing a single path
  81462. * @param scene defines the hosting scene
  81463. * @param updatable defines if the mesh must be flagged as updatable
  81464. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81465. * @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)
  81466. * @returns a new Mesh
  81467. */
  81468. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81469. /**
  81470. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81471. * @param name defines the name of the mesh to create
  81472. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81473. * @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
  81474. * @param scene defines the hosting scene
  81475. * @param updatable defines if the mesh must be flagged as updatable
  81476. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81477. * @returns a new Mesh
  81478. */
  81479. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81480. /**
  81481. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81482. * @param name defines the name of the mesh to create
  81483. * @param size sets the size (float) of each box side (default 1)
  81484. * @param scene defines the hosting scene
  81485. * @param updatable defines if the mesh must be flagged as updatable
  81486. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81487. * @returns a new Mesh
  81488. */
  81489. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81490. /**
  81491. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81492. * @param name defines the name of the mesh to create
  81493. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81494. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81495. * @param scene defines the hosting scene
  81496. * @param updatable defines if the mesh must be flagged as updatable
  81497. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81498. * @returns a new Mesh
  81499. */
  81500. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81501. /**
  81502. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81503. * @param name defines the name of the mesh to create
  81504. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81505. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81506. * @param scene defines the hosting scene
  81507. * @returns a new Mesh
  81508. */
  81509. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81510. /**
  81511. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81512. * @param name defines the name of the mesh to create
  81513. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81514. * @param diameterTop set the top cap diameter (floats, default 1)
  81515. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81516. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81517. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81518. * @param scene defines the hosting scene
  81519. * @param updatable defines if the mesh must be flagged as updatable
  81520. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81521. * @returns a new Mesh
  81522. */
  81523. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81524. /**
  81525. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81526. * @param name defines the name of the mesh to create
  81527. * @param diameter sets the diameter size (float) of the torus (default 1)
  81528. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81529. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81530. * @param scene defines the hosting scene
  81531. * @param updatable defines if the mesh must be flagged as updatable
  81532. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81533. * @returns a new Mesh
  81534. */
  81535. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81536. /**
  81537. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81538. * @param name defines the name of the mesh to create
  81539. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81540. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81541. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81542. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81543. * @param p the number of windings on X axis (positive integers, default 2)
  81544. * @param q the number of windings on Y axis (positive integers, default 3)
  81545. * @param scene defines the hosting scene
  81546. * @param updatable defines if the mesh must be flagged as updatable
  81547. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81548. * @returns a new Mesh
  81549. */
  81550. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81551. /**
  81552. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  81553. * @param name defines the name of the mesh to create
  81554. * @param points is an array successive Vector3
  81555. * @param scene defines the hosting scene
  81556. * @param updatable defines if the mesh must be flagged as updatable
  81557. * @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).
  81558. * @returns a new Mesh
  81559. */
  81560. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81561. /**
  81562. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81563. * @param name defines the name of the mesh to create
  81564. * @param points is an array successive Vector3
  81565. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81566. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81567. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81568. * @param scene defines the hosting scene
  81569. * @param updatable defines if the mesh must be flagged as updatable
  81570. * @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)
  81571. * @returns a new Mesh
  81572. */
  81573. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81574. /**
  81575. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81576. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81577. * 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.
  81578. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81579. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81580. * Remember you can only change the shape positions, not their number when updating a polygon.
  81581. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81582. * @param name defines the name of the mesh to create
  81583. * @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
  81584. * @param scene defines the hosting scene
  81585. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81586. * @param updatable defines if the mesh must be flagged as updatable
  81587. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81588. * @param earcutInjection can be used to inject your own earcut reference
  81589. * @returns a new Mesh
  81590. */
  81591. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81592. /**
  81593. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81594. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81595. * @param name defines the name of the mesh to create
  81596. * @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
  81597. * @param depth defines the height of extrusion
  81598. * @param scene defines the hosting scene
  81599. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81600. * @param updatable defines if the mesh must be flagged as updatable
  81601. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81602. * @param earcutInjection can be used to inject your own earcut reference
  81603. * @returns a new Mesh
  81604. */
  81605. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81606. /**
  81607. * Creates an extruded shape mesh.
  81608. * 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
  81609. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81610. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81611. * @param name defines the name of the mesh to create
  81612. * @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
  81613. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81614. * @param scale is the value to scale the shape
  81615. * @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
  81616. * @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
  81617. * @param scene defines the hosting scene
  81618. * @param updatable defines if the mesh must be flagged as updatable
  81619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81620. * @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)
  81621. * @returns a new Mesh
  81622. */
  81623. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81624. /**
  81625. * Creates an custom extruded shape mesh.
  81626. * The custom extrusion is a parametric shape.
  81627. * It has no predefined shape. Its final shape will depend on the input parameters.
  81628. * Please consider using the same method from the MeshBuilder class instead
  81629. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81630. * @param name defines the name of the mesh to create
  81631. * @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
  81632. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81633. * @param scaleFunction is a custom Javascript function called on each path point
  81634. * @param rotationFunction is a custom Javascript function called on each path point
  81635. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81636. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81637. * @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
  81638. * @param scene defines the hosting scene
  81639. * @param updatable defines if the mesh must be flagged as updatable
  81640. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81641. * @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)
  81642. * @returns a new Mesh
  81643. */
  81644. 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;
  81645. /**
  81646. * Creates lathe mesh.
  81647. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81648. * Please consider using the same method from the MeshBuilder class instead
  81649. * @param name defines the name of the mesh to create
  81650. * @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
  81651. * @param radius is the radius value of the lathe
  81652. * @param tessellation is the side number of the lathe.
  81653. * @param scene defines the hosting scene
  81654. * @param updatable defines if the mesh must be flagged as updatable
  81655. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81656. * @returns a new Mesh
  81657. */
  81658. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81659. /**
  81660. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81661. * @param name defines the name of the mesh to create
  81662. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81663. * @param scene defines the hosting scene
  81664. * @param updatable defines if the mesh must be flagged as updatable
  81665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81666. * @returns a new Mesh
  81667. */
  81668. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81669. /**
  81670. * Creates a ground mesh.
  81671. * Please consider using the same method from the MeshBuilder class instead
  81672. * @param name defines the name of the mesh to create
  81673. * @param width set the width of the ground
  81674. * @param height set the height of the ground
  81675. * @param subdivisions sets the number of subdivisions per side
  81676. * @param scene defines the hosting scene
  81677. * @param updatable defines if the mesh must be flagged as updatable
  81678. * @returns a new Mesh
  81679. */
  81680. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81681. /**
  81682. * Creates a tiled ground mesh.
  81683. * Please consider using the same method from the MeshBuilder class instead
  81684. * @param name defines the name of the mesh to create
  81685. * @param xmin set the ground minimum X coordinate
  81686. * @param zmin set the ground minimum Y coordinate
  81687. * @param xmax set the ground maximum X coordinate
  81688. * @param zmax set the ground maximum Z coordinate
  81689. * @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
  81690. * @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
  81691. * @param scene defines the hosting scene
  81692. * @param updatable defines if the mesh must be flagged as updatable
  81693. * @returns a new Mesh
  81694. */
  81695. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81696. w: number;
  81697. h: number;
  81698. }, precision: {
  81699. w: number;
  81700. h: number;
  81701. }, scene: Scene, updatable?: boolean): Mesh;
  81702. /**
  81703. * Creates a ground mesh from a height map.
  81704. * Please consider using the same method from the MeshBuilder class instead
  81705. * @see http://doc.babylonjs.com/babylon101/height_map
  81706. * @param name defines the name of the mesh to create
  81707. * @param url sets the URL of the height map image resource
  81708. * @param width set the ground width size
  81709. * @param height set the ground height size
  81710. * @param subdivisions sets the number of subdivision per side
  81711. * @param minHeight is the minimum altitude on the ground
  81712. * @param maxHeight is the maximum altitude on the ground
  81713. * @param scene defines the hosting scene
  81714. * @param updatable defines if the mesh must be flagged as updatable
  81715. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81716. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81717. * @returns a new Mesh
  81718. */
  81719. 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;
  81720. /**
  81721. * Creates a tube mesh.
  81722. * The tube is a parametric shape.
  81723. * It has no predefined shape. Its final shape will depend on the input parameters.
  81724. * Please consider using the same method from the MeshBuilder class instead
  81725. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81726. * @param name defines the name of the mesh to create
  81727. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81728. * @param radius sets the tube radius size
  81729. * @param tessellation is the number of sides on the tubular surface
  81730. * @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
  81731. * @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
  81732. * @param scene defines the hosting scene
  81733. * @param updatable defines if the mesh must be flagged as updatable
  81734. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81735. * @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)
  81736. * @returns a new Mesh
  81737. */
  81738. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81739. (i: number, distance: number): number;
  81740. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81741. /**
  81742. * Creates a polyhedron mesh.
  81743. * Please consider using the same method from the MeshBuilder class instead.
  81744. * * 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
  81745. * * The parameter `size` (positive float, default 1) sets the polygon size
  81746. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81747. * * 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`
  81748. * * 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
  81749. * * 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)`)
  81750. * * 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
  81751. * * 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
  81752. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81753. * * If you create a double-sided mesh, you can choose what parts of 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
  81754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81755. * @param name defines the name of the mesh to create
  81756. * @param options defines the options used to create the mesh
  81757. * @param scene defines the hosting scene
  81758. * @returns a new Mesh
  81759. */
  81760. static CreatePolyhedron(name: string, options: {
  81761. type?: number;
  81762. size?: number;
  81763. sizeX?: number;
  81764. sizeY?: number;
  81765. sizeZ?: number;
  81766. custom?: any;
  81767. faceUV?: Vector4[];
  81768. faceColors?: Color4[];
  81769. updatable?: boolean;
  81770. sideOrientation?: number;
  81771. }, scene: Scene): Mesh;
  81772. /**
  81773. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81774. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81775. * * 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`)
  81776. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81777. * * 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
  81778. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81779. * * If you create a double-sided mesh, you can choose what parts of 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
  81780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81781. * @param name defines the name of the mesh
  81782. * @param options defines the options used to create the mesh
  81783. * @param scene defines the hosting scene
  81784. * @returns a new Mesh
  81785. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81786. */
  81787. static CreateIcoSphere(name: string, options: {
  81788. radius?: number;
  81789. flat?: boolean;
  81790. subdivisions?: number;
  81791. sideOrientation?: number;
  81792. updatable?: boolean;
  81793. }, scene: Scene): Mesh;
  81794. /**
  81795. * Creates a decal mesh.
  81796. * Please consider using the same method from the MeshBuilder class instead.
  81797. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81798. * @param name defines the name of the mesh
  81799. * @param sourceMesh defines the mesh receiving the decal
  81800. * @param position sets the position of the decal in world coordinates
  81801. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81802. * @param size sets the decal scaling
  81803. * @param angle sets the angle to rotate the decal
  81804. * @returns a new Mesh
  81805. */
  81806. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81807. /**
  81808. * Prepare internal position array for software CPU skinning
  81809. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81810. */
  81811. setPositionsForCPUSkinning(): Float32Array;
  81812. /**
  81813. * Prepare internal normal array for software CPU skinning
  81814. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81815. */
  81816. setNormalsForCPUSkinning(): Float32Array;
  81817. /**
  81818. * Updates the vertex buffer by applying transformation from the bones
  81819. * @param skeleton defines the skeleton to apply to current mesh
  81820. * @returns the current mesh
  81821. */
  81822. applySkeleton(skeleton: Skeleton): Mesh;
  81823. /**
  81824. * 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
  81825. * @param meshes defines the list of meshes to scan
  81826. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81827. */
  81828. static MinMax(meshes: AbstractMesh[]): {
  81829. min: Vector3;
  81830. max: Vector3;
  81831. };
  81832. /**
  81833. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81834. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81835. * @returns a vector3
  81836. */
  81837. static Center(meshesOrMinMaxVector: {
  81838. min: Vector3;
  81839. max: Vector3;
  81840. } | AbstractMesh[]): Vector3;
  81841. /**
  81842. * Merge the array of meshes into a single mesh for performance reasons.
  81843. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81844. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81845. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81846. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81847. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81848. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81849. * @returns a new mesh
  81850. */
  81851. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81852. /** @hidden */
  81853. addInstance(instance: InstancedMesh): void;
  81854. /** @hidden */
  81855. removeInstance(instance: InstancedMesh): void;
  81856. }
  81857. }
  81858. declare module BABYLON {
  81859. /**
  81860. * Base class for the main features of a material in Babylon.js
  81861. */
  81862. export class Material implements IAnimatable {
  81863. /**
  81864. * Returns the triangle fill mode
  81865. */
  81866. static readonly TriangleFillMode: number;
  81867. /**
  81868. * Returns the wireframe mode
  81869. */
  81870. static readonly WireFrameFillMode: number;
  81871. /**
  81872. * Returns the point fill mode
  81873. */
  81874. static readonly PointFillMode: number;
  81875. /**
  81876. * Returns the point list draw mode
  81877. */
  81878. static readonly PointListDrawMode: number;
  81879. /**
  81880. * Returns the line list draw mode
  81881. */
  81882. static readonly LineListDrawMode: number;
  81883. /**
  81884. * Returns the line loop draw mode
  81885. */
  81886. static readonly LineLoopDrawMode: number;
  81887. /**
  81888. * Returns the line strip draw mode
  81889. */
  81890. static readonly LineStripDrawMode: number;
  81891. /**
  81892. * Returns the triangle strip draw mode
  81893. */
  81894. static readonly TriangleStripDrawMode: number;
  81895. /**
  81896. * Returns the triangle fan draw mode
  81897. */
  81898. static readonly TriangleFanDrawMode: number;
  81899. /**
  81900. * Stores the clock-wise side orientation
  81901. */
  81902. static readonly ClockWiseSideOrientation: number;
  81903. /**
  81904. * Stores the counter clock-wise side orientation
  81905. */
  81906. static readonly CounterClockWiseSideOrientation: number;
  81907. /**
  81908. * The dirty texture flag value
  81909. */
  81910. static readonly TextureDirtyFlag: number;
  81911. /**
  81912. * The dirty light flag value
  81913. */
  81914. static readonly LightDirtyFlag: number;
  81915. /**
  81916. * The dirty fresnel flag value
  81917. */
  81918. static readonly FresnelDirtyFlag: number;
  81919. /**
  81920. * The dirty attribute flag value
  81921. */
  81922. static readonly AttributesDirtyFlag: number;
  81923. /**
  81924. * The dirty misc flag value
  81925. */
  81926. static readonly MiscDirtyFlag: number;
  81927. /**
  81928. * The all dirty flag value
  81929. */
  81930. static readonly AllDirtyFlag: number;
  81931. /**
  81932. * The ID of the material
  81933. */
  81934. id: string;
  81935. /**
  81936. * Gets or sets the unique id of the material
  81937. */
  81938. uniqueId: number;
  81939. /**
  81940. * The name of the material
  81941. */
  81942. name: string;
  81943. /**
  81944. * Gets or sets user defined metadata
  81945. */
  81946. metadata: any;
  81947. /**
  81948. * For internal use only. Please do not use.
  81949. */
  81950. reservedDataStore: any;
  81951. /**
  81952. * Specifies if the ready state should be checked on each call
  81953. */
  81954. checkReadyOnEveryCall: boolean;
  81955. /**
  81956. * Specifies if the ready state should be checked once
  81957. */
  81958. checkReadyOnlyOnce: boolean;
  81959. /**
  81960. * The state of the material
  81961. */
  81962. state: string;
  81963. /**
  81964. * The alpha value of the material
  81965. */
  81966. protected _alpha: number;
  81967. /**
  81968. * List of inspectable custom properties (used by the Inspector)
  81969. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81970. */
  81971. inspectableCustomProperties: IInspectable[];
  81972. /**
  81973. * Sets the alpha value of the material
  81974. */
  81975. /**
  81976. * Gets the alpha value of the material
  81977. */
  81978. alpha: number;
  81979. /**
  81980. * Specifies if back face culling is enabled
  81981. */
  81982. protected _backFaceCulling: boolean;
  81983. /**
  81984. * Sets the back-face culling state
  81985. */
  81986. /**
  81987. * Gets the back-face culling state
  81988. */
  81989. backFaceCulling: boolean;
  81990. /**
  81991. * Stores the value for side orientation
  81992. */
  81993. sideOrientation: number;
  81994. /**
  81995. * Callback triggered when the material is compiled
  81996. */
  81997. onCompiled: Nullable<(effect: Effect) => void>;
  81998. /**
  81999. * Callback triggered when an error occurs
  82000. */
  82001. onError: Nullable<(effect: Effect, errors: string) => void>;
  82002. /**
  82003. * Callback triggered to get the render target textures
  82004. */
  82005. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  82006. /**
  82007. * Gets a boolean indicating that current material needs to register RTT
  82008. */
  82009. readonly hasRenderTargetTextures: boolean;
  82010. /**
  82011. * Specifies if the material should be serialized
  82012. */
  82013. doNotSerialize: boolean;
  82014. /**
  82015. * @hidden
  82016. */
  82017. _storeEffectOnSubMeshes: boolean;
  82018. /**
  82019. * Stores the animations for the material
  82020. */
  82021. animations: Nullable<Array<Animation>>;
  82022. /**
  82023. * An event triggered when the material is disposed
  82024. */
  82025. onDisposeObservable: Observable<Material>;
  82026. /**
  82027. * An observer which watches for dispose events
  82028. */
  82029. private _onDisposeObserver;
  82030. private _onUnBindObservable;
  82031. /**
  82032. * Called during a dispose event
  82033. */
  82034. onDispose: () => void;
  82035. private _onBindObservable;
  82036. /**
  82037. * An event triggered when the material is bound
  82038. */
  82039. readonly onBindObservable: Observable<AbstractMesh>;
  82040. /**
  82041. * An observer which watches for bind events
  82042. */
  82043. private _onBindObserver;
  82044. /**
  82045. * Called during a bind event
  82046. */
  82047. onBind: (Mesh: AbstractMesh) => void;
  82048. /**
  82049. * An event triggered when the material is unbound
  82050. */
  82051. readonly onUnBindObservable: Observable<Material>;
  82052. /**
  82053. * Stores the value of the alpha mode
  82054. */
  82055. private _alphaMode;
  82056. /**
  82057. * Sets the value of the alpha mode.
  82058. *
  82059. * | Value | Type | Description |
  82060. * | --- | --- | --- |
  82061. * | 0 | ALPHA_DISABLE | |
  82062. * | 1 | ALPHA_ADD | |
  82063. * | 2 | ALPHA_COMBINE | |
  82064. * | 3 | ALPHA_SUBTRACT | |
  82065. * | 4 | ALPHA_MULTIPLY | |
  82066. * | 5 | ALPHA_MAXIMIZED | |
  82067. * | 6 | ALPHA_ONEONE | |
  82068. * | 7 | ALPHA_PREMULTIPLIED | |
  82069. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  82070. * | 9 | ALPHA_INTERPOLATE | |
  82071. * | 10 | ALPHA_SCREENMODE | |
  82072. *
  82073. */
  82074. /**
  82075. * Gets the value of the alpha mode
  82076. */
  82077. alphaMode: number;
  82078. /**
  82079. * Stores the state of the need depth pre-pass value
  82080. */
  82081. private _needDepthPrePass;
  82082. /**
  82083. * Sets the need depth pre-pass value
  82084. */
  82085. /**
  82086. * Gets the depth pre-pass value
  82087. */
  82088. needDepthPrePass: boolean;
  82089. /**
  82090. * Specifies if depth writing should be disabled
  82091. */
  82092. disableDepthWrite: boolean;
  82093. /**
  82094. * Specifies if depth writing should be forced
  82095. */
  82096. forceDepthWrite: boolean;
  82097. /**
  82098. * Specifies if there should be a separate pass for culling
  82099. */
  82100. separateCullingPass: boolean;
  82101. /**
  82102. * Stores the state specifing if fog should be enabled
  82103. */
  82104. private _fogEnabled;
  82105. /**
  82106. * Sets the state for enabling fog
  82107. */
  82108. /**
  82109. * Gets the value of the fog enabled state
  82110. */
  82111. fogEnabled: boolean;
  82112. /**
  82113. * Stores the size of points
  82114. */
  82115. pointSize: number;
  82116. /**
  82117. * Stores the z offset value
  82118. */
  82119. zOffset: number;
  82120. /**
  82121. * Gets a value specifying if wireframe mode is enabled
  82122. */
  82123. /**
  82124. * Sets the state of wireframe mode
  82125. */
  82126. wireframe: boolean;
  82127. /**
  82128. * Gets the value specifying if point clouds are enabled
  82129. */
  82130. /**
  82131. * Sets the state of point cloud mode
  82132. */
  82133. pointsCloud: boolean;
  82134. /**
  82135. * Gets the material fill mode
  82136. */
  82137. /**
  82138. * Sets the material fill mode
  82139. */
  82140. fillMode: number;
  82141. /**
  82142. * @hidden
  82143. * Stores the effects for the material
  82144. */
  82145. _effect: Nullable<Effect>;
  82146. /**
  82147. * @hidden
  82148. * Specifies if the material was previously ready
  82149. */
  82150. _wasPreviouslyReady: boolean;
  82151. /**
  82152. * Specifies if uniform buffers should be used
  82153. */
  82154. private _useUBO;
  82155. /**
  82156. * Stores a reference to the scene
  82157. */
  82158. private _scene;
  82159. /**
  82160. * Stores the fill mode state
  82161. */
  82162. private _fillMode;
  82163. /**
  82164. * Specifies if the depth write state should be cached
  82165. */
  82166. private _cachedDepthWriteState;
  82167. /**
  82168. * Stores the uniform buffer
  82169. */
  82170. protected _uniformBuffer: UniformBuffer;
  82171. /** @hidden */
  82172. _indexInSceneMaterialArray: number;
  82173. /** @hidden */
  82174. meshMap: Nullable<{
  82175. [id: string]: AbstractMesh | undefined;
  82176. }>;
  82177. /**
  82178. * Creates a material instance
  82179. * @param name defines the name of the material
  82180. * @param scene defines the scene to reference
  82181. * @param doNotAdd specifies if the material should be added to the scene
  82182. */
  82183. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  82184. /**
  82185. * Returns a string representation of the current material
  82186. * @param fullDetails defines a boolean indicating which levels of logging is desired
  82187. * @returns a string with material information
  82188. */
  82189. toString(fullDetails?: boolean): string;
  82190. /**
  82191. * Gets the class name of the material
  82192. * @returns a string with the class name of the material
  82193. */
  82194. getClassName(): string;
  82195. /**
  82196. * Specifies if updates for the material been locked
  82197. */
  82198. readonly isFrozen: boolean;
  82199. /**
  82200. * Locks updates for the material
  82201. */
  82202. freeze(): void;
  82203. /**
  82204. * Unlocks updates for the material
  82205. */
  82206. unfreeze(): void;
  82207. /**
  82208. * Specifies if the material is ready to be used
  82209. * @param mesh defines the mesh to check
  82210. * @param useInstances specifies if instances should be used
  82211. * @returns a boolean indicating if the material is ready to be used
  82212. */
  82213. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82214. /**
  82215. * Specifies that the submesh is ready to be used
  82216. * @param mesh defines the mesh to check
  82217. * @param subMesh defines which submesh to check
  82218. * @param useInstances specifies that instances should be used
  82219. * @returns a boolean indicating that the submesh is ready or not
  82220. */
  82221. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82222. /**
  82223. * Returns the material effect
  82224. * @returns the effect associated with the material
  82225. */
  82226. getEffect(): Nullable<Effect>;
  82227. /**
  82228. * Returns the current scene
  82229. * @returns a Scene
  82230. */
  82231. getScene(): Scene;
  82232. /**
  82233. * Specifies if the material will require alpha blending
  82234. * @returns a boolean specifying if alpha blending is needed
  82235. */
  82236. needAlphaBlending(): boolean;
  82237. /**
  82238. * Specifies if the mesh will require alpha blending
  82239. * @param mesh defines the mesh to check
  82240. * @returns a boolean specifying if alpha blending is needed for the mesh
  82241. */
  82242. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  82243. /**
  82244. * Specifies if this material should be rendered in alpha test mode
  82245. * @returns a boolean specifying if an alpha test is needed.
  82246. */
  82247. needAlphaTesting(): boolean;
  82248. /**
  82249. * Gets the texture used for the alpha test
  82250. * @returns the texture to use for alpha testing
  82251. */
  82252. getAlphaTestTexture(): Nullable<BaseTexture>;
  82253. /**
  82254. * Marks the material to indicate that it needs to be re-calculated
  82255. */
  82256. markDirty(): void;
  82257. /** @hidden */
  82258. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  82259. /**
  82260. * Binds the material to the mesh
  82261. * @param world defines the world transformation matrix
  82262. * @param mesh defines the mesh to bind the material to
  82263. */
  82264. bind(world: Matrix, mesh?: Mesh): void;
  82265. /**
  82266. * Binds the submesh to the material
  82267. * @param world defines the world transformation matrix
  82268. * @param mesh defines the mesh containing the submesh
  82269. * @param subMesh defines the submesh to bind the material to
  82270. */
  82271. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  82272. /**
  82273. * Binds the world matrix to the material
  82274. * @param world defines the world transformation matrix
  82275. */
  82276. bindOnlyWorldMatrix(world: Matrix): void;
  82277. /**
  82278. * Binds the scene's uniform buffer to the effect.
  82279. * @param effect defines the effect to bind to the scene uniform buffer
  82280. * @param sceneUbo defines the uniform buffer storing scene data
  82281. */
  82282. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  82283. /**
  82284. * Binds the view matrix to the effect
  82285. * @param effect defines the effect to bind the view matrix to
  82286. */
  82287. bindView(effect: Effect): void;
  82288. /**
  82289. * Binds the view projection matrix to the effect
  82290. * @param effect defines the effect to bind the view projection matrix to
  82291. */
  82292. bindViewProjection(effect: Effect): void;
  82293. /**
  82294. * Specifies if material alpha testing should be turned on for the mesh
  82295. * @param mesh defines the mesh to check
  82296. */
  82297. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  82298. /**
  82299. * Processes to execute after binding the material to a mesh
  82300. * @param mesh defines the rendered mesh
  82301. */
  82302. protected _afterBind(mesh?: Mesh): void;
  82303. /**
  82304. * Unbinds the material from the mesh
  82305. */
  82306. unbind(): void;
  82307. /**
  82308. * Gets the active textures from the material
  82309. * @returns an array of textures
  82310. */
  82311. getActiveTextures(): BaseTexture[];
  82312. /**
  82313. * Specifies if the material uses a texture
  82314. * @param texture defines the texture to check against the material
  82315. * @returns a boolean specifying if the material uses the texture
  82316. */
  82317. hasTexture(texture: BaseTexture): boolean;
  82318. /**
  82319. * Makes a duplicate of the material, and gives it a new name
  82320. * @param name defines the new name for the duplicated material
  82321. * @returns the cloned material
  82322. */
  82323. clone(name: string): Nullable<Material>;
  82324. /**
  82325. * Gets the meshes bound to the material
  82326. * @returns an array of meshes bound to the material
  82327. */
  82328. getBindedMeshes(): AbstractMesh[];
  82329. /**
  82330. * Force shader compilation
  82331. * @param mesh defines the mesh associated with this material
  82332. * @param onCompiled defines a function to execute once the material is compiled
  82333. * @param options defines the options to configure the compilation
  82334. */
  82335. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  82336. clipPlane: boolean;
  82337. }>): void;
  82338. /**
  82339. * Force shader compilation
  82340. * @param mesh defines the mesh that will use this material
  82341. * @param options defines additional options for compiling the shaders
  82342. * @returns a promise that resolves when the compilation completes
  82343. */
  82344. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  82345. clipPlane: boolean;
  82346. }>): Promise<void>;
  82347. private static readonly _ImageProcessingDirtyCallBack;
  82348. private static readonly _TextureDirtyCallBack;
  82349. private static readonly _FresnelDirtyCallBack;
  82350. private static readonly _MiscDirtyCallBack;
  82351. private static readonly _LightsDirtyCallBack;
  82352. private static readonly _AttributeDirtyCallBack;
  82353. private static _FresnelAndMiscDirtyCallBack;
  82354. private static _TextureAndMiscDirtyCallBack;
  82355. private static readonly _DirtyCallbackArray;
  82356. private static readonly _RunDirtyCallBacks;
  82357. /**
  82358. * Marks a define in the material to indicate that it needs to be re-computed
  82359. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  82360. */
  82361. markAsDirty(flag: number): void;
  82362. /**
  82363. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  82364. * @param func defines a function which checks material defines against the submeshes
  82365. */
  82366. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  82367. /**
  82368. * Indicates that image processing needs to be re-calculated for all submeshes
  82369. */
  82370. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  82371. /**
  82372. * Indicates that textures need to be re-calculated for all submeshes
  82373. */
  82374. protected _markAllSubMeshesAsTexturesDirty(): void;
  82375. /**
  82376. * Indicates that fresnel needs to be re-calculated for all submeshes
  82377. */
  82378. protected _markAllSubMeshesAsFresnelDirty(): void;
  82379. /**
  82380. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  82381. */
  82382. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  82383. /**
  82384. * Indicates that lights need to be re-calculated for all submeshes
  82385. */
  82386. protected _markAllSubMeshesAsLightsDirty(): void;
  82387. /**
  82388. * Indicates that attributes need to be re-calculated for all submeshes
  82389. */
  82390. protected _markAllSubMeshesAsAttributesDirty(): void;
  82391. /**
  82392. * Indicates that misc needs to be re-calculated for all submeshes
  82393. */
  82394. protected _markAllSubMeshesAsMiscDirty(): void;
  82395. /**
  82396. * Indicates that textures and misc need to be re-calculated for all submeshes
  82397. */
  82398. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  82399. /**
  82400. * Disposes the material
  82401. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82402. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82403. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82404. */
  82405. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82406. /** @hidden */
  82407. private releaseVertexArrayObject;
  82408. /**
  82409. * Serializes this material
  82410. * @returns the serialized material object
  82411. */
  82412. serialize(): any;
  82413. /**
  82414. * Creates a material from parsed material data
  82415. * @param parsedMaterial defines parsed material data
  82416. * @param scene defines the hosting scene
  82417. * @param rootUrl defines the root URL to use to load textures
  82418. * @returns a new material
  82419. */
  82420. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82421. }
  82422. }
  82423. declare module BABYLON {
  82424. /**
  82425. * Base class for submeshes
  82426. */
  82427. export class BaseSubMesh {
  82428. /** @hidden */
  82429. _materialDefines: Nullable<MaterialDefines>;
  82430. /** @hidden */
  82431. _materialEffect: Nullable<Effect>;
  82432. /**
  82433. * Gets associated effect
  82434. */
  82435. readonly effect: Nullable<Effect>;
  82436. /**
  82437. * Sets associated effect (effect used to render this submesh)
  82438. * @param effect defines the effect to associate with
  82439. * @param defines defines the set of defines used to compile this effect
  82440. */
  82441. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82442. }
  82443. /**
  82444. * Defines a subdivision inside a mesh
  82445. */
  82446. export class SubMesh extends BaseSubMesh implements ICullable {
  82447. /** the material index to use */
  82448. materialIndex: number;
  82449. /** vertex index start */
  82450. verticesStart: number;
  82451. /** vertices count */
  82452. verticesCount: number;
  82453. /** index start */
  82454. indexStart: number;
  82455. /** indices count */
  82456. indexCount: number;
  82457. /** @hidden */
  82458. _linesIndexCount: number;
  82459. private _mesh;
  82460. private _renderingMesh;
  82461. private _boundingInfo;
  82462. private _linesIndexBuffer;
  82463. /** @hidden */
  82464. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82465. /** @hidden */
  82466. _trianglePlanes: Plane[];
  82467. /** @hidden */
  82468. _lastColliderTransformMatrix: Nullable<Matrix>;
  82469. /** @hidden */
  82470. _renderId: number;
  82471. /** @hidden */
  82472. _alphaIndex: number;
  82473. /** @hidden */
  82474. _distanceToCamera: number;
  82475. /** @hidden */
  82476. _id: number;
  82477. private _currentMaterial;
  82478. /**
  82479. * Add a new submesh to a mesh
  82480. * @param materialIndex defines the material index to use
  82481. * @param verticesStart defines vertex index start
  82482. * @param verticesCount defines vertices count
  82483. * @param indexStart defines index start
  82484. * @param indexCount defines indices count
  82485. * @param mesh defines the parent mesh
  82486. * @param renderingMesh defines an optional rendering mesh
  82487. * @param createBoundingBox defines if bounding box should be created for this submesh
  82488. * @returns the new submesh
  82489. */
  82490. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82491. /**
  82492. * Creates a new submesh
  82493. * @param materialIndex defines the material index to use
  82494. * @param verticesStart defines vertex index start
  82495. * @param verticesCount defines vertices count
  82496. * @param indexStart defines index start
  82497. * @param indexCount defines indices count
  82498. * @param mesh defines the parent mesh
  82499. * @param renderingMesh defines an optional rendering mesh
  82500. * @param createBoundingBox defines if bounding box should be created for this submesh
  82501. */
  82502. constructor(
  82503. /** the material index to use */
  82504. materialIndex: number,
  82505. /** vertex index start */
  82506. verticesStart: number,
  82507. /** vertices count */
  82508. verticesCount: number,
  82509. /** index start */
  82510. indexStart: number,
  82511. /** indices count */
  82512. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82513. /**
  82514. * Returns true if this submesh covers the entire parent mesh
  82515. * @ignorenaming
  82516. */
  82517. readonly IsGlobal: boolean;
  82518. /**
  82519. * Returns the submesh BoudingInfo object
  82520. * @returns current bounding info (or mesh's one if the submesh is global)
  82521. */
  82522. getBoundingInfo(): BoundingInfo;
  82523. /**
  82524. * Sets the submesh BoundingInfo
  82525. * @param boundingInfo defines the new bounding info to use
  82526. * @returns the SubMesh
  82527. */
  82528. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82529. /**
  82530. * Returns the mesh of the current submesh
  82531. * @return the parent mesh
  82532. */
  82533. getMesh(): AbstractMesh;
  82534. /**
  82535. * Returns the rendering mesh of the submesh
  82536. * @returns the rendering mesh (could be different from parent mesh)
  82537. */
  82538. getRenderingMesh(): Mesh;
  82539. /**
  82540. * Returns the submesh material
  82541. * @returns null or the current material
  82542. */
  82543. getMaterial(): Nullable<Material>;
  82544. /**
  82545. * Sets a new updated BoundingInfo object to the submesh
  82546. * @param data defines an optional position array to use to determine the bounding info
  82547. * @returns the SubMesh
  82548. */
  82549. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  82550. /** @hidden */
  82551. _checkCollision(collider: Collider): boolean;
  82552. /**
  82553. * Updates the submesh BoundingInfo
  82554. * @param world defines the world matrix to use to update the bounding info
  82555. * @returns the submesh
  82556. */
  82557. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82558. /**
  82559. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82560. * @param frustumPlanes defines the frustum planes
  82561. * @returns true if the submesh is intersecting with the frustum
  82562. */
  82563. isInFrustum(frustumPlanes: Plane[]): boolean;
  82564. /**
  82565. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82566. * @param frustumPlanes defines the frustum planes
  82567. * @returns true if the submesh is inside the frustum
  82568. */
  82569. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82570. /**
  82571. * Renders the submesh
  82572. * @param enableAlphaMode defines if alpha needs to be used
  82573. * @returns the submesh
  82574. */
  82575. render(enableAlphaMode: boolean): SubMesh;
  82576. /**
  82577. * @hidden
  82578. */
  82579. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  82580. /**
  82581. * Checks if the submesh intersects with a ray
  82582. * @param ray defines the ray to test
  82583. * @returns true is the passed ray intersects the submesh bounding box
  82584. */
  82585. canIntersects(ray: Ray): boolean;
  82586. /**
  82587. * Intersects current submesh with a ray
  82588. * @param ray defines the ray to test
  82589. * @param positions defines mesh's positions array
  82590. * @param indices defines mesh's indices array
  82591. * @param fastCheck defines if only bounding info should be used
  82592. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82593. * @returns intersection info or null if no intersection
  82594. */
  82595. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82596. /** @hidden */
  82597. private _intersectLines;
  82598. /** @hidden */
  82599. private _intersectTriangles;
  82600. /** @hidden */
  82601. _rebuild(): void;
  82602. /**
  82603. * Creates a new submesh from the passed mesh
  82604. * @param newMesh defines the new hosting mesh
  82605. * @param newRenderingMesh defines an optional rendering mesh
  82606. * @returns the new submesh
  82607. */
  82608. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82609. /**
  82610. * Release associated resources
  82611. */
  82612. dispose(): void;
  82613. /**
  82614. * Gets the class name
  82615. * @returns the string "SubMesh".
  82616. */
  82617. getClassName(): string;
  82618. /**
  82619. * Creates a new submesh from indices data
  82620. * @param materialIndex the index of the main mesh material
  82621. * @param startIndex the index where to start the copy in the mesh indices array
  82622. * @param indexCount the number of indices to copy then from the startIndex
  82623. * @param mesh the main mesh to create the submesh from
  82624. * @param renderingMesh the optional rendering mesh
  82625. * @returns a new submesh
  82626. */
  82627. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82628. }
  82629. }
  82630. declare module BABYLON {
  82631. /**
  82632. * Class used to store geometry data (vertex buffers + index buffer)
  82633. */
  82634. export class Geometry implements IGetSetVerticesData {
  82635. /**
  82636. * Gets or sets the ID of the geometry
  82637. */
  82638. id: string;
  82639. /**
  82640. * Gets or sets the unique ID of the geometry
  82641. */
  82642. uniqueId: number;
  82643. /**
  82644. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82645. */
  82646. delayLoadState: number;
  82647. /**
  82648. * Gets the file containing the data to load when running in delay load state
  82649. */
  82650. delayLoadingFile: Nullable<string>;
  82651. /**
  82652. * Callback called when the geometry is updated
  82653. */
  82654. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82655. private _scene;
  82656. private _engine;
  82657. private _meshes;
  82658. private _totalVertices;
  82659. /** @hidden */
  82660. _indices: IndicesArray;
  82661. /** @hidden */
  82662. _vertexBuffers: {
  82663. [key: string]: VertexBuffer;
  82664. };
  82665. private _isDisposed;
  82666. private _extend;
  82667. private _boundingBias;
  82668. /** @hidden */
  82669. _delayInfo: Array<string>;
  82670. private _indexBuffer;
  82671. private _indexBufferIsUpdatable;
  82672. /** @hidden */
  82673. _boundingInfo: Nullable<BoundingInfo>;
  82674. /** @hidden */
  82675. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82676. /** @hidden */
  82677. _softwareSkinningFrameId: number;
  82678. private _vertexArrayObjects;
  82679. private _updatable;
  82680. /** @hidden */
  82681. _positions: Nullable<Vector3[]>;
  82682. /**
  82683. * 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
  82684. */
  82685. /**
  82686. * 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
  82687. */
  82688. boundingBias: Vector2;
  82689. /**
  82690. * Static function used to attach a new empty geometry to a mesh
  82691. * @param mesh defines the mesh to attach the geometry to
  82692. * @returns the new Geometry
  82693. */
  82694. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82695. /**
  82696. * Creates a new geometry
  82697. * @param id defines the unique ID
  82698. * @param scene defines the hosting scene
  82699. * @param vertexData defines the VertexData used to get geometry data
  82700. * @param updatable defines if geometry must be updatable (false by default)
  82701. * @param mesh defines the mesh that will be associated with the geometry
  82702. */
  82703. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82704. /**
  82705. * Gets the current extend of the geometry
  82706. */
  82707. readonly extend: {
  82708. minimum: Vector3;
  82709. maximum: Vector3;
  82710. };
  82711. /**
  82712. * Gets the hosting scene
  82713. * @returns the hosting Scene
  82714. */
  82715. getScene(): Scene;
  82716. /**
  82717. * Gets the hosting engine
  82718. * @returns the hosting Engine
  82719. */
  82720. getEngine(): Engine;
  82721. /**
  82722. * Defines if the geometry is ready to use
  82723. * @returns true if the geometry is ready to be used
  82724. */
  82725. isReady(): boolean;
  82726. /**
  82727. * Gets a value indicating that the geometry should not be serialized
  82728. */
  82729. readonly doNotSerialize: boolean;
  82730. /** @hidden */
  82731. _rebuild(): void;
  82732. /**
  82733. * Affects all geometry data in one call
  82734. * @param vertexData defines the geometry data
  82735. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82736. */
  82737. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82738. /**
  82739. * Set specific vertex data
  82740. * @param kind defines the data kind (Position, normal, etc...)
  82741. * @param data defines the vertex data to use
  82742. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82743. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82744. */
  82745. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82746. /**
  82747. * Removes a specific vertex data
  82748. * @param kind defines the data kind (Position, normal, etc...)
  82749. */
  82750. removeVerticesData(kind: string): void;
  82751. /**
  82752. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82753. * @param buffer defines the vertex buffer to use
  82754. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82755. */
  82756. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82757. /**
  82758. * Update a specific vertex buffer
  82759. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  82760. * It will do nothing if the buffer is not updatable
  82761. * @param kind defines the data kind (Position, normal, etc...)
  82762. * @param data defines the data to use
  82763. * @param offset defines the offset in the target buffer where to store the data
  82764. * @param useBytes set to true if the offset is in bytes
  82765. */
  82766. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82767. /**
  82768. * Update a specific vertex buffer
  82769. * This function will create a new buffer if the current one is not updatable
  82770. * @param kind defines the data kind (Position, normal, etc...)
  82771. * @param data defines the data to use
  82772. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82773. */
  82774. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82775. private _updateBoundingInfo;
  82776. /** @hidden */
  82777. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  82778. /**
  82779. * Gets total number of vertices
  82780. * @returns the total number of vertices
  82781. */
  82782. getTotalVertices(): number;
  82783. /**
  82784. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82785. * @param kind defines the data kind (Position, normal, etc...)
  82786. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82787. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82788. * @returns a float array containing vertex data
  82789. */
  82790. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82791. /**
  82792. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82793. * @param kind defines the data kind (Position, normal, etc...)
  82794. * @returns true if the vertex buffer with the specified kind is updatable
  82795. */
  82796. isVertexBufferUpdatable(kind: string): boolean;
  82797. /**
  82798. * Gets a specific vertex buffer
  82799. * @param kind defines the data kind (Position, normal, etc...)
  82800. * @returns a VertexBuffer
  82801. */
  82802. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82803. /**
  82804. * Returns all vertex buffers
  82805. * @return an object holding all vertex buffers indexed by kind
  82806. */
  82807. getVertexBuffers(): Nullable<{
  82808. [key: string]: VertexBuffer;
  82809. }>;
  82810. /**
  82811. * Gets a boolean indicating if specific vertex buffer is present
  82812. * @param kind defines the data kind (Position, normal, etc...)
  82813. * @returns true if data is present
  82814. */
  82815. isVerticesDataPresent(kind: string): boolean;
  82816. /**
  82817. * Gets a list of all attached data kinds (Position, normal, etc...)
  82818. * @returns a list of string containing all kinds
  82819. */
  82820. getVerticesDataKinds(): string[];
  82821. /**
  82822. * Update index buffer
  82823. * @param indices defines the indices to store in the index buffer
  82824. * @param offset defines the offset in the target buffer where to store the data
  82825. * @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)
  82826. */
  82827. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82828. /**
  82829. * Creates a new index buffer
  82830. * @param indices defines the indices to store in the index buffer
  82831. * @param totalVertices defines the total number of vertices (could be null)
  82832. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82833. */
  82834. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82835. /**
  82836. * Return the total number of indices
  82837. * @returns the total number of indices
  82838. */
  82839. getTotalIndices(): number;
  82840. /**
  82841. * Gets the index buffer array
  82842. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82843. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82844. * @returns the index buffer array
  82845. */
  82846. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82847. /**
  82848. * Gets the index buffer
  82849. * @return the index buffer
  82850. */
  82851. getIndexBuffer(): Nullable<DataBuffer>;
  82852. /** @hidden */
  82853. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82854. /**
  82855. * Release the associated resources for a specific mesh
  82856. * @param mesh defines the source mesh
  82857. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82858. */
  82859. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82860. /**
  82861. * Apply current geometry to a given mesh
  82862. * @param mesh defines the mesh to apply geometry to
  82863. */
  82864. applyToMesh(mesh: Mesh): void;
  82865. private _updateExtend;
  82866. private _applyToMesh;
  82867. private notifyUpdate;
  82868. /**
  82869. * Load the geometry if it was flagged as delay loaded
  82870. * @param scene defines the hosting scene
  82871. * @param onLoaded defines a callback called when the geometry is loaded
  82872. */
  82873. load(scene: Scene, onLoaded?: () => void): void;
  82874. private _queueLoad;
  82875. /**
  82876. * Invert the geometry to move from a right handed system to a left handed one.
  82877. */
  82878. toLeftHanded(): void;
  82879. /** @hidden */
  82880. _resetPointsArrayCache(): void;
  82881. /** @hidden */
  82882. _generatePointsArray(): boolean;
  82883. /**
  82884. * Gets a value indicating if the geometry is disposed
  82885. * @returns true if the geometry was disposed
  82886. */
  82887. isDisposed(): boolean;
  82888. private _disposeVertexArrayObjects;
  82889. /**
  82890. * Free all associated resources
  82891. */
  82892. dispose(): void;
  82893. /**
  82894. * Clone the current geometry into a new geometry
  82895. * @param id defines the unique ID of the new geometry
  82896. * @returns a new geometry object
  82897. */
  82898. copy(id: string): Geometry;
  82899. /**
  82900. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82901. * @return a JSON representation of the current geometry data (without the vertices data)
  82902. */
  82903. serialize(): any;
  82904. private toNumberArray;
  82905. /**
  82906. * Serialize all vertices data into a JSON oject
  82907. * @returns a JSON representation of the current geometry data
  82908. */
  82909. serializeVerticeData(): any;
  82910. /**
  82911. * Extracts a clone of a mesh geometry
  82912. * @param mesh defines the source mesh
  82913. * @param id defines the unique ID of the new geometry object
  82914. * @returns the new geometry object
  82915. */
  82916. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82917. /**
  82918. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82919. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82920. * Be aware Math.random() could cause collisions, but:
  82921. * "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"
  82922. * @returns a string containing a new GUID
  82923. */
  82924. static RandomId(): string;
  82925. /** @hidden */
  82926. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82927. private static _CleanMatricesWeights;
  82928. /**
  82929. * Create a new geometry from persisted data (Using .babylon file format)
  82930. * @param parsedVertexData defines the persisted data
  82931. * @param scene defines the hosting scene
  82932. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82933. * @returns the new geometry object
  82934. */
  82935. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82936. }
  82937. }
  82938. declare module BABYLON {
  82939. /**
  82940. * Define an interface for all classes that will get and set the data on vertices
  82941. */
  82942. export interface IGetSetVerticesData {
  82943. /**
  82944. * Gets a boolean indicating if specific vertex data is present
  82945. * @param kind defines the vertex data kind to use
  82946. * @returns true is data kind is present
  82947. */
  82948. isVerticesDataPresent(kind: string): boolean;
  82949. /**
  82950. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82951. * @param kind defines the data kind (Position, normal, etc...)
  82952. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82953. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82954. * @returns a float array containing vertex data
  82955. */
  82956. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82957. /**
  82958. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82959. * @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.
  82960. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82961. * @returns the indices array or an empty array if the mesh has no geometry
  82962. */
  82963. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82964. /**
  82965. * Set specific vertex data
  82966. * @param kind defines the data kind (Position, normal, etc...)
  82967. * @param data defines the vertex data to use
  82968. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82969. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82970. */
  82971. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82972. /**
  82973. * Update a specific associated vertex buffer
  82974. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82975. * - VertexBuffer.PositionKind
  82976. * - VertexBuffer.UVKind
  82977. * - VertexBuffer.UV2Kind
  82978. * - VertexBuffer.UV3Kind
  82979. * - VertexBuffer.UV4Kind
  82980. * - VertexBuffer.UV5Kind
  82981. * - VertexBuffer.UV6Kind
  82982. * - VertexBuffer.ColorKind
  82983. * - VertexBuffer.MatricesIndicesKind
  82984. * - VertexBuffer.MatricesIndicesExtraKind
  82985. * - VertexBuffer.MatricesWeightsKind
  82986. * - VertexBuffer.MatricesWeightsExtraKind
  82987. * @param data defines the data source
  82988. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  82989. * @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)
  82990. */
  82991. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  82992. /**
  82993. * Creates a new index buffer
  82994. * @param indices defines the indices to store in the index buffer
  82995. * @param totalVertices defines the total number of vertices (could be null)
  82996. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82997. */
  82998. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  82999. }
  83000. /**
  83001. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  83002. */
  83003. export class VertexData {
  83004. /**
  83005. * Mesh side orientation : usually the external or front surface
  83006. */
  83007. static readonly FRONTSIDE: number;
  83008. /**
  83009. * Mesh side orientation : usually the internal or back surface
  83010. */
  83011. static readonly BACKSIDE: number;
  83012. /**
  83013. * Mesh side orientation : both internal and external or front and back surfaces
  83014. */
  83015. static readonly DOUBLESIDE: number;
  83016. /**
  83017. * Mesh side orientation : by default, `FRONTSIDE`
  83018. */
  83019. static readonly DEFAULTSIDE: number;
  83020. /**
  83021. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  83022. */
  83023. positions: Nullable<FloatArray>;
  83024. /**
  83025. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  83026. */
  83027. normals: Nullable<FloatArray>;
  83028. /**
  83029. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  83030. */
  83031. tangents: Nullable<FloatArray>;
  83032. /**
  83033. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83034. */
  83035. uvs: Nullable<FloatArray>;
  83036. /**
  83037. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83038. */
  83039. uvs2: Nullable<FloatArray>;
  83040. /**
  83041. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83042. */
  83043. uvs3: Nullable<FloatArray>;
  83044. /**
  83045. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83046. */
  83047. uvs4: Nullable<FloatArray>;
  83048. /**
  83049. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83050. */
  83051. uvs5: Nullable<FloatArray>;
  83052. /**
  83053. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83054. */
  83055. uvs6: Nullable<FloatArray>;
  83056. /**
  83057. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  83058. */
  83059. colors: Nullable<FloatArray>;
  83060. /**
  83061. * 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).
  83062. */
  83063. matricesIndices: Nullable<FloatArray>;
  83064. /**
  83065. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  83066. */
  83067. matricesWeights: Nullable<FloatArray>;
  83068. /**
  83069. * An array extending the number of possible indices
  83070. */
  83071. matricesIndicesExtra: Nullable<FloatArray>;
  83072. /**
  83073. * An array extending the number of possible weights when the number of indices is extended
  83074. */
  83075. matricesWeightsExtra: Nullable<FloatArray>;
  83076. /**
  83077. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  83078. */
  83079. indices: Nullable<IndicesArray>;
  83080. /**
  83081. * Uses the passed data array to set the set the values for the specified kind of data
  83082. * @param data a linear array of floating numbers
  83083. * @param kind the type of data that is being set, eg positions, colors etc
  83084. */
  83085. set(data: FloatArray, kind: string): void;
  83086. /**
  83087. * Associates the vertexData to the passed Mesh.
  83088. * Sets it as updatable or not (default `false`)
  83089. * @param mesh the mesh the vertexData is applied to
  83090. * @param updatable when used and having the value true allows new data to update the vertexData
  83091. * @returns the VertexData
  83092. */
  83093. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  83094. /**
  83095. * Associates the vertexData to the passed Geometry.
  83096. * Sets it as updatable or not (default `false`)
  83097. * @param geometry the geometry the vertexData is applied to
  83098. * @param updatable when used and having the value true allows new data to update the vertexData
  83099. * @returns VertexData
  83100. */
  83101. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  83102. /**
  83103. * Updates the associated mesh
  83104. * @param mesh the mesh to be updated
  83105. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83106. * @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
  83107. * @returns VertexData
  83108. */
  83109. updateMesh(mesh: Mesh): VertexData;
  83110. /**
  83111. * Updates the associated geometry
  83112. * @param geometry the geometry to be updated
  83113. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83114. * @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
  83115. * @returns VertexData.
  83116. */
  83117. updateGeometry(geometry: Geometry): VertexData;
  83118. private _applyTo;
  83119. private _update;
  83120. /**
  83121. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83122. * @param matrix the transforming matrix
  83123. * @returns the VertexData
  83124. */
  83125. transform(matrix: Matrix): VertexData;
  83126. /**
  83127. * Merges the passed VertexData into the current one
  83128. * @param other the VertexData to be merged into the current one
  83129. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83130. * @returns the modified VertexData
  83131. */
  83132. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  83133. private _mergeElement;
  83134. private _validate;
  83135. /**
  83136. * Serializes the VertexData
  83137. * @returns a serialized object
  83138. */
  83139. serialize(): any;
  83140. /**
  83141. * Extracts the vertexData from a mesh
  83142. * @param mesh the mesh from which to extract the VertexData
  83143. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83144. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83145. * @returns the object VertexData associated to the passed mesh
  83146. */
  83147. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83148. /**
  83149. * Extracts the vertexData from the geometry
  83150. * @param geometry the geometry from which to extract the VertexData
  83151. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  83152. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83153. * @returns the object VertexData associated to the passed mesh
  83154. */
  83155. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83156. private static _ExtractFrom;
  83157. /**
  83158. * Creates the VertexData for a Ribbon
  83159. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83160. * * pathArray array of paths, each of which an array of successive Vector3
  83161. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83162. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83163. * * 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
  83164. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83165. * * 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)
  83166. * * 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)
  83167. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83168. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83169. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83170. * @returns the VertexData of the ribbon
  83171. */
  83172. static CreateRibbon(options: {
  83173. pathArray: Vector3[][];
  83174. closeArray?: boolean;
  83175. closePath?: boolean;
  83176. offset?: number;
  83177. sideOrientation?: number;
  83178. frontUVs?: Vector4;
  83179. backUVs?: Vector4;
  83180. invertUV?: boolean;
  83181. uvs?: Vector2[];
  83182. colors?: Color4[];
  83183. }): VertexData;
  83184. /**
  83185. * Creates the VertexData for a box
  83186. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83187. * * size sets the width, height and depth of the box to the value of size, optional default 1
  83188. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  83189. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  83190. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  83191. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  83192. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  83193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83194. * * 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)
  83195. * * 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)
  83196. * @returns the VertexData of the box
  83197. */
  83198. static CreateBox(options: {
  83199. size?: number;
  83200. width?: number;
  83201. height?: number;
  83202. depth?: number;
  83203. faceUV?: Vector4[];
  83204. faceColors?: Color4[];
  83205. sideOrientation?: number;
  83206. frontUVs?: Vector4;
  83207. backUVs?: Vector4;
  83208. }): VertexData;
  83209. /**
  83210. * Creates the VertexData for an ellipsoid, defaults to a sphere
  83211. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83212. * * segments sets the number of horizontal strips optional, default 32
  83213. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  83214. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  83215. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  83216. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  83217. * * 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
  83218. * * 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
  83219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83220. * * 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)
  83221. * * 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)
  83222. * @returns the VertexData of the ellipsoid
  83223. */
  83224. static CreateSphere(options: {
  83225. segments?: number;
  83226. diameter?: number;
  83227. diameterX?: number;
  83228. diameterY?: number;
  83229. diameterZ?: number;
  83230. arc?: number;
  83231. slice?: number;
  83232. sideOrientation?: number;
  83233. frontUVs?: Vector4;
  83234. backUVs?: Vector4;
  83235. }): VertexData;
  83236. /**
  83237. * Creates the VertexData for a cylinder, cone or prism
  83238. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83239. * * height sets the height (y direction) of the cylinder, optional, default 2
  83240. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  83241. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  83242. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  83243. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83244. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  83245. * * 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
  83246. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83247. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83248. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  83249. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  83250. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83251. * * 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)
  83252. * * 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)
  83253. * @returns the VertexData of the cylinder, cone or prism
  83254. */
  83255. static CreateCylinder(options: {
  83256. height?: number;
  83257. diameterTop?: number;
  83258. diameterBottom?: number;
  83259. diameter?: number;
  83260. tessellation?: number;
  83261. subdivisions?: number;
  83262. arc?: number;
  83263. faceColors?: Color4[];
  83264. faceUV?: Vector4[];
  83265. hasRings?: boolean;
  83266. enclose?: boolean;
  83267. sideOrientation?: number;
  83268. frontUVs?: Vector4;
  83269. backUVs?: Vector4;
  83270. }): VertexData;
  83271. /**
  83272. * Creates the VertexData for a torus
  83273. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83274. * * diameter the diameter of the torus, optional default 1
  83275. * * thickness the diameter of the tube forming the torus, optional default 0.5
  83276. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83277. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83278. * * 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)
  83279. * * 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)
  83280. * @returns the VertexData of the torus
  83281. */
  83282. static CreateTorus(options: {
  83283. diameter?: number;
  83284. thickness?: number;
  83285. tessellation?: number;
  83286. sideOrientation?: number;
  83287. frontUVs?: Vector4;
  83288. backUVs?: Vector4;
  83289. }): VertexData;
  83290. /**
  83291. * Creates the VertexData of the LineSystem
  83292. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  83293. * - lines an array of lines, each line being an array of successive Vector3
  83294. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  83295. * @returns the VertexData of the LineSystem
  83296. */
  83297. static CreateLineSystem(options: {
  83298. lines: Vector3[][];
  83299. colors?: Nullable<Color4[][]>;
  83300. }): VertexData;
  83301. /**
  83302. * Create the VertexData for a DashedLines
  83303. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  83304. * - points an array successive Vector3
  83305. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  83306. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  83307. * - dashNb the intended total number of dashes, optional, default 200
  83308. * @returns the VertexData for the DashedLines
  83309. */
  83310. static CreateDashedLines(options: {
  83311. points: Vector3[];
  83312. dashSize?: number;
  83313. gapSize?: number;
  83314. dashNb?: number;
  83315. }): VertexData;
  83316. /**
  83317. * Creates the VertexData for a Ground
  83318. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83319. * - width the width (x direction) of the ground, optional, default 1
  83320. * - height the height (z direction) of the ground, optional, default 1
  83321. * - subdivisions the number of subdivisions per side, optional, default 1
  83322. * @returns the VertexData of the Ground
  83323. */
  83324. static CreateGround(options: {
  83325. width?: number;
  83326. height?: number;
  83327. subdivisions?: number;
  83328. subdivisionsX?: number;
  83329. subdivisionsY?: number;
  83330. }): VertexData;
  83331. /**
  83332. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  83333. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83334. * * xmin the ground minimum X coordinate, optional, default -1
  83335. * * zmin the ground minimum Z coordinate, optional, default -1
  83336. * * xmax the ground maximum X coordinate, optional, default 1
  83337. * * zmax the ground maximum Z coordinate, optional, default 1
  83338. * * 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}
  83339. * * 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}
  83340. * @returns the VertexData of the TiledGround
  83341. */
  83342. static CreateTiledGround(options: {
  83343. xmin: number;
  83344. zmin: number;
  83345. xmax: number;
  83346. zmax: number;
  83347. subdivisions?: {
  83348. w: number;
  83349. h: number;
  83350. };
  83351. precision?: {
  83352. w: number;
  83353. h: number;
  83354. };
  83355. }): VertexData;
  83356. /**
  83357. * Creates the VertexData of the Ground designed from a heightmap
  83358. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  83359. * * width the width (x direction) of the ground
  83360. * * height the height (z direction) of the ground
  83361. * * subdivisions the number of subdivisions per side
  83362. * * minHeight the minimum altitude on the ground, optional, default 0
  83363. * * maxHeight the maximum altitude on the ground, optional default 1
  83364. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  83365. * * buffer the array holding the image color data
  83366. * * bufferWidth the width of image
  83367. * * bufferHeight the height of image
  83368. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  83369. * @returns the VertexData of the Ground designed from a heightmap
  83370. */
  83371. static CreateGroundFromHeightMap(options: {
  83372. width: number;
  83373. height: number;
  83374. subdivisions: number;
  83375. minHeight: number;
  83376. maxHeight: number;
  83377. colorFilter: Color3;
  83378. buffer: Uint8Array;
  83379. bufferWidth: number;
  83380. bufferHeight: number;
  83381. alphaFilter: number;
  83382. }): VertexData;
  83383. /**
  83384. * Creates the VertexData for a Plane
  83385. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  83386. * * size sets the width and height of the plane to the value of size, optional default 1
  83387. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  83388. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  83389. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83390. * * 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)
  83391. * * 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)
  83392. * @returns the VertexData of the box
  83393. */
  83394. static CreatePlane(options: {
  83395. size?: number;
  83396. width?: number;
  83397. height?: number;
  83398. sideOrientation?: number;
  83399. frontUVs?: Vector4;
  83400. backUVs?: Vector4;
  83401. }): VertexData;
  83402. /**
  83403. * Creates the VertexData of the Disc or regular Polygon
  83404. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  83405. * * radius the radius of the disc, optional default 0.5
  83406. * * tessellation the number of polygon sides, optional, default 64
  83407. * * 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
  83408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83409. * * 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)
  83410. * * 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)
  83411. * @returns the VertexData of the box
  83412. */
  83413. static CreateDisc(options: {
  83414. radius?: number;
  83415. tessellation?: number;
  83416. arc?: number;
  83417. sideOrientation?: number;
  83418. frontUVs?: Vector4;
  83419. backUVs?: Vector4;
  83420. }): VertexData;
  83421. /**
  83422. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83423. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83424. * @param polygon a mesh built from polygonTriangulation.build()
  83425. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83426. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83427. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83428. * @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)
  83429. * @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)
  83430. * @returns the VertexData of the Polygon
  83431. */
  83432. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83433. /**
  83434. * Creates the VertexData of the IcoSphere
  83435. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83436. * * radius the radius of the IcoSphere, optional default 1
  83437. * * radiusX allows stretching in the x direction, optional, default radius
  83438. * * radiusY allows stretching in the y direction, optional, default radius
  83439. * * radiusZ allows stretching in the z direction, optional, default radius
  83440. * * flat when true creates a flat shaded mesh, optional, default true
  83441. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83442. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83443. * * 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)
  83444. * * 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)
  83445. * @returns the VertexData of the IcoSphere
  83446. */
  83447. static CreateIcoSphere(options: {
  83448. radius?: number;
  83449. radiusX?: number;
  83450. radiusY?: number;
  83451. radiusZ?: number;
  83452. flat?: boolean;
  83453. subdivisions?: number;
  83454. sideOrientation?: number;
  83455. frontUVs?: Vector4;
  83456. backUVs?: Vector4;
  83457. }): VertexData;
  83458. /**
  83459. * Creates the VertexData for a Polyhedron
  83460. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83461. * * type provided types are:
  83462. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83463. * * 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)
  83464. * * size the size of the IcoSphere, optional default 1
  83465. * * sizeX allows stretching in the x direction, optional, default size
  83466. * * sizeY allows stretching in the y direction, optional, default size
  83467. * * sizeZ allows stretching in the z direction, optional, default size
  83468. * * 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
  83469. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83470. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83471. * * flat when true creates a flat shaded mesh, optional, default true
  83472. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83473. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83474. * * 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)
  83475. * * 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)
  83476. * @returns the VertexData of the Polyhedron
  83477. */
  83478. static CreatePolyhedron(options: {
  83479. type?: number;
  83480. size?: number;
  83481. sizeX?: number;
  83482. sizeY?: number;
  83483. sizeZ?: number;
  83484. custom?: any;
  83485. faceUV?: Vector4[];
  83486. faceColors?: Color4[];
  83487. flat?: boolean;
  83488. sideOrientation?: number;
  83489. frontUVs?: Vector4;
  83490. backUVs?: Vector4;
  83491. }): VertexData;
  83492. /**
  83493. * Creates the VertexData for a TorusKnot
  83494. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83495. * * radius the radius of the torus knot, optional, default 2
  83496. * * tube the thickness of the tube, optional, default 0.5
  83497. * * radialSegments the number of sides on each tube segments, optional, default 32
  83498. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83499. * * p the number of windings around the z axis, optional, default 2
  83500. * * q the number of windings around the x axis, optional, default 3
  83501. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83502. * * 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)
  83503. * * 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)
  83504. * @returns the VertexData of the Torus Knot
  83505. */
  83506. static CreateTorusKnot(options: {
  83507. radius?: number;
  83508. tube?: number;
  83509. radialSegments?: number;
  83510. tubularSegments?: number;
  83511. p?: number;
  83512. q?: number;
  83513. sideOrientation?: number;
  83514. frontUVs?: Vector4;
  83515. backUVs?: Vector4;
  83516. }): VertexData;
  83517. /**
  83518. * Compute normals for given positions and indices
  83519. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83520. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83521. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83522. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83523. * * facetNormals : optional array of facet normals (vector3)
  83524. * * facetPositions : optional array of facet positions (vector3)
  83525. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83526. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83527. * * bInfo : optional bounding info, required for facetPartitioning computation
  83528. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83529. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83530. * * useRightHandedSystem: optional boolean to for right handed system computation
  83531. * * depthSort : optional boolean to enable the facet depth sort computation
  83532. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83533. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83534. */
  83535. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83536. facetNormals?: any;
  83537. facetPositions?: any;
  83538. facetPartitioning?: any;
  83539. ratio?: number;
  83540. bInfo?: any;
  83541. bbSize?: Vector3;
  83542. subDiv?: any;
  83543. useRightHandedSystem?: boolean;
  83544. depthSort?: boolean;
  83545. distanceTo?: Vector3;
  83546. depthSortedFacets?: any;
  83547. }): void;
  83548. /** @hidden */
  83549. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83550. /**
  83551. * Applies VertexData created from the imported parameters to the geometry
  83552. * @param parsedVertexData the parsed data from an imported file
  83553. * @param geometry the geometry to apply the VertexData to
  83554. */
  83555. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83556. }
  83557. }
  83558. declare module BABYLON {
  83559. /**
  83560. * Class containing static functions to help procedurally build meshes
  83561. */
  83562. export class DiscBuilder {
  83563. /**
  83564. * Creates a plane polygonal mesh. By default, this is a disc
  83565. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83566. * * 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
  83567. * * 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
  83568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83571. * @param name defines the name of the mesh
  83572. * @param options defines the options used to create the mesh
  83573. * @param scene defines the hosting scene
  83574. * @returns the plane polygonal mesh
  83575. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83576. */
  83577. static CreateDisc(name: string, options: {
  83578. radius?: number;
  83579. tessellation?: number;
  83580. arc?: number;
  83581. updatable?: boolean;
  83582. sideOrientation?: number;
  83583. frontUVs?: Vector4;
  83584. backUVs?: Vector4;
  83585. }, scene?: Nullable<Scene>): Mesh;
  83586. }
  83587. }
  83588. declare module BABYLON {
  83589. /**
  83590. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83591. *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.
  83592. * The SPS is also a particle system. It provides some methods to manage the particles.
  83593. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83594. *
  83595. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83596. */
  83597. export class SolidParticleSystem implements IDisposable {
  83598. /**
  83599. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83600. * Example : var p = SPS.particles[i];
  83601. */
  83602. particles: SolidParticle[];
  83603. /**
  83604. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83605. */
  83606. nbParticles: number;
  83607. /**
  83608. * If the particles must ever face the camera (default false). Useful for planar particles.
  83609. */
  83610. billboard: boolean;
  83611. /**
  83612. * Recompute normals when adding a shape
  83613. */
  83614. recomputeNormals: boolean;
  83615. /**
  83616. * This a counter ofr your own usage. It's not set by any SPS functions.
  83617. */
  83618. counter: number;
  83619. /**
  83620. * The SPS name. This name is also given to the underlying mesh.
  83621. */
  83622. name: string;
  83623. /**
  83624. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83625. */
  83626. mesh: Mesh;
  83627. /**
  83628. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83629. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83630. */
  83631. vars: any;
  83632. /**
  83633. * This array is populated when the SPS is set as 'pickable'.
  83634. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83635. * Each element of this array is an object `{idx: int, faceId: int}`.
  83636. * `idx` is the picked particle index in the `SPS.particles` array
  83637. * `faceId` is the picked face index counted within this particle.
  83638. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83639. */
  83640. pickedParticles: {
  83641. idx: number;
  83642. faceId: number;
  83643. }[];
  83644. /**
  83645. * This array is populated when `enableDepthSort` is set to true.
  83646. * Each element of this array is an instance of the class DepthSortedParticle.
  83647. */
  83648. depthSortedParticles: DepthSortedParticle[];
  83649. /**
  83650. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83651. * @hidden
  83652. */
  83653. _bSphereOnly: boolean;
  83654. /**
  83655. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83656. * @hidden
  83657. */
  83658. _bSphereRadiusFactor: number;
  83659. private _scene;
  83660. private _positions;
  83661. private _indices;
  83662. private _normals;
  83663. private _colors;
  83664. private _uvs;
  83665. private _indices32;
  83666. private _positions32;
  83667. private _normals32;
  83668. private _fixedNormal32;
  83669. private _colors32;
  83670. private _uvs32;
  83671. private _index;
  83672. private _updatable;
  83673. private _pickable;
  83674. private _isVisibilityBoxLocked;
  83675. private _alwaysVisible;
  83676. private _depthSort;
  83677. private _shapeCounter;
  83678. private _copy;
  83679. private _color;
  83680. private _computeParticleColor;
  83681. private _computeParticleTexture;
  83682. private _computeParticleRotation;
  83683. private _computeParticleVertex;
  83684. private _computeBoundingBox;
  83685. private _depthSortParticles;
  83686. private _camera;
  83687. private _mustUnrotateFixedNormals;
  83688. private _particlesIntersect;
  83689. private _needs32Bits;
  83690. /**
  83691. * Creates a SPS (Solid Particle System) object.
  83692. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83693. * @param scene (Scene) is the scene in which the SPS is added.
  83694. * @param options defines the options of the sps e.g.
  83695. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83696. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83697. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83698. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83699. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83700. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83701. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83702. */
  83703. constructor(name: string, scene: Scene, options?: {
  83704. updatable?: boolean;
  83705. isPickable?: boolean;
  83706. enableDepthSort?: boolean;
  83707. particleIntersection?: boolean;
  83708. boundingSphereOnly?: boolean;
  83709. bSphereRadiusFactor?: number;
  83710. });
  83711. /**
  83712. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83713. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83714. * @returns the created mesh
  83715. */
  83716. buildMesh(): Mesh;
  83717. /**
  83718. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83719. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83720. * Thus the particles generated from `digest()` have their property `position` set yet.
  83721. * @param mesh ( Mesh ) is the mesh to be digested
  83722. * @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
  83723. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83724. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83725. * @returns the current SPS
  83726. */
  83727. digest(mesh: Mesh, options?: {
  83728. facetNb?: number;
  83729. number?: number;
  83730. delta?: number;
  83731. }): SolidParticleSystem;
  83732. private _unrotateFixedNormals;
  83733. private _resetCopy;
  83734. private _meshBuilder;
  83735. private _posToShape;
  83736. private _uvsToShapeUV;
  83737. private _addParticle;
  83738. /**
  83739. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83740. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83741. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83742. * @param nb (positive integer) the number of particles to be created from this model
  83743. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83744. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83745. * @returns the number of shapes in the system
  83746. */
  83747. addShape(mesh: Mesh, nb: number, options?: {
  83748. positionFunction?: any;
  83749. vertexFunction?: any;
  83750. }): number;
  83751. private _rebuildParticle;
  83752. /**
  83753. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83754. * @returns the SPS.
  83755. */
  83756. rebuildMesh(): SolidParticleSystem;
  83757. /**
  83758. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83759. * This method calls `updateParticle()` for each particle of the SPS.
  83760. * For an animated SPS, it is usually called within the render loop.
  83761. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83762. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83763. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83764. * @returns the SPS.
  83765. */
  83766. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83767. /**
  83768. * Disposes the SPS.
  83769. */
  83770. dispose(): void;
  83771. /**
  83772. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83773. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83774. * @returns the SPS.
  83775. */
  83776. refreshVisibleSize(): SolidParticleSystem;
  83777. /**
  83778. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83779. * @param size the size (float) of the visibility box
  83780. * note : this doesn't lock the SPS mesh bounding box.
  83781. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83782. */
  83783. setVisibilityBox(size: number): void;
  83784. /**
  83785. * Gets whether the SPS as always visible or not
  83786. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83787. */
  83788. /**
  83789. * Sets the SPS as always visible or not
  83790. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83791. */
  83792. isAlwaysVisible: boolean;
  83793. /**
  83794. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83796. */
  83797. /**
  83798. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83799. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83800. */
  83801. isVisibilityBoxLocked: boolean;
  83802. /**
  83803. * Tells to `setParticles()` to compute the particle rotations or not.
  83804. * Default value : true. The SPS is faster when it's set to false.
  83805. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83806. */
  83807. /**
  83808. * Gets if `setParticles()` computes the particle rotations or not.
  83809. * Default value : true. The SPS is faster when it's set to false.
  83810. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83811. */
  83812. computeParticleRotation: boolean;
  83813. /**
  83814. * Tells to `setParticles()` to compute the particle colors or not.
  83815. * Default value : true. The SPS is faster when it's set to false.
  83816. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83817. */
  83818. /**
  83819. * Gets if `setParticles()` computes the particle colors or not.
  83820. * Default value : true. The SPS is faster when it's set to false.
  83821. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83822. */
  83823. computeParticleColor: boolean;
  83824. /**
  83825. * Gets if `setParticles()` computes the particle textures or not.
  83826. * Default value : true. The SPS is faster when it's set to false.
  83827. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83828. */
  83829. computeParticleTexture: boolean;
  83830. /**
  83831. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83832. * Default value : false. The SPS is faster when it's set to false.
  83833. * Note : the particle custom vertex positions aren't stored values.
  83834. */
  83835. /**
  83836. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83837. * Default value : false. The SPS is faster when it's set to false.
  83838. * Note : the particle custom vertex positions aren't stored values.
  83839. */
  83840. computeParticleVertex: boolean;
  83841. /**
  83842. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83843. */
  83844. /**
  83845. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83846. */
  83847. computeBoundingBox: boolean;
  83848. /**
  83849. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83850. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83851. * Default : `true`
  83852. */
  83853. /**
  83854. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83855. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83856. * Default : `true`
  83857. */
  83858. depthSortParticles: boolean;
  83859. /**
  83860. * This function does nothing. It may be overwritten to set all the particle first values.
  83861. * The SPS doesn't call this function, you may have to call it by your own.
  83862. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83863. */
  83864. initParticles(): void;
  83865. /**
  83866. * This function does nothing. It may be overwritten to recycle a particle.
  83867. * The SPS doesn't call this function, you may have to call it by your own.
  83868. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83869. * @param particle The particle to recycle
  83870. * @returns the recycled particle
  83871. */
  83872. recycleParticle(particle: SolidParticle): SolidParticle;
  83873. /**
  83874. * Updates a particle : this function should be overwritten by the user.
  83875. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83876. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83877. * @example : just set a particle position or velocity and recycle conditions
  83878. * @param particle The particle to update
  83879. * @returns the updated particle
  83880. */
  83881. updateParticle(particle: SolidParticle): SolidParticle;
  83882. /**
  83883. * Updates a vertex of a particle : it can be overwritten by the user.
  83884. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83885. * @param particle the current particle
  83886. * @param vertex the current index of the current particle
  83887. * @param pt the index of the current vertex in the particle shape
  83888. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83889. * @example : just set a vertex particle position
  83890. * @returns the updated vertex
  83891. */
  83892. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83893. /**
  83894. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83895. * This does nothing and may be overwritten by the user.
  83896. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83897. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83898. * @param update the boolean update value actually passed to setParticles()
  83899. */
  83900. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83901. /**
  83902. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83903. * This will be passed three parameters.
  83904. * This does nothing and may be overwritten by the user.
  83905. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83906. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83907. * @param update the boolean update value actually passed to setParticles()
  83908. */
  83909. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83910. }
  83911. }
  83912. declare module BABYLON {
  83913. /**
  83914. * Represents one particle of a solid particle system.
  83915. */
  83916. export class SolidParticle {
  83917. /**
  83918. * particle global index
  83919. */
  83920. idx: number;
  83921. /**
  83922. * The color of the particle
  83923. */
  83924. color: Nullable<Color4>;
  83925. /**
  83926. * The world space position of the particle.
  83927. */
  83928. position: Vector3;
  83929. /**
  83930. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83931. */
  83932. rotation: Vector3;
  83933. /**
  83934. * The world space rotation quaternion of the particle.
  83935. */
  83936. rotationQuaternion: Nullable<Quaternion>;
  83937. /**
  83938. * The scaling of the particle.
  83939. */
  83940. scaling: Vector3;
  83941. /**
  83942. * The uvs of the particle.
  83943. */
  83944. uvs: Vector4;
  83945. /**
  83946. * The current speed of the particle.
  83947. */
  83948. velocity: Vector3;
  83949. /**
  83950. * The pivot point in the particle local space.
  83951. */
  83952. pivot: Vector3;
  83953. /**
  83954. * Must the particle be translated from its pivot point in its local space ?
  83955. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83956. * Default : false
  83957. */
  83958. translateFromPivot: boolean;
  83959. /**
  83960. * Is the particle active or not ?
  83961. */
  83962. alive: boolean;
  83963. /**
  83964. * Is the particle visible or not ?
  83965. */
  83966. isVisible: boolean;
  83967. /**
  83968. * Index of this particle in the global "positions" array (Internal use)
  83969. * @hidden
  83970. */
  83971. _pos: number;
  83972. /**
  83973. * @hidden Index of this particle in the global "indices" array (Internal use)
  83974. */
  83975. _ind: number;
  83976. /**
  83977. * @hidden ModelShape of this particle (Internal use)
  83978. */
  83979. _model: ModelShape;
  83980. /**
  83981. * ModelShape id of this particle
  83982. */
  83983. shapeId: number;
  83984. /**
  83985. * Index of the particle in its shape id (Internal use)
  83986. */
  83987. idxInShape: number;
  83988. /**
  83989. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  83990. */
  83991. _modelBoundingInfo: BoundingInfo;
  83992. /**
  83993. * @hidden Particle BoundingInfo object (Internal use)
  83994. */
  83995. _boundingInfo: BoundingInfo;
  83996. /**
  83997. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  83998. */
  83999. _sps: SolidParticleSystem;
  84000. /**
  84001. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  84002. */
  84003. _stillInvisible: boolean;
  84004. /**
  84005. * @hidden Last computed particle rotation matrix
  84006. */
  84007. _rotationMatrix: number[];
  84008. /**
  84009. * Parent particle Id, if any.
  84010. * Default null.
  84011. */
  84012. parentId: Nullable<number>;
  84013. /**
  84014. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  84015. * The possible values are :
  84016. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84017. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84018. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84019. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84020. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84021. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  84022. * */
  84023. cullingStrategy: number;
  84024. /**
  84025. * @hidden Internal global position in the SPS.
  84026. */
  84027. _globalPosition: Vector3;
  84028. /**
  84029. * Creates a Solid Particle object.
  84030. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  84031. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  84032. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  84033. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  84034. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  84035. * @param shapeId (integer) is the model shape identifier in the SPS.
  84036. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  84037. * @param sps defines the sps it is associated to
  84038. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  84039. */
  84040. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  84041. /**
  84042. * Legacy support, changed scale to scaling
  84043. */
  84044. /**
  84045. * Legacy support, changed scale to scaling
  84046. */
  84047. scale: Vector3;
  84048. /**
  84049. * Legacy support, changed quaternion to rotationQuaternion
  84050. */
  84051. /**
  84052. * Legacy support, changed quaternion to rotationQuaternion
  84053. */
  84054. quaternion: Nullable<Quaternion>;
  84055. /**
  84056. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  84057. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  84058. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  84059. * @returns true if it intersects
  84060. */
  84061. intersectsMesh(target: Mesh | SolidParticle): boolean;
  84062. /**
  84063. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  84064. * A particle is in the frustum if its bounding box intersects the frustum
  84065. * @param frustumPlanes defines the frustum to test
  84066. * @returns true if the particle is in the frustum planes
  84067. */
  84068. isInFrustum(frustumPlanes: Plane[]): boolean;
  84069. /**
  84070. * get the rotation matrix of the particle
  84071. * @hidden
  84072. */
  84073. getRotationMatrix(m: Matrix): void;
  84074. }
  84075. /**
  84076. * Represents the shape of the model used by one particle of a solid particle system.
  84077. * SPS internal tool, don't use it manually.
  84078. */
  84079. export class ModelShape {
  84080. /**
  84081. * The shape id
  84082. * @hidden
  84083. */
  84084. shapeID: number;
  84085. /**
  84086. * flat array of model positions (internal use)
  84087. * @hidden
  84088. */
  84089. _shape: Vector3[];
  84090. /**
  84091. * flat array of model UVs (internal use)
  84092. * @hidden
  84093. */
  84094. _shapeUV: number[];
  84095. /**
  84096. * length of the shape in the model indices array (internal use)
  84097. * @hidden
  84098. */
  84099. _indicesLength: number;
  84100. /**
  84101. * Custom position function (internal use)
  84102. * @hidden
  84103. */
  84104. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  84105. /**
  84106. * Custom vertex function (internal use)
  84107. * @hidden
  84108. */
  84109. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  84110. /**
  84111. * 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.
  84112. * SPS internal tool, don't use it manually.
  84113. * @hidden
  84114. */
  84115. 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>);
  84116. }
  84117. /**
  84118. * Represents a Depth Sorted Particle in the solid particle system.
  84119. */
  84120. export class DepthSortedParticle {
  84121. /**
  84122. * Index of the particle in the "indices" array
  84123. */
  84124. ind: number;
  84125. /**
  84126. * Length of the particle shape in the "indices" array
  84127. */
  84128. indicesLength: number;
  84129. /**
  84130. * Squared distance from the particle to the camera
  84131. */
  84132. sqDistance: number;
  84133. }
  84134. }
  84135. declare module BABYLON {
  84136. /**
  84137. * Class used to store all common mesh properties
  84138. */
  84139. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  84140. /** No occlusion */
  84141. static OCCLUSION_TYPE_NONE: number;
  84142. /** Occlusion set to optimisitic */
  84143. static OCCLUSION_TYPE_OPTIMISTIC: number;
  84144. /** Occlusion set to strict */
  84145. static OCCLUSION_TYPE_STRICT: number;
  84146. /** Use an accurante occlusion algorithm */
  84147. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  84148. /** Use a conservative occlusion algorithm */
  84149. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  84150. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  84151. * Test order :
  84152. * Is the bounding sphere outside the frustum ?
  84153. * If not, are the bounding box vertices outside the frustum ?
  84154. * It not, then the cullable object is in the frustum.
  84155. */
  84156. static readonly CULLINGSTRATEGY_STANDARD: number;
  84157. /** Culling strategy : Bounding Sphere Only.
  84158. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  84159. * It's also less accurate than the standard because some not visible objects can still be selected.
  84160. * Test : is the bounding sphere outside the frustum ?
  84161. * If not, then the cullable object is in the frustum.
  84162. */
  84163. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  84164. /** Culling strategy : Optimistic Inclusion.
  84165. * This in an inclusion test first, then the standard exclusion test.
  84166. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  84167. * 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.
  84168. * Anyway, it's as accurate as the standard strategy.
  84169. * Test :
  84170. * Is the cullable object bounding sphere center in the frustum ?
  84171. * If not, apply the default culling strategy.
  84172. */
  84173. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  84174. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  84175. * This in an inclusion test first, then the bounding sphere only exclusion test.
  84176. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  84177. * 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.
  84178. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  84179. * Test :
  84180. * Is the cullable object bounding sphere center in the frustum ?
  84181. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  84182. */
  84183. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  84184. /**
  84185. * No billboard
  84186. */
  84187. static readonly BILLBOARDMODE_NONE: number;
  84188. /** Billboard on X axis */
  84189. static readonly BILLBOARDMODE_X: number;
  84190. /** Billboard on Y axis */
  84191. static readonly BILLBOARDMODE_Y: number;
  84192. /** Billboard on Z axis */
  84193. static readonly BILLBOARDMODE_Z: number;
  84194. /** Billboard on all axes */
  84195. static readonly BILLBOARDMODE_ALL: number;
  84196. private _facetData;
  84197. /**
  84198. * The culling strategy to use to check whether the mesh must be rendered or not.
  84199. * This value can be changed at any time and will be used on the next render mesh selection.
  84200. * The possible values are :
  84201. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84202. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84203. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84204. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84205. * Please read each static variable documentation to get details about the culling process.
  84206. * */
  84207. cullingStrategy: number;
  84208. /**
  84209. * Gets the number of facets in the mesh
  84210. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84211. */
  84212. readonly facetNb: number;
  84213. /**
  84214. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  84215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84216. */
  84217. partitioningSubdivisions: number;
  84218. /**
  84219. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  84220. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  84221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84222. */
  84223. partitioningBBoxRatio: number;
  84224. /**
  84225. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  84226. * Works only for updatable meshes.
  84227. * Doesn't work with multi-materials
  84228. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84229. */
  84230. mustDepthSortFacets: boolean;
  84231. /**
  84232. * The location (Vector3) where the facet depth sort must be computed from.
  84233. * By default, the active camera position.
  84234. * Used only when facet depth sort is enabled
  84235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84236. */
  84237. facetDepthSortFrom: Vector3;
  84238. /**
  84239. * gets a boolean indicating if facetData is enabled
  84240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84241. */
  84242. readonly isFacetDataEnabled: boolean;
  84243. /** @hidden */
  84244. _updateNonUniformScalingState(value: boolean): boolean;
  84245. /**
  84246. * An event triggered when this mesh collides with another one
  84247. */
  84248. onCollideObservable: Observable<AbstractMesh>;
  84249. private _onCollideObserver;
  84250. /** Set a function to call when this mesh collides with another one */
  84251. onCollide: () => void;
  84252. /**
  84253. * An event triggered when the collision's position changes
  84254. */
  84255. onCollisionPositionChangeObservable: Observable<Vector3>;
  84256. private _onCollisionPositionChangeObserver;
  84257. /** Set a function to call when the collision's position changes */
  84258. onCollisionPositionChange: () => void;
  84259. /**
  84260. * An event triggered when material is changed
  84261. */
  84262. onMaterialChangedObservable: Observable<AbstractMesh>;
  84263. /**
  84264. * Gets or sets the orientation for POV movement & rotation
  84265. */
  84266. definedFacingForward: boolean;
  84267. /** @hidden */
  84268. _occlusionQuery: Nullable<WebGLQuery>;
  84269. private _visibility;
  84270. /** @hidden */
  84271. _isActive: boolean;
  84272. /** @hidden */
  84273. _onlyForInstances: boolean;
  84274. /** @hidden */
  84275. _renderingGroup: Nullable<RenderingGroup>;
  84276. /**
  84277. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84278. */
  84279. /**
  84280. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84281. */
  84282. visibility: number;
  84283. /** Gets or sets the alpha index used to sort transparent meshes
  84284. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  84285. */
  84286. alphaIndex: number;
  84287. /**
  84288. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  84289. */
  84290. isVisible: boolean;
  84291. /**
  84292. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84293. */
  84294. isPickable: boolean;
  84295. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  84296. showSubMeshesBoundingBox: boolean;
  84297. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  84298. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  84299. */
  84300. isBlocker: boolean;
  84301. /**
  84302. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  84303. */
  84304. enablePointerMoveEvents: boolean;
  84305. /**
  84306. * Specifies the rendering group id for this mesh (0 by default)
  84307. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84308. */
  84309. renderingGroupId: number;
  84310. private _material;
  84311. /** Gets or sets current material */
  84312. material: Nullable<Material>;
  84313. private _receiveShadows;
  84314. /**
  84315. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84316. * @see http://doc.babylonjs.com/babylon101/shadows
  84317. */
  84318. receiveShadows: boolean;
  84319. /** Defines color to use when rendering outline */
  84320. outlineColor: Color3;
  84321. /** Define width to use when rendering outline */
  84322. outlineWidth: number;
  84323. /** Defines color to use when rendering overlay */
  84324. overlayColor: Color3;
  84325. /** Defines alpha to use when rendering overlay */
  84326. overlayAlpha: number;
  84327. private _hasVertexAlpha;
  84328. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84329. hasVertexAlpha: boolean;
  84330. private _useVertexColors;
  84331. /** 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) */
  84332. useVertexColors: boolean;
  84333. private _computeBonesUsingShaders;
  84334. /**
  84335. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  84336. */
  84337. computeBonesUsingShaders: boolean;
  84338. private _numBoneInfluencers;
  84339. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84340. numBoneInfluencers: number;
  84341. private _applyFog;
  84342. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84343. applyFog: boolean;
  84344. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  84345. useOctreeForRenderingSelection: boolean;
  84346. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  84347. useOctreeForPicking: boolean;
  84348. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  84349. useOctreeForCollisions: boolean;
  84350. private _layerMask;
  84351. /**
  84352. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84353. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84354. */
  84355. layerMask: number;
  84356. /**
  84357. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  84358. */
  84359. alwaysSelectAsActiveMesh: boolean;
  84360. /**
  84361. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  84362. */
  84363. doNotSyncBoundingInfo: boolean;
  84364. /**
  84365. * Gets or sets the current action manager
  84366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84367. */
  84368. actionManager: Nullable<AbstractActionManager>;
  84369. private _checkCollisions;
  84370. private _collisionMask;
  84371. private _collisionGroup;
  84372. /**
  84373. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  84374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84375. */
  84376. ellipsoid: Vector3;
  84377. /**
  84378. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  84379. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84380. */
  84381. ellipsoidOffset: Vector3;
  84382. private _collider;
  84383. private _oldPositionForCollisions;
  84384. private _diffPositionForCollisions;
  84385. /**
  84386. * Gets or sets a collision mask used to mask collisions (default is -1).
  84387. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84388. */
  84389. collisionMask: number;
  84390. /**
  84391. * Gets or sets the current collision group mask (-1 by default).
  84392. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84393. */
  84394. collisionGroup: number;
  84395. /**
  84396. * Defines edge width used when edgesRenderer is enabled
  84397. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84398. */
  84399. edgesWidth: number;
  84400. /**
  84401. * Defines edge color used when edgesRenderer is enabled
  84402. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84403. */
  84404. edgesColor: Color4;
  84405. /** @hidden */
  84406. _edgesRenderer: Nullable<IEdgesRenderer>;
  84407. /** @hidden */
  84408. _masterMesh: Nullable<AbstractMesh>;
  84409. /** @hidden */
  84410. _boundingInfo: Nullable<BoundingInfo>;
  84411. /** @hidden */
  84412. _renderId: number;
  84413. /**
  84414. * Gets or sets the list of subMeshes
  84415. * @see http://doc.babylonjs.com/how_to/multi_materials
  84416. */
  84417. subMeshes: SubMesh[];
  84418. /** @hidden */
  84419. _intersectionsInProgress: AbstractMesh[];
  84420. /** @hidden */
  84421. _unIndexed: boolean;
  84422. /** @hidden */
  84423. _lightSources: Light[];
  84424. /** Gets the list of lights affecting that mesh */
  84425. readonly lightSources: Light[];
  84426. /** @hidden */
  84427. readonly _positions: Nullable<Vector3[]>;
  84428. /** @hidden */
  84429. _waitingActions: Nullable<any>;
  84430. /** @hidden */
  84431. _waitingFreezeWorldMatrix: Nullable<boolean>;
  84432. private _skeleton;
  84433. /** @hidden */
  84434. _bonesTransformMatrices: Nullable<Float32Array>;
  84435. /**
  84436. * Gets or sets a skeleton to apply skining transformations
  84437. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84438. */
  84439. skeleton: Nullable<Skeleton>;
  84440. /**
  84441. * An event triggered when the mesh is rebuilt.
  84442. */
  84443. onRebuildObservable: Observable<AbstractMesh>;
  84444. /**
  84445. * Creates a new AbstractMesh
  84446. * @param name defines the name of the mesh
  84447. * @param scene defines the hosting scene
  84448. */
  84449. constructor(name: string, scene?: Nullable<Scene>);
  84450. /**
  84451. * Returns the string "AbstractMesh"
  84452. * @returns "AbstractMesh"
  84453. */
  84454. getClassName(): string;
  84455. /**
  84456. * Gets a string representation of the current mesh
  84457. * @param fullDetails defines a boolean indicating if full details must be included
  84458. * @returns a string representation of the current mesh
  84459. */
  84460. toString(fullDetails?: boolean): string;
  84461. /**
  84462. * @hidden
  84463. */
  84464. protected _getEffectiveParent(): Nullable<Node>;
  84465. /** @hidden */
  84466. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84467. /** @hidden */
  84468. _rebuild(): void;
  84469. /** @hidden */
  84470. _resyncLightSources(): void;
  84471. /** @hidden */
  84472. _resyncLighSource(light: Light): void;
  84473. /** @hidden */
  84474. _unBindEffect(): void;
  84475. /** @hidden */
  84476. _removeLightSource(light: Light): void;
  84477. private _markSubMeshesAsDirty;
  84478. /** @hidden */
  84479. _markSubMeshesAsLightDirty(): void;
  84480. /** @hidden */
  84481. _markSubMeshesAsAttributesDirty(): void;
  84482. /** @hidden */
  84483. _markSubMeshesAsMiscDirty(): void;
  84484. /**
  84485. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84486. */
  84487. scaling: Vector3;
  84488. /**
  84489. * Returns true if the mesh is blocked. Implemented by child classes
  84490. */
  84491. readonly isBlocked: boolean;
  84492. /**
  84493. * Returns the mesh itself by default. Implemented by child classes
  84494. * @param camera defines the camera to use to pick the right LOD level
  84495. * @returns the currentAbstractMesh
  84496. */
  84497. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84498. /**
  84499. * Returns 0 by default. Implemented by child classes
  84500. * @returns an integer
  84501. */
  84502. getTotalVertices(): number;
  84503. /**
  84504. * Returns a positive integer : the total number of indices in this mesh geometry.
  84505. * @returns the numner of indices or zero if the mesh has no geometry.
  84506. */
  84507. getTotalIndices(): number;
  84508. /**
  84509. * Returns null by default. Implemented by child classes
  84510. * @returns null
  84511. */
  84512. getIndices(): Nullable<IndicesArray>;
  84513. /**
  84514. * Returns the array of the requested vertex data kind. Implemented by child classes
  84515. * @param kind defines the vertex data kind to use
  84516. * @returns null
  84517. */
  84518. getVerticesData(kind: string): Nullable<FloatArray>;
  84519. /**
  84520. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84521. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84522. * Note that a new underlying VertexBuffer object is created each call.
  84523. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84524. * @param kind defines vertex data kind:
  84525. * * VertexBuffer.PositionKind
  84526. * * VertexBuffer.UVKind
  84527. * * VertexBuffer.UV2Kind
  84528. * * VertexBuffer.UV3Kind
  84529. * * VertexBuffer.UV4Kind
  84530. * * VertexBuffer.UV5Kind
  84531. * * VertexBuffer.UV6Kind
  84532. * * VertexBuffer.ColorKind
  84533. * * VertexBuffer.MatricesIndicesKind
  84534. * * VertexBuffer.MatricesIndicesExtraKind
  84535. * * VertexBuffer.MatricesWeightsKind
  84536. * * VertexBuffer.MatricesWeightsExtraKind
  84537. * @param data defines the data source
  84538. * @param updatable defines if the data must be flagged as updatable (or static)
  84539. * @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
  84540. * @returns the current mesh
  84541. */
  84542. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84543. /**
  84544. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84545. * If the mesh has no geometry, it is simply returned as it is.
  84546. * @param kind defines vertex data kind:
  84547. * * VertexBuffer.PositionKind
  84548. * * VertexBuffer.UVKind
  84549. * * VertexBuffer.UV2Kind
  84550. * * VertexBuffer.UV3Kind
  84551. * * VertexBuffer.UV4Kind
  84552. * * VertexBuffer.UV5Kind
  84553. * * VertexBuffer.UV6Kind
  84554. * * VertexBuffer.ColorKind
  84555. * * VertexBuffer.MatricesIndicesKind
  84556. * * VertexBuffer.MatricesIndicesExtraKind
  84557. * * VertexBuffer.MatricesWeightsKind
  84558. * * VertexBuffer.MatricesWeightsExtraKind
  84559. * @param data defines the data source
  84560. * @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
  84561. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84562. * @returns the current mesh
  84563. */
  84564. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84565. /**
  84566. * Sets the mesh indices,
  84567. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84568. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84569. * @param totalVertices Defines the total number of vertices
  84570. * @returns the current mesh
  84571. */
  84572. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84573. /**
  84574. * Gets a boolean indicating if specific vertex data is present
  84575. * @param kind defines the vertex data kind to use
  84576. * @returns true is data kind is present
  84577. */
  84578. isVerticesDataPresent(kind: string): boolean;
  84579. /**
  84580. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84581. * @returns a BoundingInfo
  84582. */
  84583. getBoundingInfo(): BoundingInfo;
  84584. /**
  84585. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84586. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84587. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84588. * @returns the current mesh
  84589. */
  84590. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84591. /**
  84592. * Overwrite the current bounding info
  84593. * @param boundingInfo defines the new bounding info
  84594. * @returns the current mesh
  84595. */
  84596. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84597. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84598. readonly useBones: boolean;
  84599. /** @hidden */
  84600. _preActivate(): void;
  84601. /** @hidden */
  84602. _preActivateForIntermediateRendering(renderId: number): void;
  84603. /** @hidden */
  84604. _activate(renderId: number): boolean;
  84605. /** @hidden */
  84606. _freeze(): void;
  84607. /** @hidden */
  84608. _unFreeze(): void;
  84609. /**
  84610. * Gets the current world matrix
  84611. * @returns a Matrix
  84612. */
  84613. getWorldMatrix(): Matrix;
  84614. /** @hidden */
  84615. _getWorldMatrixDeterminant(): number;
  84616. /**
  84617. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  84618. */
  84619. readonly isAnInstance: boolean;
  84620. /**
  84621. * Perform relative position change from the point of view of behind the front of the mesh.
  84622. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84623. * Supports definition of mesh facing forward or backward
  84624. * @param amountRight defines the distance on the right axis
  84625. * @param amountUp defines the distance on the up axis
  84626. * @param amountForward defines the distance on the forward axis
  84627. * @returns the current mesh
  84628. */
  84629. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84630. /**
  84631. * Calculate relative position change from the point of view of behind the front of the mesh.
  84632. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84633. * Supports definition of mesh facing forward or backward
  84634. * @param amountRight defines the distance on the right axis
  84635. * @param amountUp defines the distance on the up axis
  84636. * @param amountForward defines the distance on the forward axis
  84637. * @returns the new displacement vector
  84638. */
  84639. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84640. /**
  84641. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84642. * Supports definition of mesh facing forward or backward
  84643. * @param flipBack defines the flip
  84644. * @param twirlClockwise defines the twirl
  84645. * @param tiltRight defines the tilt
  84646. * @returns the current mesh
  84647. */
  84648. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84649. /**
  84650. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84651. * Supports definition of mesh facing forward or backward.
  84652. * @param flipBack defines the flip
  84653. * @param twirlClockwise defines the twirl
  84654. * @param tiltRight defines the tilt
  84655. * @returns the new rotation vector
  84656. */
  84657. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84658. /**
  84659. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84660. * This means the mesh underlying bounding box and sphere are recomputed.
  84661. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84662. * @returns the current mesh
  84663. */
  84664. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84665. /** @hidden */
  84666. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84667. /** @hidden */
  84668. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84669. /** @hidden */
  84670. _updateBoundingInfo(): AbstractMesh;
  84671. /** @hidden */
  84672. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84673. /** @hidden */
  84674. protected _afterComputeWorldMatrix(): void;
  84675. /** @hidden */
  84676. readonly _effectiveMesh: AbstractMesh;
  84677. /**
  84678. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84679. * A mesh is in the frustum if its bounding box intersects the frustum
  84680. * @param frustumPlanes defines the frustum to test
  84681. * @returns true if the mesh is in the frustum planes
  84682. */
  84683. isInFrustum(frustumPlanes: Plane[]): boolean;
  84684. /**
  84685. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84686. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84687. * @param frustumPlanes defines the frustum to test
  84688. * @returns true if the mesh is completely in the frustum planes
  84689. */
  84690. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84691. /**
  84692. * True if the mesh intersects another mesh or a SolidParticle object
  84693. * @param mesh defines a target mesh or SolidParticle to test
  84694. * @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)
  84695. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84696. * @returns true if there is an intersection
  84697. */
  84698. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84699. /**
  84700. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84701. * @param point defines the point to test
  84702. * @returns true if there is an intersection
  84703. */
  84704. intersectsPoint(point: Vector3): boolean;
  84705. /**
  84706. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84707. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84708. */
  84709. checkCollisions: boolean;
  84710. /**
  84711. * Gets Collider object used to compute collisions (not physics)
  84712. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84713. */
  84714. readonly collider: Nullable<Collider>;
  84715. /**
  84716. * Move the mesh using collision engine
  84717. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84718. * @param displacement defines the requested displacement vector
  84719. * @returns the current mesh
  84720. */
  84721. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84722. private _onCollisionPositionChange;
  84723. /** @hidden */
  84724. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84725. /** @hidden */
  84726. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84727. /** @hidden */
  84728. _checkCollision(collider: Collider): AbstractMesh;
  84729. /** @hidden */
  84730. _generatePointsArray(): boolean;
  84731. /**
  84732. * Checks if the passed Ray intersects with the mesh
  84733. * @param ray defines the ray to use
  84734. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84735. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84736. * @returns the picking info
  84737. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84738. */
  84739. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84740. /**
  84741. * Clones the current mesh
  84742. * @param name defines the mesh name
  84743. * @param newParent defines the new mesh parent
  84744. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84745. * @returns the new mesh
  84746. */
  84747. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84748. /**
  84749. * Disposes all the submeshes of the current meshnp
  84750. * @returns the current mesh
  84751. */
  84752. releaseSubMeshes(): AbstractMesh;
  84753. /**
  84754. * Releases resources associated with this abstract mesh.
  84755. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84756. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84757. */
  84758. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84759. /**
  84760. * Adds the passed mesh as a child to the current mesh
  84761. * @param mesh defines the child mesh
  84762. * @returns the current mesh
  84763. */
  84764. addChild(mesh: AbstractMesh): AbstractMesh;
  84765. /**
  84766. * Removes the passed mesh from the current mesh children list
  84767. * @param mesh defines the child mesh
  84768. * @returns the current mesh
  84769. */
  84770. removeChild(mesh: AbstractMesh): AbstractMesh;
  84771. /** @hidden */
  84772. private _initFacetData;
  84773. /**
  84774. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84775. * This method can be called within the render loop.
  84776. * 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
  84777. * @returns the current mesh
  84778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84779. */
  84780. updateFacetData(): AbstractMesh;
  84781. /**
  84782. * Returns the facetLocalNormals array.
  84783. * The normals are expressed in the mesh local spac
  84784. * @returns an array of Vector3
  84785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84786. */
  84787. getFacetLocalNormals(): Vector3[];
  84788. /**
  84789. * Returns the facetLocalPositions array.
  84790. * The facet positions are expressed in the mesh local space
  84791. * @returns an array of Vector3
  84792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84793. */
  84794. getFacetLocalPositions(): Vector3[];
  84795. /**
  84796. * Returns the facetLocalPartioning array
  84797. * @returns an array of array of numbers
  84798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84799. */
  84800. getFacetLocalPartitioning(): number[][];
  84801. /**
  84802. * Returns the i-th facet position in the world system.
  84803. * This method allocates a new Vector3 per call
  84804. * @param i defines the facet index
  84805. * @returns a new Vector3
  84806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84807. */
  84808. getFacetPosition(i: number): Vector3;
  84809. /**
  84810. * Sets the reference Vector3 with the i-th facet position in the world system
  84811. * @param i defines the facet index
  84812. * @param ref defines the target vector
  84813. * @returns the current mesh
  84814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84815. */
  84816. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84817. /**
  84818. * Returns the i-th facet normal in the world system.
  84819. * This method allocates a new Vector3 per call
  84820. * @param i defines the facet index
  84821. * @returns a new Vector3
  84822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84823. */
  84824. getFacetNormal(i: number): Vector3;
  84825. /**
  84826. * Sets the reference Vector3 with the i-th facet normal in the world system
  84827. * @param i defines the facet index
  84828. * @param ref defines the target vector
  84829. * @returns the current mesh
  84830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84831. */
  84832. getFacetNormalToRef(i: number, ref: Vector3): this;
  84833. /**
  84834. * 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)
  84835. * @param x defines x coordinate
  84836. * @param y defines y coordinate
  84837. * @param z defines z coordinate
  84838. * @returns the array of facet indexes
  84839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84840. */
  84841. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  84842. /**
  84843. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  84844. * @param projected sets as the (x,y,z) world projection on the facet
  84845. * @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
  84846. * @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
  84847. * @param x defines x coordinate
  84848. * @param y defines y coordinate
  84849. * @param z defines z coordinate
  84850. * @returns the face index if found (or null instead)
  84851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84852. */
  84853. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84854. /**
  84855. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  84856. * @param projected sets as the (x,y,z) local projection on the facet
  84857. * @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
  84858. * @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
  84859. * @param x defines x coordinate
  84860. * @param y defines y coordinate
  84861. * @param z defines z coordinate
  84862. * @returns the face index if found (or null instead)
  84863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84864. */
  84865. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84866. /**
  84867. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  84868. * @returns the parameters
  84869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84870. */
  84871. getFacetDataParameters(): any;
  84872. /**
  84873. * Disables the feature FacetData and frees the related memory
  84874. * @returns the current mesh
  84875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84876. */
  84877. disableFacetData(): AbstractMesh;
  84878. /**
  84879. * Updates the AbstractMesh indices array
  84880. * @param indices defines the data source
  84881. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84882. * @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)
  84883. * @returns the current mesh
  84884. */
  84885. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  84886. /**
  84887. * Creates new normals data for the mesh
  84888. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84889. * @returns the current mesh
  84890. */
  84891. createNormals(updatable: boolean): AbstractMesh;
  84892. /**
  84893. * Align the mesh with a normal
  84894. * @param normal defines the normal to use
  84895. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84896. * @returns the current mesh
  84897. */
  84898. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84899. /** @hidden */
  84900. _checkOcclusionQuery(): boolean;
  84901. }
  84902. }
  84903. declare module BABYLON {
  84904. /**
  84905. * Interface used to define ActionEvent
  84906. */
  84907. export interface IActionEvent {
  84908. /** The mesh or sprite that triggered the action */
  84909. source: any;
  84910. /** The X mouse cursor position at the time of the event */
  84911. pointerX: number;
  84912. /** The Y mouse cursor position at the time of the event */
  84913. pointerY: number;
  84914. /** The mesh that is currently pointed at (can be null) */
  84915. meshUnderPointer: Nullable<AbstractMesh>;
  84916. /** the original (browser) event that triggered the ActionEvent */
  84917. sourceEvent?: any;
  84918. /** additional data for the event */
  84919. additionalData?: any;
  84920. }
  84921. /**
  84922. * ActionEvent is the event being sent when an action is triggered.
  84923. */
  84924. export class ActionEvent implements IActionEvent {
  84925. /** The mesh or sprite that triggered the action */
  84926. source: any;
  84927. /** The X mouse cursor position at the time of the event */
  84928. pointerX: number;
  84929. /** The Y mouse cursor position at the time of the event */
  84930. pointerY: number;
  84931. /** The mesh that is currently pointed at (can be null) */
  84932. meshUnderPointer: Nullable<AbstractMesh>;
  84933. /** the original (browser) event that triggered the ActionEvent */
  84934. sourceEvent?: any;
  84935. /** additional data for the event */
  84936. additionalData?: any;
  84937. /**
  84938. * Creates a new ActionEvent
  84939. * @param source The mesh or sprite that triggered the action
  84940. * @param pointerX The X mouse cursor position at the time of the event
  84941. * @param pointerY The Y mouse cursor position at the time of the event
  84942. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84943. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84944. * @param additionalData additional data for the event
  84945. */
  84946. constructor(
  84947. /** The mesh or sprite that triggered the action */
  84948. source: any,
  84949. /** The X mouse cursor position at the time of the event */
  84950. pointerX: number,
  84951. /** The Y mouse cursor position at the time of the event */
  84952. pointerY: number,
  84953. /** The mesh that is currently pointed at (can be null) */
  84954. meshUnderPointer: Nullable<AbstractMesh>,
  84955. /** the original (browser) event that triggered the ActionEvent */
  84956. sourceEvent?: any,
  84957. /** additional data for the event */
  84958. additionalData?: any);
  84959. /**
  84960. * Helper function to auto-create an ActionEvent from a source mesh.
  84961. * @param source The source mesh that triggered the event
  84962. * @param evt The original (browser) event
  84963. * @param additionalData additional data for the event
  84964. * @returns the new ActionEvent
  84965. */
  84966. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84967. /**
  84968. * Helper function to auto-create an ActionEvent from a source sprite
  84969. * @param source The source sprite that triggered the event
  84970. * @param scene Scene associated with the sprite
  84971. * @param evt The original (browser) event
  84972. * @param additionalData additional data for the event
  84973. * @returns the new ActionEvent
  84974. */
  84975. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84976. /**
  84977. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84978. * @param scene the scene where the event occurred
  84979. * @param evt The original (browser) event
  84980. * @returns the new ActionEvent
  84981. */
  84982. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  84983. /**
  84984. * Helper function to auto-create an ActionEvent from a primitive
  84985. * @param prim defines the target primitive
  84986. * @param pointerPos defines the pointer position
  84987. * @param evt The original (browser) event
  84988. * @param additionalData additional data for the event
  84989. * @returns the new ActionEvent
  84990. */
  84991. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  84992. }
  84993. }
  84994. declare module BABYLON {
  84995. /**
  84996. * Abstract class used to decouple action Manager from scene and meshes.
  84997. * Do not instantiate.
  84998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84999. */
  85000. export abstract class AbstractActionManager implements IDisposable {
  85001. /** Gets the list of active triggers */
  85002. static Triggers: {
  85003. [key: string]: number;
  85004. };
  85005. /** Gets the cursor to use when hovering items */
  85006. hoverCursor: string;
  85007. /** Gets the list of actions */
  85008. actions: IAction[];
  85009. /**
  85010. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  85011. */
  85012. isRecursive: boolean;
  85013. /**
  85014. * Releases all associated resources
  85015. */
  85016. abstract dispose(): void;
  85017. /**
  85018. * Does this action manager has pointer triggers
  85019. */
  85020. abstract readonly hasPointerTriggers: boolean;
  85021. /**
  85022. * Does this action manager has pick triggers
  85023. */
  85024. abstract readonly hasPickTriggers: boolean;
  85025. /**
  85026. * Process a specific trigger
  85027. * @param trigger defines the trigger to process
  85028. * @param evt defines the event details to be processed
  85029. */
  85030. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  85031. /**
  85032. * Does this action manager handles actions of any of the given triggers
  85033. * @param triggers defines the triggers to be tested
  85034. * @return a boolean indicating whether one (or more) of the triggers is handled
  85035. */
  85036. abstract hasSpecificTriggers(triggers: number[]): boolean;
  85037. /**
  85038. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  85039. * speed.
  85040. * @param triggerA defines the trigger to be tested
  85041. * @param triggerB defines the trigger to be tested
  85042. * @return a boolean indicating whether one (or more) of the triggers is handled
  85043. */
  85044. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  85045. /**
  85046. * Does this action manager handles actions of a given trigger
  85047. * @param trigger defines the trigger to be tested
  85048. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  85049. * @return whether the trigger is handled
  85050. */
  85051. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  85052. /**
  85053. * Serialize this manager to a JSON object
  85054. * @param name defines the property name to store this manager
  85055. * @returns a JSON representation of this manager
  85056. */
  85057. abstract serialize(name: string): any;
  85058. /**
  85059. * Registers an action to this action manager
  85060. * @param action defines the action to be registered
  85061. * @return the action amended (prepared) after registration
  85062. */
  85063. abstract registerAction(action: IAction): Nullable<IAction>;
  85064. /**
  85065. * Unregisters an action to this action manager
  85066. * @param action defines the action to be unregistered
  85067. * @return a boolean indicating whether the action has been unregistered
  85068. */
  85069. abstract unregisterAction(action: IAction): Boolean;
  85070. /**
  85071. * Does exist one action manager with at least one trigger
  85072. **/
  85073. static readonly HasTriggers: boolean;
  85074. /**
  85075. * Does exist one action manager with at least one pick trigger
  85076. **/
  85077. static readonly HasPickTriggers: boolean;
  85078. /**
  85079. * Does exist one action manager that handles actions of a given trigger
  85080. * @param trigger defines the trigger to be tested
  85081. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  85082. **/
  85083. static HasSpecificTrigger(trigger: number): boolean;
  85084. }
  85085. }
  85086. declare module BABYLON {
  85087. /**
  85088. * Defines how a node can be built from a string name.
  85089. */
  85090. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  85091. /**
  85092. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  85093. */
  85094. export class Node implements IBehaviorAware<Node> {
  85095. /** @hidden */
  85096. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  85097. private static _NodeConstructors;
  85098. /**
  85099. * Add a new node constructor
  85100. * @param type defines the type name of the node to construct
  85101. * @param constructorFunc defines the constructor function
  85102. */
  85103. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  85104. /**
  85105. * Returns a node constructor based on type name
  85106. * @param type defines the type name
  85107. * @param name defines the new node name
  85108. * @param scene defines the hosting scene
  85109. * @param options defines optional options to transmit to constructors
  85110. * @returns the new constructor or null
  85111. */
  85112. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  85113. /**
  85114. * Gets or sets the name of the node
  85115. */
  85116. name: string;
  85117. /**
  85118. * Gets or sets the id of the node
  85119. */
  85120. id: string;
  85121. /**
  85122. * Gets or sets the unique id of the node
  85123. */
  85124. uniqueId: number;
  85125. /**
  85126. * Gets or sets a string used to store user defined state for the node
  85127. */
  85128. state: string;
  85129. /**
  85130. * Gets or sets an object used to store user defined information for the node
  85131. */
  85132. metadata: any;
  85133. /**
  85134. * For internal use only. Please do not use.
  85135. */
  85136. reservedDataStore: any;
  85137. /**
  85138. * List of inspectable custom properties (used by the Inspector)
  85139. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85140. */
  85141. inspectableCustomProperties: IInspectable[];
  85142. /**
  85143. * Gets or sets a boolean used to define if the node must be serialized
  85144. */
  85145. doNotSerialize: boolean;
  85146. /** @hidden */
  85147. _isDisposed: boolean;
  85148. /**
  85149. * Gets a list of Animations associated with the node
  85150. */
  85151. animations: Animation[];
  85152. protected _ranges: {
  85153. [name: string]: Nullable<AnimationRange>;
  85154. };
  85155. /**
  85156. * Callback raised when the node is ready to be used
  85157. */
  85158. onReady: Nullable<(node: Node) => void>;
  85159. private _isEnabled;
  85160. private _isParentEnabled;
  85161. private _isReady;
  85162. /** @hidden */
  85163. _currentRenderId: number;
  85164. private _parentUpdateId;
  85165. /** @hidden */
  85166. _childUpdateId: number;
  85167. /** @hidden */
  85168. _waitingParentId: Nullable<string>;
  85169. /** @hidden */
  85170. _scene: Scene;
  85171. /** @hidden */
  85172. _cache: any;
  85173. private _parentNode;
  85174. private _children;
  85175. /** @hidden */
  85176. _worldMatrix: Matrix;
  85177. /** @hidden */
  85178. _worldMatrixDeterminant: number;
  85179. /** @hidden */
  85180. _worldMatrixDeterminantIsDirty: boolean;
  85181. /** @hidden */
  85182. private _sceneRootNodesIndex;
  85183. /**
  85184. * Gets a boolean indicating if the node has been disposed
  85185. * @returns true if the node was disposed
  85186. */
  85187. isDisposed(): boolean;
  85188. /**
  85189. * Gets or sets the parent of the node (without keeping the current position in the scene)
  85190. * @see https://doc.babylonjs.com/how_to/parenting
  85191. */
  85192. parent: Nullable<Node>;
  85193. private addToSceneRootNodes;
  85194. private removeFromSceneRootNodes;
  85195. private _animationPropertiesOverride;
  85196. /**
  85197. * Gets or sets the animation properties override
  85198. */
  85199. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85200. /**
  85201. * Gets a string idenfifying the name of the class
  85202. * @returns "Node" string
  85203. */
  85204. getClassName(): string;
  85205. /** @hidden */
  85206. readonly _isNode: boolean;
  85207. /**
  85208. * An event triggered when the mesh is disposed
  85209. */
  85210. onDisposeObservable: Observable<Node>;
  85211. private _onDisposeObserver;
  85212. /**
  85213. * Sets a callback that will be raised when the node will be disposed
  85214. */
  85215. onDispose: () => void;
  85216. /**
  85217. * Creates a new Node
  85218. * @param name the name and id to be given to this node
  85219. * @param scene the scene this node will be added to
  85220. * @param addToRootNodes the node will be added to scene.rootNodes
  85221. */
  85222. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  85223. /**
  85224. * Gets the scene of the node
  85225. * @returns a scene
  85226. */
  85227. getScene(): Scene;
  85228. /**
  85229. * Gets the engine of the node
  85230. * @returns a Engine
  85231. */
  85232. getEngine(): Engine;
  85233. private _behaviors;
  85234. /**
  85235. * Attach a behavior to the node
  85236. * @see http://doc.babylonjs.com/features/behaviour
  85237. * @param behavior defines the behavior to attach
  85238. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  85239. * @returns the current Node
  85240. */
  85241. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  85242. /**
  85243. * Remove an attached behavior
  85244. * @see http://doc.babylonjs.com/features/behaviour
  85245. * @param behavior defines the behavior to attach
  85246. * @returns the current Node
  85247. */
  85248. removeBehavior(behavior: Behavior<Node>): Node;
  85249. /**
  85250. * Gets the list of attached behaviors
  85251. * @see http://doc.babylonjs.com/features/behaviour
  85252. */
  85253. readonly behaviors: Behavior<Node>[];
  85254. /**
  85255. * Gets an attached behavior by name
  85256. * @param name defines the name of the behavior to look for
  85257. * @see http://doc.babylonjs.com/features/behaviour
  85258. * @returns null if behavior was not found else the requested behavior
  85259. */
  85260. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  85261. /**
  85262. * Returns the latest update of the World matrix
  85263. * @returns a Matrix
  85264. */
  85265. getWorldMatrix(): Matrix;
  85266. /** @hidden */
  85267. _getWorldMatrixDeterminant(): number;
  85268. /**
  85269. * Returns directly the latest state of the mesh World matrix.
  85270. * A Matrix is returned.
  85271. */
  85272. readonly worldMatrixFromCache: Matrix;
  85273. /** @hidden */
  85274. _initCache(): void;
  85275. /** @hidden */
  85276. updateCache(force?: boolean): void;
  85277. /** @hidden */
  85278. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  85279. /** @hidden */
  85280. _updateCache(ignoreParentClass?: boolean): void;
  85281. /** @hidden */
  85282. _isSynchronized(): boolean;
  85283. /** @hidden */
  85284. _markSyncedWithParent(): void;
  85285. /** @hidden */
  85286. isSynchronizedWithParent(): boolean;
  85287. /** @hidden */
  85288. isSynchronized(): boolean;
  85289. /**
  85290. * Is this node ready to be used/rendered
  85291. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85292. * @return true if the node is ready
  85293. */
  85294. isReady(completeCheck?: boolean): boolean;
  85295. /**
  85296. * Is this node enabled?
  85297. * 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
  85298. * @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
  85299. * @return whether this node (and its parent) is enabled
  85300. */
  85301. isEnabled(checkAncestors?: boolean): boolean;
  85302. /** @hidden */
  85303. protected _syncParentEnabledState(): void;
  85304. /**
  85305. * Set the enabled state of this node
  85306. * @param value defines the new enabled state
  85307. */
  85308. setEnabled(value: boolean): void;
  85309. /**
  85310. * Is this node a descendant of the given node?
  85311. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  85312. * @param ancestor defines the parent node to inspect
  85313. * @returns a boolean indicating if this node is a descendant of the given node
  85314. */
  85315. isDescendantOf(ancestor: Node): boolean;
  85316. /** @hidden */
  85317. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  85318. /**
  85319. * Will return all nodes that have this node as ascendant
  85320. * @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
  85321. * @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
  85322. * @return all children nodes of all types
  85323. */
  85324. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  85325. /**
  85326. * Get all child-meshes of this node
  85327. * @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)
  85328. * @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
  85329. * @returns an array of AbstractMesh
  85330. */
  85331. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  85332. /**
  85333. * Get all direct children of this node
  85334. * @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
  85335. * @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)
  85336. * @returns an array of Node
  85337. */
  85338. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  85339. /** @hidden */
  85340. _setReady(state: boolean): void;
  85341. /**
  85342. * Get an animation by name
  85343. * @param name defines the name of the animation to look for
  85344. * @returns null if not found else the requested animation
  85345. */
  85346. getAnimationByName(name: string): Nullable<Animation>;
  85347. /**
  85348. * Creates an animation range for this node
  85349. * @param name defines the name of the range
  85350. * @param from defines the starting key
  85351. * @param to defines the end key
  85352. */
  85353. createAnimationRange(name: string, from: number, to: number): void;
  85354. /**
  85355. * Delete a specific animation range
  85356. * @param name defines the name of the range to delete
  85357. * @param deleteFrames defines if animation frames from the range must be deleted as well
  85358. */
  85359. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85360. /**
  85361. * Get an animation range by name
  85362. * @param name defines the name of the animation range to look for
  85363. * @returns null if not found else the requested animation range
  85364. */
  85365. getAnimationRange(name: string): Nullable<AnimationRange>;
  85366. /**
  85367. * Gets the list of all animation ranges defined on this node
  85368. * @returns an array
  85369. */
  85370. getAnimationRanges(): Nullable<AnimationRange>[];
  85371. /**
  85372. * Will start the animation sequence
  85373. * @param name defines the range frames for animation sequence
  85374. * @param loop defines if the animation should loop (false by default)
  85375. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  85376. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  85377. * @returns the object created for this animation. If range does not exist, it will return null
  85378. */
  85379. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85380. /**
  85381. * Serialize animation ranges into a JSON compatible object
  85382. * @returns serialization object
  85383. */
  85384. serializeAnimationRanges(): any;
  85385. /**
  85386. * Computes the world matrix of the node
  85387. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85388. * @returns the world matrix
  85389. */
  85390. computeWorldMatrix(force?: boolean): Matrix;
  85391. /**
  85392. * Releases resources associated with this node.
  85393. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85394. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85395. */
  85396. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85397. /**
  85398. * Parse animation range data from a serialization object and store them into a given node
  85399. * @param node defines where to store the animation ranges
  85400. * @param parsedNode defines the serialization object to read data from
  85401. * @param scene defines the hosting scene
  85402. */
  85403. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  85404. /**
  85405. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  85406. * @param includeDescendants Include bounding info from descendants as well (true by default)
  85407. * @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
  85408. * @returns the new bounding vectors
  85409. */
  85410. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  85411. min: Vector3;
  85412. max: Vector3;
  85413. };
  85414. }
  85415. }
  85416. declare module BABYLON {
  85417. /**
  85418. * @hidden
  85419. */
  85420. export class _IAnimationState {
  85421. key: number;
  85422. repeatCount: number;
  85423. workValue?: any;
  85424. loopMode?: number;
  85425. offsetValue?: any;
  85426. highLimitValue?: any;
  85427. }
  85428. /**
  85429. * Class used to store any kind of animation
  85430. */
  85431. export class Animation {
  85432. /**Name of the animation */
  85433. name: string;
  85434. /**Property to animate */
  85435. targetProperty: string;
  85436. /**The frames per second of the animation */
  85437. framePerSecond: number;
  85438. /**The data type of the animation */
  85439. dataType: number;
  85440. /**The loop mode of the animation */
  85441. loopMode?: number | undefined;
  85442. /**Specifies if blending should be enabled */
  85443. enableBlending?: boolean | undefined;
  85444. /**
  85445. * Use matrix interpolation instead of using direct key value when animating matrices
  85446. */
  85447. static AllowMatricesInterpolation: boolean;
  85448. /**
  85449. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85450. */
  85451. static AllowMatrixDecomposeForInterpolation: boolean;
  85452. /**
  85453. * Stores the key frames of the animation
  85454. */
  85455. private _keys;
  85456. /**
  85457. * Stores the easing function of the animation
  85458. */
  85459. private _easingFunction;
  85460. /**
  85461. * @hidden Internal use only
  85462. */
  85463. _runtimeAnimations: RuntimeAnimation[];
  85464. /**
  85465. * The set of event that will be linked to this animation
  85466. */
  85467. private _events;
  85468. /**
  85469. * Stores an array of target property paths
  85470. */
  85471. targetPropertyPath: string[];
  85472. /**
  85473. * Stores the blending speed of the animation
  85474. */
  85475. blendingSpeed: number;
  85476. /**
  85477. * Stores the animation ranges for the animation
  85478. */
  85479. private _ranges;
  85480. /**
  85481. * @hidden Internal use
  85482. */
  85483. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85484. /**
  85485. * Sets up an animation
  85486. * @param property The property to animate
  85487. * @param animationType The animation type to apply
  85488. * @param framePerSecond The frames per second of the animation
  85489. * @param easingFunction The easing function used in the animation
  85490. * @returns The created animation
  85491. */
  85492. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85493. /**
  85494. * Create and start an animation on a node
  85495. * @param name defines the name of the global animation that will be run on all nodes
  85496. * @param node defines the root node where the animation will take place
  85497. * @param targetProperty defines property to animate
  85498. * @param framePerSecond defines the number of frame per second yo use
  85499. * @param totalFrame defines the number of frames in total
  85500. * @param from defines the initial value
  85501. * @param to defines the final value
  85502. * @param loopMode defines which loop mode you want to use (off by default)
  85503. * @param easingFunction defines the easing function to use (linear by default)
  85504. * @param onAnimationEnd defines the callback to call when animation end
  85505. * @returns the animatable created for this animation
  85506. */
  85507. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85508. /**
  85509. * Create and start an animation on a node and its descendants
  85510. * @param name defines the name of the global animation that will be run on all nodes
  85511. * @param node defines the root node where the animation will take place
  85512. * @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
  85513. * @param targetProperty defines property to animate
  85514. * @param framePerSecond defines the number of frame per second to use
  85515. * @param totalFrame defines the number of frames in total
  85516. * @param from defines the initial value
  85517. * @param to defines the final value
  85518. * @param loopMode defines which loop mode you want to use (off by default)
  85519. * @param easingFunction defines the easing function to use (linear by default)
  85520. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85521. * @returns the list of animatables created for all nodes
  85522. * @example https://www.babylonjs-playground.com/#MH0VLI
  85523. */
  85524. 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[]>;
  85525. /**
  85526. * Creates a new animation, merges it with the existing animations and starts it
  85527. * @param name Name of the animation
  85528. * @param node Node which contains the scene that begins the animations
  85529. * @param targetProperty Specifies which property to animate
  85530. * @param framePerSecond The frames per second of the animation
  85531. * @param totalFrame The total number of frames
  85532. * @param from The frame at the beginning of the animation
  85533. * @param to The frame at the end of the animation
  85534. * @param loopMode Specifies the loop mode of the animation
  85535. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85536. * @param onAnimationEnd Callback to run once the animation is complete
  85537. * @returns Nullable animation
  85538. */
  85539. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85540. /**
  85541. * Transition property of an host to the target Value
  85542. * @param property The property to transition
  85543. * @param targetValue The target Value of the property
  85544. * @param host The object where the property to animate belongs
  85545. * @param scene Scene used to run the animation
  85546. * @param frameRate Framerate (in frame/s) to use
  85547. * @param transition The transition type we want to use
  85548. * @param duration The duration of the animation, in milliseconds
  85549. * @param onAnimationEnd Callback trigger at the end of the animation
  85550. * @returns Nullable animation
  85551. */
  85552. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85553. /**
  85554. * Return the array of runtime animations currently using this animation
  85555. */
  85556. readonly runtimeAnimations: RuntimeAnimation[];
  85557. /**
  85558. * Specifies if any of the runtime animations are currently running
  85559. */
  85560. readonly hasRunningRuntimeAnimations: boolean;
  85561. /**
  85562. * Initializes the animation
  85563. * @param name Name of the animation
  85564. * @param targetProperty Property to animate
  85565. * @param framePerSecond The frames per second of the animation
  85566. * @param dataType The data type of the animation
  85567. * @param loopMode The loop mode of the animation
  85568. * @param enableBlending Specifies if blending should be enabled
  85569. */
  85570. constructor(
  85571. /**Name of the animation */
  85572. name: string,
  85573. /**Property to animate */
  85574. targetProperty: string,
  85575. /**The frames per second of the animation */
  85576. framePerSecond: number,
  85577. /**The data type of the animation */
  85578. dataType: number,
  85579. /**The loop mode of the animation */
  85580. loopMode?: number | undefined,
  85581. /**Specifies if blending should be enabled */
  85582. enableBlending?: boolean | undefined);
  85583. /**
  85584. * Converts the animation to a string
  85585. * @param fullDetails support for multiple levels of logging within scene loading
  85586. * @returns String form of the animation
  85587. */
  85588. toString(fullDetails?: boolean): string;
  85589. /**
  85590. * Add an event to this animation
  85591. * @param event Event to add
  85592. */
  85593. addEvent(event: AnimationEvent): void;
  85594. /**
  85595. * Remove all events found at the given frame
  85596. * @param frame The frame to remove events from
  85597. */
  85598. removeEvents(frame: number): void;
  85599. /**
  85600. * Retrieves all the events from the animation
  85601. * @returns Events from the animation
  85602. */
  85603. getEvents(): AnimationEvent[];
  85604. /**
  85605. * Creates an animation range
  85606. * @param name Name of the animation range
  85607. * @param from Starting frame of the animation range
  85608. * @param to Ending frame of the animation
  85609. */
  85610. createRange(name: string, from: number, to: number): void;
  85611. /**
  85612. * Deletes an animation range by name
  85613. * @param name Name of the animation range to delete
  85614. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85615. */
  85616. deleteRange(name: string, deleteFrames?: boolean): void;
  85617. /**
  85618. * Gets the animation range by name, or null if not defined
  85619. * @param name Name of the animation range
  85620. * @returns Nullable animation range
  85621. */
  85622. getRange(name: string): Nullable<AnimationRange>;
  85623. /**
  85624. * Gets the key frames from the animation
  85625. * @returns The key frames of the animation
  85626. */
  85627. getKeys(): Array<IAnimationKey>;
  85628. /**
  85629. * Gets the highest frame rate of the animation
  85630. * @returns Highest frame rate of the animation
  85631. */
  85632. getHighestFrame(): number;
  85633. /**
  85634. * Gets the easing function of the animation
  85635. * @returns Easing function of the animation
  85636. */
  85637. getEasingFunction(): IEasingFunction;
  85638. /**
  85639. * Sets the easing function of the animation
  85640. * @param easingFunction A custom mathematical formula for animation
  85641. */
  85642. setEasingFunction(easingFunction: EasingFunction): void;
  85643. /**
  85644. * Interpolates a scalar linearly
  85645. * @param startValue Start value of the animation curve
  85646. * @param endValue End value of the animation curve
  85647. * @param gradient Scalar amount to interpolate
  85648. * @returns Interpolated scalar value
  85649. */
  85650. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85651. /**
  85652. * Interpolates a scalar cubically
  85653. * @param startValue Start value of the animation curve
  85654. * @param outTangent End tangent of the animation
  85655. * @param endValue End value of the animation curve
  85656. * @param inTangent Start tangent of the animation curve
  85657. * @param gradient Scalar amount to interpolate
  85658. * @returns Interpolated scalar value
  85659. */
  85660. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85661. /**
  85662. * Interpolates a quaternion using a spherical linear interpolation
  85663. * @param startValue Start value of the animation curve
  85664. * @param endValue End value of the animation curve
  85665. * @param gradient Scalar amount to interpolate
  85666. * @returns Interpolated quaternion value
  85667. */
  85668. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85669. /**
  85670. * Interpolates a quaternion cubically
  85671. * @param startValue Start value of the animation curve
  85672. * @param outTangent End tangent of the animation curve
  85673. * @param endValue End value of the animation curve
  85674. * @param inTangent Start tangent of the animation curve
  85675. * @param gradient Scalar amount to interpolate
  85676. * @returns Interpolated quaternion value
  85677. */
  85678. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85679. /**
  85680. * Interpolates a Vector3 linearl
  85681. * @param startValue Start value of the animation curve
  85682. * @param endValue End value of the animation curve
  85683. * @param gradient Scalar amount to interpolate
  85684. * @returns Interpolated scalar value
  85685. */
  85686. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85687. /**
  85688. * Interpolates a Vector3 cubically
  85689. * @param startValue Start value of the animation curve
  85690. * @param outTangent End tangent of the animation
  85691. * @param endValue End value of the animation curve
  85692. * @param inTangent Start tangent of the animation curve
  85693. * @param gradient Scalar amount to interpolate
  85694. * @returns InterpolatedVector3 value
  85695. */
  85696. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85697. /**
  85698. * Interpolates a Vector2 linearly
  85699. * @param startValue Start value of the animation curve
  85700. * @param endValue End value of the animation curve
  85701. * @param gradient Scalar amount to interpolate
  85702. * @returns Interpolated Vector2 value
  85703. */
  85704. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85705. /**
  85706. * Interpolates a Vector2 cubically
  85707. * @param startValue Start value of the animation curve
  85708. * @param outTangent End tangent of the animation
  85709. * @param endValue End value of the animation curve
  85710. * @param inTangent Start tangent of the animation curve
  85711. * @param gradient Scalar amount to interpolate
  85712. * @returns Interpolated Vector2 value
  85713. */
  85714. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85715. /**
  85716. * Interpolates a size linearly
  85717. * @param startValue Start value of the animation curve
  85718. * @param endValue End value of the animation curve
  85719. * @param gradient Scalar amount to interpolate
  85720. * @returns Interpolated Size value
  85721. */
  85722. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85723. /**
  85724. * Interpolates a Color3 linearly
  85725. * @param startValue Start value of the animation curve
  85726. * @param endValue End value of the animation curve
  85727. * @param gradient Scalar amount to interpolate
  85728. * @returns Interpolated Color3 value
  85729. */
  85730. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85731. /**
  85732. * @hidden Internal use only
  85733. */
  85734. _getKeyValue(value: any): any;
  85735. /**
  85736. * @hidden Internal use only
  85737. */
  85738. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85739. /**
  85740. * Defines the function to use to interpolate matrices
  85741. * @param startValue defines the start matrix
  85742. * @param endValue defines the end matrix
  85743. * @param gradient defines the gradient between both matrices
  85744. * @param result defines an optional target matrix where to store the interpolation
  85745. * @returns the interpolated matrix
  85746. */
  85747. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85748. /**
  85749. * Makes a copy of the animation
  85750. * @returns Cloned animation
  85751. */
  85752. clone(): Animation;
  85753. /**
  85754. * Sets the key frames of the animation
  85755. * @param values The animation key frames to set
  85756. */
  85757. setKeys(values: Array<IAnimationKey>): void;
  85758. /**
  85759. * Serializes the animation to an object
  85760. * @returns Serialized object
  85761. */
  85762. serialize(): any;
  85763. /**
  85764. * Float animation type
  85765. */
  85766. private static _ANIMATIONTYPE_FLOAT;
  85767. /**
  85768. * Vector3 animation type
  85769. */
  85770. private static _ANIMATIONTYPE_VECTOR3;
  85771. /**
  85772. * Quaternion animation type
  85773. */
  85774. private static _ANIMATIONTYPE_QUATERNION;
  85775. /**
  85776. * Matrix animation type
  85777. */
  85778. private static _ANIMATIONTYPE_MATRIX;
  85779. /**
  85780. * Color3 animation type
  85781. */
  85782. private static _ANIMATIONTYPE_COLOR3;
  85783. /**
  85784. * Vector2 animation type
  85785. */
  85786. private static _ANIMATIONTYPE_VECTOR2;
  85787. /**
  85788. * Size animation type
  85789. */
  85790. private static _ANIMATIONTYPE_SIZE;
  85791. /**
  85792. * Relative Loop Mode
  85793. */
  85794. private static _ANIMATIONLOOPMODE_RELATIVE;
  85795. /**
  85796. * Cycle Loop Mode
  85797. */
  85798. private static _ANIMATIONLOOPMODE_CYCLE;
  85799. /**
  85800. * Constant Loop Mode
  85801. */
  85802. private static _ANIMATIONLOOPMODE_CONSTANT;
  85803. /**
  85804. * Get the float animation type
  85805. */
  85806. static readonly ANIMATIONTYPE_FLOAT: number;
  85807. /**
  85808. * Get the Vector3 animation type
  85809. */
  85810. static readonly ANIMATIONTYPE_VECTOR3: number;
  85811. /**
  85812. * Get the Vector2 animation type
  85813. */
  85814. static readonly ANIMATIONTYPE_VECTOR2: number;
  85815. /**
  85816. * Get the Size animation type
  85817. */
  85818. static readonly ANIMATIONTYPE_SIZE: number;
  85819. /**
  85820. * Get the Quaternion animation type
  85821. */
  85822. static readonly ANIMATIONTYPE_QUATERNION: number;
  85823. /**
  85824. * Get the Matrix animation type
  85825. */
  85826. static readonly ANIMATIONTYPE_MATRIX: number;
  85827. /**
  85828. * Get the Color3 animation type
  85829. */
  85830. static readonly ANIMATIONTYPE_COLOR3: number;
  85831. /**
  85832. * Get the Relative Loop Mode
  85833. */
  85834. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  85835. /**
  85836. * Get the Cycle Loop Mode
  85837. */
  85838. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  85839. /**
  85840. * Get the Constant Loop Mode
  85841. */
  85842. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  85843. /** @hidden */
  85844. static _UniversalLerp(left: any, right: any, amount: number): any;
  85845. /**
  85846. * Parses an animation object and creates an animation
  85847. * @param parsedAnimation Parsed animation object
  85848. * @returns Animation object
  85849. */
  85850. static Parse(parsedAnimation: any): Animation;
  85851. /**
  85852. * Appends the serialized animations from the source animations
  85853. * @param source Source containing the animations
  85854. * @param destination Target to store the animations
  85855. */
  85856. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85857. }
  85858. }
  85859. declare module BABYLON {
  85860. /**
  85861. * Base class of all the textures in babylon.
  85862. * It groups all the common properties the materials, post process, lights... might need
  85863. * in order to make a correct use of the texture.
  85864. */
  85865. export class BaseTexture implements IAnimatable {
  85866. /**
  85867. * Default anisotropic filtering level for the application.
  85868. * It is set to 4 as a good tradeoff between perf and quality.
  85869. */
  85870. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  85871. /**
  85872. * Gets or sets the unique id of the texture
  85873. */
  85874. uniqueId: number;
  85875. /**
  85876. * Define the name of the texture.
  85877. */
  85878. name: string;
  85879. /**
  85880. * Gets or sets an object used to store user defined information.
  85881. */
  85882. metadata: any;
  85883. /**
  85884. * For internal use only. Please do not use.
  85885. */
  85886. reservedDataStore: any;
  85887. private _hasAlpha;
  85888. /**
  85889. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  85890. */
  85891. hasAlpha: boolean;
  85892. /**
  85893. * Defines if the alpha value should be determined via the rgb values.
  85894. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  85895. */
  85896. getAlphaFromRGB: boolean;
  85897. /**
  85898. * Intensity or strength of the texture.
  85899. * It is commonly used by materials to fine tune the intensity of the texture
  85900. */
  85901. level: number;
  85902. /**
  85903. * Define the UV chanel to use starting from 0 and defaulting to 0.
  85904. * This is part of the texture as textures usually maps to one uv set.
  85905. */
  85906. coordinatesIndex: number;
  85907. private _coordinatesMode;
  85908. /**
  85909. * How a texture is mapped.
  85910. *
  85911. * | Value | Type | Description |
  85912. * | ----- | ----------------------------------- | ----------- |
  85913. * | 0 | EXPLICIT_MODE | |
  85914. * | 1 | SPHERICAL_MODE | |
  85915. * | 2 | PLANAR_MODE | |
  85916. * | 3 | CUBIC_MODE | |
  85917. * | 4 | PROJECTION_MODE | |
  85918. * | 5 | SKYBOX_MODE | |
  85919. * | 6 | INVCUBIC_MODE | |
  85920. * | 7 | EQUIRECTANGULAR_MODE | |
  85921. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85922. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85923. */
  85924. coordinatesMode: number;
  85925. /**
  85926. * | Value | Type | Description |
  85927. * | ----- | ------------------ | ----------- |
  85928. * | 0 | CLAMP_ADDRESSMODE | |
  85929. * | 1 | WRAP_ADDRESSMODE | |
  85930. * | 2 | MIRROR_ADDRESSMODE | |
  85931. */
  85932. wrapU: number;
  85933. /**
  85934. * | Value | Type | Description |
  85935. * | ----- | ------------------ | ----------- |
  85936. * | 0 | CLAMP_ADDRESSMODE | |
  85937. * | 1 | WRAP_ADDRESSMODE | |
  85938. * | 2 | MIRROR_ADDRESSMODE | |
  85939. */
  85940. wrapV: number;
  85941. /**
  85942. * | Value | Type | Description |
  85943. * | ----- | ------------------ | ----------- |
  85944. * | 0 | CLAMP_ADDRESSMODE | |
  85945. * | 1 | WRAP_ADDRESSMODE | |
  85946. * | 2 | MIRROR_ADDRESSMODE | |
  85947. */
  85948. wrapR: number;
  85949. /**
  85950. * With compliant hardware and browser (supporting anisotropic filtering)
  85951. * this defines the level of anisotropic filtering in the texture.
  85952. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85953. */
  85954. anisotropicFilteringLevel: number;
  85955. /**
  85956. * Define if the texture is a cube texture or if false a 2d texture.
  85957. */
  85958. isCube: boolean;
  85959. /**
  85960. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85961. */
  85962. is3D: boolean;
  85963. /**
  85964. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85965. * HDR texture are usually stored in linear space.
  85966. * This only impacts the PBR and Background materials
  85967. */
  85968. gammaSpace: boolean;
  85969. /**
  85970. * Gets whether or not the texture contains RGBD data.
  85971. */
  85972. readonly isRGBD: boolean;
  85973. /**
  85974. * Is Z inverted in the texture (useful in a cube texture).
  85975. */
  85976. invertZ: boolean;
  85977. /**
  85978. * Are mip maps generated for this texture or not.
  85979. */
  85980. readonly noMipmap: boolean;
  85981. /**
  85982. * @hidden
  85983. */
  85984. lodLevelInAlpha: boolean;
  85985. /**
  85986. * With prefiltered texture, defined the offset used during the prefiltering steps.
  85987. */
  85988. lodGenerationOffset: number;
  85989. /**
  85990. * With prefiltered texture, defined the scale used during the prefiltering steps.
  85991. */
  85992. lodGenerationScale: number;
  85993. /**
  85994. * Define if the texture is a render target.
  85995. */
  85996. isRenderTarget: boolean;
  85997. /**
  85998. * Define the unique id of the texture in the scene.
  85999. */
  86000. readonly uid: string;
  86001. /**
  86002. * Return a string representation of the texture.
  86003. * @returns the texture as a string
  86004. */
  86005. toString(): string;
  86006. /**
  86007. * Get the class name of the texture.
  86008. * @returns "BaseTexture"
  86009. */
  86010. getClassName(): string;
  86011. /**
  86012. * Define the list of animation attached to the texture.
  86013. */
  86014. animations: Animation[];
  86015. /**
  86016. * An event triggered when the texture is disposed.
  86017. */
  86018. onDisposeObservable: Observable<BaseTexture>;
  86019. private _onDisposeObserver;
  86020. /**
  86021. * Callback triggered when the texture has been disposed.
  86022. * Kept for back compatibility, you can use the onDisposeObservable instead.
  86023. */
  86024. onDispose: () => void;
  86025. /**
  86026. * Define the current state of the loading sequence when in delayed load mode.
  86027. */
  86028. delayLoadState: number;
  86029. private _scene;
  86030. /** @hidden */
  86031. _texture: Nullable<InternalTexture>;
  86032. private _uid;
  86033. /**
  86034. * Define if the texture is preventinga material to render or not.
  86035. * If not and the texture is not ready, the engine will use a default black texture instead.
  86036. */
  86037. readonly isBlocking: boolean;
  86038. /**
  86039. * Instantiates a new BaseTexture.
  86040. * Base class of all the textures in babylon.
  86041. * It groups all the common properties the materials, post process, lights... might need
  86042. * in order to make a correct use of the texture.
  86043. * @param scene Define the scene the texture blongs to
  86044. */
  86045. constructor(scene: Nullable<Scene>);
  86046. /**
  86047. * Get the scene the texture belongs to.
  86048. * @returns the scene or null if undefined
  86049. */
  86050. getScene(): Nullable<Scene>;
  86051. /**
  86052. * Get the texture transform matrix used to offset tile the texture for istance.
  86053. * @returns the transformation matrix
  86054. */
  86055. getTextureMatrix(): Matrix;
  86056. /**
  86057. * Get the texture reflection matrix used to rotate/transform the reflection.
  86058. * @returns the reflection matrix
  86059. */
  86060. getReflectionTextureMatrix(): Matrix;
  86061. /**
  86062. * Get the underlying lower level texture from Babylon.
  86063. * @returns the insternal texture
  86064. */
  86065. getInternalTexture(): Nullable<InternalTexture>;
  86066. /**
  86067. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  86068. * @returns true if ready or not blocking
  86069. */
  86070. isReadyOrNotBlocking(): boolean;
  86071. /**
  86072. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86073. * @returns true if fully ready
  86074. */
  86075. isReady(): boolean;
  86076. private _cachedSize;
  86077. /**
  86078. * Get the size of the texture.
  86079. * @returns the texture size.
  86080. */
  86081. getSize(): ISize;
  86082. /**
  86083. * Get the base size of the texture.
  86084. * It can be different from the size if the texture has been resized for POT for instance
  86085. * @returns the base size
  86086. */
  86087. getBaseSize(): ISize;
  86088. /**
  86089. * Update the sampling mode of the texture.
  86090. * Default is Trilinear mode.
  86091. *
  86092. * | Value | Type | Description |
  86093. * | ----- | ------------------ | ----------- |
  86094. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86095. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86096. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86097. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86098. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86099. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86100. * | 7 | NEAREST_LINEAR | |
  86101. * | 8 | NEAREST_NEAREST | |
  86102. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86103. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86104. * | 11 | LINEAR_LINEAR | |
  86105. * | 12 | LINEAR_NEAREST | |
  86106. *
  86107. * > _mag_: magnification filter (close to the viewer)
  86108. * > _min_: minification filter (far from the viewer)
  86109. * > _mip_: filter used between mip map levels
  86110. *@param samplingMode Define the new sampling mode of the texture
  86111. */
  86112. updateSamplingMode(samplingMode: number): void;
  86113. /**
  86114. * Scales the texture if is `canRescale()`
  86115. * @param ratio the resize factor we want to use to rescale
  86116. */
  86117. scale(ratio: number): void;
  86118. /**
  86119. * Get if the texture can rescale.
  86120. */
  86121. readonly canRescale: boolean;
  86122. /** @hidden */
  86123. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  86124. /** @hidden */
  86125. _rebuild(): void;
  86126. /**
  86127. * Triggers the load sequence in delayed load mode.
  86128. */
  86129. delayLoad(): void;
  86130. /**
  86131. * Clones the texture.
  86132. * @returns the cloned texture
  86133. */
  86134. clone(): Nullable<BaseTexture>;
  86135. /**
  86136. * Get the texture underlying type (INT, FLOAT...)
  86137. */
  86138. readonly textureType: number;
  86139. /**
  86140. * Get the texture underlying format (RGB, RGBA...)
  86141. */
  86142. readonly textureFormat: number;
  86143. /**
  86144. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  86145. * This will returns an RGBA array buffer containing either in values (0-255) or
  86146. * float values (0-1) depending of the underlying buffer type.
  86147. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  86148. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  86149. * @param buffer defines a user defined buffer to fill with data (can be null)
  86150. * @returns The Array buffer containing the pixels data.
  86151. */
  86152. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  86153. /**
  86154. * Release and destroy the underlying lower level texture aka internalTexture.
  86155. */
  86156. releaseInternalTexture(): void;
  86157. /**
  86158. * Get the polynomial representation of the texture data.
  86159. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  86160. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  86161. */
  86162. sphericalPolynomial: Nullable<SphericalPolynomial>;
  86163. /** @hidden */
  86164. readonly _lodTextureHigh: Nullable<BaseTexture>;
  86165. /** @hidden */
  86166. readonly _lodTextureMid: Nullable<BaseTexture>;
  86167. /** @hidden */
  86168. readonly _lodTextureLow: Nullable<BaseTexture>;
  86169. /**
  86170. * Dispose the texture and release its associated resources.
  86171. */
  86172. dispose(): void;
  86173. /**
  86174. * Serialize the texture into a JSON representation that can be parsed later on.
  86175. * @returns the JSON representation of the texture
  86176. */
  86177. serialize(): any;
  86178. /**
  86179. * Helper function to be called back once a list of texture contains only ready textures.
  86180. * @param textures Define the list of textures to wait for
  86181. * @param callback Define the callback triggered once the entire list will be ready
  86182. */
  86183. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  86184. }
  86185. }
  86186. declare module BABYLON {
  86187. /**
  86188. * Uniform buffer objects.
  86189. *
  86190. * Handles blocks of uniform on the GPU.
  86191. *
  86192. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86193. *
  86194. * For more information, please refer to :
  86195. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86196. */
  86197. export class UniformBuffer {
  86198. private _engine;
  86199. private _buffer;
  86200. private _data;
  86201. private _bufferData;
  86202. private _dynamic?;
  86203. private _uniformLocations;
  86204. private _uniformSizes;
  86205. private _uniformLocationPointer;
  86206. private _needSync;
  86207. private _noUBO;
  86208. private _currentEffect;
  86209. private static _MAX_UNIFORM_SIZE;
  86210. private static _tempBuffer;
  86211. /**
  86212. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86213. * This is dynamic to allow compat with webgl 1 and 2.
  86214. * You will need to pass the name of the uniform as well as the value.
  86215. */
  86216. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86217. /**
  86218. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86219. * This is dynamic to allow compat with webgl 1 and 2.
  86220. * You will need to pass the name of the uniform as well as the value.
  86221. */
  86222. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86223. /**
  86224. * Lambda to Update a single float in a uniform buffer.
  86225. * This is dynamic to allow compat with webgl 1 and 2.
  86226. * You will need to pass the name of the uniform as well as the value.
  86227. */
  86228. updateFloat: (name: string, x: number) => void;
  86229. /**
  86230. * Lambda to Update a vec2 of float in a uniform buffer.
  86231. * This is dynamic to allow compat with webgl 1 and 2.
  86232. * You will need to pass the name of the uniform as well as the value.
  86233. */
  86234. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86235. /**
  86236. * Lambda to Update a vec3 of float in a uniform buffer.
  86237. * This is dynamic to allow compat with webgl 1 and 2.
  86238. * You will need to pass the name of the uniform as well as the value.
  86239. */
  86240. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86241. /**
  86242. * Lambda to Update a vec4 of float in a uniform buffer.
  86243. * This is dynamic to allow compat with webgl 1 and 2.
  86244. * You will need to pass the name of the uniform as well as the value.
  86245. */
  86246. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86247. /**
  86248. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86249. * This is dynamic to allow compat with webgl 1 and 2.
  86250. * You will need to pass the name of the uniform as well as the value.
  86251. */
  86252. updateMatrix: (name: string, mat: Matrix) => void;
  86253. /**
  86254. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86255. * This is dynamic to allow compat with webgl 1 and 2.
  86256. * You will need to pass the name of the uniform as well as the value.
  86257. */
  86258. updateVector3: (name: string, vector: Vector3) => void;
  86259. /**
  86260. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86261. * This is dynamic to allow compat with webgl 1 and 2.
  86262. * You will need to pass the name of the uniform as well as the value.
  86263. */
  86264. updateVector4: (name: string, vector: Vector4) => void;
  86265. /**
  86266. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86267. * This is dynamic to allow compat with webgl 1 and 2.
  86268. * You will need to pass the name of the uniform as well as the value.
  86269. */
  86270. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86271. /**
  86272. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86273. * This is dynamic to allow compat with webgl 1 and 2.
  86274. * You will need to pass the name of the uniform as well as the value.
  86275. */
  86276. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86277. /**
  86278. * Instantiates a new Uniform buffer objects.
  86279. *
  86280. * Handles blocks of uniform on the GPU.
  86281. *
  86282. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86283. *
  86284. * For more information, please refer to :
  86285. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86286. * @param engine Define the engine the buffer is associated with
  86287. * @param data Define the data contained in the buffer
  86288. * @param dynamic Define if the buffer is updatable
  86289. */
  86290. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86291. /**
  86292. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86293. * or just falling back on setUniformXXX calls.
  86294. */
  86295. readonly useUbo: boolean;
  86296. /**
  86297. * Indicates if the WebGL underlying uniform buffer is in sync
  86298. * with the javascript cache data.
  86299. */
  86300. readonly isSync: boolean;
  86301. /**
  86302. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86303. * Also, a dynamic UniformBuffer will disable cache verification and always
  86304. * update the underlying WebGL uniform buffer to the GPU.
  86305. * @returns if Dynamic, otherwise false
  86306. */
  86307. isDynamic(): boolean;
  86308. /**
  86309. * The data cache on JS side.
  86310. * @returns the underlying data as a float array
  86311. */
  86312. getData(): Float32Array;
  86313. /**
  86314. * The underlying WebGL Uniform buffer.
  86315. * @returns the webgl buffer
  86316. */
  86317. getBuffer(): Nullable<DataBuffer>;
  86318. /**
  86319. * std140 layout specifies how to align data within an UBO structure.
  86320. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86321. * for specs.
  86322. */
  86323. private _fillAlignment;
  86324. /**
  86325. * Adds an uniform in the buffer.
  86326. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86327. * for the layout to be correct !
  86328. * @param name Name of the uniform, as used in the uniform block in the shader.
  86329. * @param size Data size, or data directly.
  86330. */
  86331. addUniform(name: string, size: number | number[]): void;
  86332. /**
  86333. * Adds a Matrix 4x4 to the uniform buffer.
  86334. * @param name Name of the uniform, as used in the uniform block in the shader.
  86335. * @param mat A 4x4 matrix.
  86336. */
  86337. addMatrix(name: string, mat: Matrix): void;
  86338. /**
  86339. * Adds a vec2 to the uniform buffer.
  86340. * @param name Name of the uniform, as used in the uniform block in the shader.
  86341. * @param x Define the x component value of the vec2
  86342. * @param y Define the y component value of the vec2
  86343. */
  86344. addFloat2(name: string, x: number, y: number): void;
  86345. /**
  86346. * Adds a vec3 to the uniform buffer.
  86347. * @param name Name of the uniform, as used in the uniform block in the shader.
  86348. * @param x Define the x component value of the vec3
  86349. * @param y Define the y component value of the vec3
  86350. * @param z Define the z component value of the vec3
  86351. */
  86352. addFloat3(name: string, x: number, y: number, z: number): void;
  86353. /**
  86354. * Adds a vec3 to the uniform buffer.
  86355. * @param name Name of the uniform, as used in the uniform block in the shader.
  86356. * @param color Define the vec3 from a Color
  86357. */
  86358. addColor3(name: string, color: Color3): void;
  86359. /**
  86360. * Adds a vec4 to the uniform buffer.
  86361. * @param name Name of the uniform, as used in the uniform block in the shader.
  86362. * @param color Define the rgb components from a Color
  86363. * @param alpha Define the a component of the vec4
  86364. */
  86365. addColor4(name: string, color: Color3, alpha: number): void;
  86366. /**
  86367. * Adds a vec3 to the uniform buffer.
  86368. * @param name Name of the uniform, as used in the uniform block in the shader.
  86369. * @param vector Define the vec3 components from a Vector
  86370. */
  86371. addVector3(name: string, vector: Vector3): void;
  86372. /**
  86373. * Adds a Matrix 3x3 to the uniform buffer.
  86374. * @param name Name of the uniform, as used in the uniform block in the shader.
  86375. */
  86376. addMatrix3x3(name: string): void;
  86377. /**
  86378. * Adds a Matrix 2x2 to the uniform buffer.
  86379. * @param name Name of the uniform, as used in the uniform block in the shader.
  86380. */
  86381. addMatrix2x2(name: string): void;
  86382. /**
  86383. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86384. */
  86385. create(): void;
  86386. /** @hidden */
  86387. _rebuild(): void;
  86388. /**
  86389. * Updates the WebGL Uniform Buffer on the GPU.
  86390. * If the `dynamic` flag is set to true, no cache comparison is done.
  86391. * Otherwise, the buffer will be updated only if the cache differs.
  86392. */
  86393. update(): void;
  86394. /**
  86395. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86396. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86397. * @param data Define the flattened data
  86398. * @param size Define the size of the data.
  86399. */
  86400. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86401. private _updateMatrix3x3ForUniform;
  86402. private _updateMatrix3x3ForEffect;
  86403. private _updateMatrix2x2ForEffect;
  86404. private _updateMatrix2x2ForUniform;
  86405. private _updateFloatForEffect;
  86406. private _updateFloatForUniform;
  86407. private _updateFloat2ForEffect;
  86408. private _updateFloat2ForUniform;
  86409. private _updateFloat3ForEffect;
  86410. private _updateFloat3ForUniform;
  86411. private _updateFloat4ForEffect;
  86412. private _updateFloat4ForUniform;
  86413. private _updateMatrixForEffect;
  86414. private _updateMatrixForUniform;
  86415. private _updateVector3ForEffect;
  86416. private _updateVector3ForUniform;
  86417. private _updateVector4ForEffect;
  86418. private _updateVector4ForUniform;
  86419. private _updateColor3ForEffect;
  86420. private _updateColor3ForUniform;
  86421. private _updateColor4ForEffect;
  86422. private _updateColor4ForUniform;
  86423. /**
  86424. * Sets a sampler uniform on the effect.
  86425. * @param name Define the name of the sampler.
  86426. * @param texture Define the texture to set in the sampler
  86427. */
  86428. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86429. /**
  86430. * Directly updates the value of the uniform in the cache AND on the GPU.
  86431. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86432. * @param data Define the flattened data
  86433. */
  86434. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86435. /**
  86436. * Binds this uniform buffer to an effect.
  86437. * @param effect Define the effect to bind the buffer to
  86438. * @param name Name of the uniform block in the shader.
  86439. */
  86440. bindToEffect(effect: Effect, name: string): void;
  86441. /**
  86442. * Disposes the uniform buffer.
  86443. */
  86444. dispose(): void;
  86445. }
  86446. }
  86447. declare module BABYLON {
  86448. /**
  86449. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86451. */
  86452. export class Analyser {
  86453. /**
  86454. * Gets or sets the smoothing
  86455. * @ignorenaming
  86456. */
  86457. SMOOTHING: number;
  86458. /**
  86459. * Gets or sets the FFT table size
  86460. * @ignorenaming
  86461. */
  86462. FFT_SIZE: number;
  86463. /**
  86464. * Gets or sets the bar graph amplitude
  86465. * @ignorenaming
  86466. */
  86467. BARGRAPHAMPLITUDE: number;
  86468. /**
  86469. * Gets or sets the position of the debug canvas
  86470. * @ignorenaming
  86471. */
  86472. DEBUGCANVASPOS: {
  86473. x: number;
  86474. y: number;
  86475. };
  86476. /**
  86477. * Gets or sets the debug canvas size
  86478. * @ignorenaming
  86479. */
  86480. DEBUGCANVASSIZE: {
  86481. width: number;
  86482. height: number;
  86483. };
  86484. private _byteFreqs;
  86485. private _byteTime;
  86486. private _floatFreqs;
  86487. private _webAudioAnalyser;
  86488. private _debugCanvas;
  86489. private _debugCanvasContext;
  86490. private _scene;
  86491. private _registerFunc;
  86492. private _audioEngine;
  86493. /**
  86494. * Creates a new analyser
  86495. * @param scene defines hosting scene
  86496. */
  86497. constructor(scene: Scene);
  86498. /**
  86499. * Get the number of data values you will have to play with for the visualization
  86500. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86501. * @returns a number
  86502. */
  86503. getFrequencyBinCount(): number;
  86504. /**
  86505. * Gets the current frequency data as a byte array
  86506. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86507. * @returns a Uint8Array
  86508. */
  86509. getByteFrequencyData(): Uint8Array;
  86510. /**
  86511. * Gets the current waveform as a byte array
  86512. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86513. * @returns a Uint8Array
  86514. */
  86515. getByteTimeDomainData(): Uint8Array;
  86516. /**
  86517. * Gets the current frequency data as a float array
  86518. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86519. * @returns a Float32Array
  86520. */
  86521. getFloatFrequencyData(): Float32Array;
  86522. /**
  86523. * Renders the debug canvas
  86524. */
  86525. drawDebugCanvas(): void;
  86526. /**
  86527. * Stops rendering the debug canvas and removes it
  86528. */
  86529. stopDebugCanvas(): void;
  86530. /**
  86531. * Connects two audio nodes
  86532. * @param inputAudioNode defines first node to connect
  86533. * @param outputAudioNode defines second node to connect
  86534. */
  86535. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86536. /**
  86537. * Releases all associated resources
  86538. */
  86539. dispose(): void;
  86540. }
  86541. }
  86542. declare module BABYLON {
  86543. /**
  86544. * This represents an audio engine and it is responsible
  86545. * to play, synchronize and analyse sounds throughout the application.
  86546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86547. */
  86548. export interface IAudioEngine extends IDisposable {
  86549. /**
  86550. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86551. */
  86552. readonly canUseWebAudio: boolean;
  86553. /**
  86554. * Gets the current AudioContext if available.
  86555. */
  86556. readonly audioContext: Nullable<AudioContext>;
  86557. /**
  86558. * The master gain node defines the global audio volume of your audio engine.
  86559. */
  86560. readonly masterGain: GainNode;
  86561. /**
  86562. * Gets whether or not mp3 are supported by your browser.
  86563. */
  86564. readonly isMP3supported: boolean;
  86565. /**
  86566. * Gets whether or not ogg are supported by your browser.
  86567. */
  86568. readonly isOGGsupported: boolean;
  86569. /**
  86570. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86571. * @ignoreNaming
  86572. */
  86573. WarnedWebAudioUnsupported: boolean;
  86574. /**
  86575. * Defines if the audio engine relies on a custom unlocked button.
  86576. * In this case, the embedded button will not be displayed.
  86577. */
  86578. useCustomUnlockedButton: boolean;
  86579. /**
  86580. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86581. */
  86582. readonly unlocked: boolean;
  86583. /**
  86584. * Event raised when audio has been unlocked on the browser.
  86585. */
  86586. onAudioUnlockedObservable: Observable<AudioEngine>;
  86587. /**
  86588. * Event raised when audio has been locked on the browser.
  86589. */
  86590. onAudioLockedObservable: Observable<AudioEngine>;
  86591. /**
  86592. * Flags the audio engine in Locked state.
  86593. * This happens due to new browser policies preventing audio to autoplay.
  86594. */
  86595. lock(): void;
  86596. /**
  86597. * Unlocks the audio engine once a user action has been done on the dom.
  86598. * This is helpful to resume play once browser policies have been satisfied.
  86599. */
  86600. unlock(): void;
  86601. }
  86602. /**
  86603. * This represents the default audio engine used in babylon.
  86604. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86606. */
  86607. export class AudioEngine implements IAudioEngine {
  86608. private _audioContext;
  86609. private _audioContextInitialized;
  86610. private _muteButton;
  86611. private _hostElement;
  86612. /**
  86613. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86614. */
  86615. canUseWebAudio: boolean;
  86616. /**
  86617. * The master gain node defines the global audio volume of your audio engine.
  86618. */
  86619. masterGain: GainNode;
  86620. /**
  86621. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86622. * @ignoreNaming
  86623. */
  86624. WarnedWebAudioUnsupported: boolean;
  86625. /**
  86626. * Gets whether or not mp3 are supported by your browser.
  86627. */
  86628. isMP3supported: boolean;
  86629. /**
  86630. * Gets whether or not ogg are supported by your browser.
  86631. */
  86632. isOGGsupported: boolean;
  86633. /**
  86634. * Gets whether audio has been unlocked on the device.
  86635. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86636. * a user interaction has happened.
  86637. */
  86638. unlocked: boolean;
  86639. /**
  86640. * Defines if the audio engine relies on a custom unlocked button.
  86641. * In this case, the embedded button will not be displayed.
  86642. */
  86643. useCustomUnlockedButton: boolean;
  86644. /**
  86645. * Event raised when audio has been unlocked on the browser.
  86646. */
  86647. onAudioUnlockedObservable: Observable<AudioEngine>;
  86648. /**
  86649. * Event raised when audio has been locked on the browser.
  86650. */
  86651. onAudioLockedObservable: Observable<AudioEngine>;
  86652. /**
  86653. * Gets the current AudioContext if available.
  86654. */
  86655. readonly audioContext: Nullable<AudioContext>;
  86656. private _connectedAnalyser;
  86657. /**
  86658. * Instantiates a new audio engine.
  86659. *
  86660. * There should be only one per page as some browsers restrict the number
  86661. * of audio contexts you can create.
  86662. * @param hostElement defines the host element where to display the mute icon if necessary
  86663. */
  86664. constructor(hostElement?: Nullable<HTMLElement>);
  86665. /**
  86666. * Flags the audio engine in Locked state.
  86667. * This happens due to new browser policies preventing audio to autoplay.
  86668. */
  86669. lock(): void;
  86670. /**
  86671. * Unlocks the audio engine once a user action has been done on the dom.
  86672. * This is helpful to resume play once browser policies have been satisfied.
  86673. */
  86674. unlock(): void;
  86675. private _resumeAudioContext;
  86676. private _initializeAudioContext;
  86677. private _tryToRun;
  86678. private _triggerRunningState;
  86679. private _triggerSuspendedState;
  86680. private _displayMuteButton;
  86681. private _moveButtonToTopLeft;
  86682. private _onResize;
  86683. private _hideMuteButton;
  86684. /**
  86685. * Destroy and release the resources associated with the audio ccontext.
  86686. */
  86687. dispose(): void;
  86688. /**
  86689. * Gets the global volume sets on the master gain.
  86690. * @returns the global volume if set or -1 otherwise
  86691. */
  86692. getGlobalVolume(): number;
  86693. /**
  86694. * Sets the global volume of your experience (sets on the master gain).
  86695. * @param newVolume Defines the new global volume of the application
  86696. */
  86697. setGlobalVolume(newVolume: number): void;
  86698. /**
  86699. * Connect the audio engine to an audio analyser allowing some amazing
  86700. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86702. * @param analyser The analyser to connect to the engine
  86703. */
  86704. connectToAnalyser(analyser: Analyser): void;
  86705. }
  86706. }
  86707. declare module BABYLON {
  86708. /**
  86709. * Interface used to present a loading screen while loading a scene
  86710. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86711. */
  86712. export interface ILoadingScreen {
  86713. /**
  86714. * Function called to display the loading screen
  86715. */
  86716. displayLoadingUI: () => void;
  86717. /**
  86718. * Function called to hide the loading screen
  86719. */
  86720. hideLoadingUI: () => void;
  86721. /**
  86722. * Gets or sets the color to use for the background
  86723. */
  86724. loadingUIBackgroundColor: string;
  86725. /**
  86726. * Gets or sets the text to display while loading
  86727. */
  86728. loadingUIText: string;
  86729. }
  86730. /**
  86731. * Class used for the default loading screen
  86732. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86733. */
  86734. export class DefaultLoadingScreen implements ILoadingScreen {
  86735. private _renderingCanvas;
  86736. private _loadingText;
  86737. private _loadingDivBackgroundColor;
  86738. private _loadingDiv;
  86739. private _loadingTextDiv;
  86740. /**
  86741. * Creates a new default loading screen
  86742. * @param _renderingCanvas defines the canvas used to render the scene
  86743. * @param _loadingText defines the default text to display
  86744. * @param _loadingDivBackgroundColor defines the default background color
  86745. */
  86746. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86747. /**
  86748. * Function called to display the loading screen
  86749. */
  86750. displayLoadingUI(): void;
  86751. /**
  86752. * Function called to hide the loading screen
  86753. */
  86754. hideLoadingUI(): void;
  86755. /**
  86756. * Gets or sets the text to display while loading
  86757. */
  86758. loadingUIText: string;
  86759. /**
  86760. * Gets or sets the color to use for the background
  86761. */
  86762. loadingUIBackgroundColor: string;
  86763. private _resizeLoadingUI;
  86764. }
  86765. }
  86766. declare module BABYLON {
  86767. /** @hidden */
  86768. export class WebGLPipelineContext implements IPipelineContext {
  86769. engine: Engine;
  86770. program: Nullable<WebGLProgram>;
  86771. context?: WebGLRenderingContext;
  86772. vertexShader?: WebGLShader;
  86773. fragmentShader?: WebGLShader;
  86774. isParallelCompiled: boolean;
  86775. onCompiled?: () => void;
  86776. transformFeedback?: WebGLTransformFeedback | null;
  86777. readonly isAsync: boolean;
  86778. readonly isReady: boolean;
  86779. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86780. }
  86781. }
  86782. declare module BABYLON {
  86783. /** @hidden */
  86784. export class WebGLDataBuffer extends DataBuffer {
  86785. private _buffer;
  86786. constructor(resource: WebGLBuffer);
  86787. readonly underlyingResource: any;
  86788. }
  86789. }
  86790. declare module BABYLON {
  86791. /**
  86792. * Settings for finer control over video usage
  86793. */
  86794. export interface VideoTextureSettings {
  86795. /**
  86796. * Applies `autoplay` to video, if specified
  86797. */
  86798. autoPlay?: boolean;
  86799. /**
  86800. * Applies `loop` to video, if specified
  86801. */
  86802. loop?: boolean;
  86803. /**
  86804. * Automatically updates internal texture from video at every frame in the render loop
  86805. */
  86806. autoUpdateTexture: boolean;
  86807. /**
  86808. * Image src displayed during the video loading or until the user interacts with the video.
  86809. */
  86810. poster?: string;
  86811. }
  86812. /**
  86813. * If you want to display a video in your scene, this is the special texture for that.
  86814. * This special texture works similar to other textures, with the exception of a few parameters.
  86815. * @see https://doc.babylonjs.com/how_to/video_texture
  86816. */
  86817. export class VideoTexture extends Texture {
  86818. /**
  86819. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86820. */
  86821. readonly autoUpdateTexture: boolean;
  86822. /**
  86823. * The video instance used by the texture internally
  86824. */
  86825. readonly video: HTMLVideoElement;
  86826. private _onUserActionRequestedObservable;
  86827. /**
  86828. * Event triggerd when a dom action is required by the user to play the video.
  86829. * This happens due to recent changes in browser policies preventing video to auto start.
  86830. */
  86831. readonly onUserActionRequestedObservable: Observable<Texture>;
  86832. private _generateMipMaps;
  86833. private _engine;
  86834. private _stillImageCaptured;
  86835. private _displayingPosterTexture;
  86836. private _settings;
  86837. private _createInternalTextureOnEvent;
  86838. /**
  86839. * Creates a video texture.
  86840. * If you want to display a video in your scene, this is the special texture for that.
  86841. * This special texture works similar to other textures, with the exception of a few parameters.
  86842. * @see https://doc.babylonjs.com/how_to/video_texture
  86843. * @param name optional name, will detect from video source, if not defined
  86844. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86845. * @param scene is obviously the current scene.
  86846. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86847. * @param invertY is false by default but can be used to invert video on Y axis
  86848. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86849. * @param settings allows finer control over video usage
  86850. */
  86851. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86852. private _getName;
  86853. private _getVideo;
  86854. private _createInternalTexture;
  86855. private reset;
  86856. /**
  86857. * @hidden Internal method to initiate `update`.
  86858. */
  86859. _rebuild(): void;
  86860. /**
  86861. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86862. */
  86863. update(): void;
  86864. /**
  86865. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86866. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86867. */
  86868. updateTexture(isVisible: boolean): void;
  86869. protected _updateInternalTexture: () => void;
  86870. /**
  86871. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86872. * @param url New url.
  86873. */
  86874. updateURL(url: string): void;
  86875. /**
  86876. * Dispose the texture and release its associated resources.
  86877. */
  86878. dispose(): void;
  86879. /**
  86880. * Creates a video texture straight from a stream.
  86881. * @param scene Define the scene the texture should be created in
  86882. * @param stream Define the stream the texture should be created from
  86883. * @returns The created video texture as a promise
  86884. */
  86885. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86886. /**
  86887. * Creates a video texture straight from your WebCam video feed.
  86888. * @param scene Define the scene the texture should be created in
  86889. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86890. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86891. * @returns The created video texture as a promise
  86892. */
  86893. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86894. minWidth: number;
  86895. maxWidth: number;
  86896. minHeight: number;
  86897. maxHeight: number;
  86898. deviceId: string;
  86899. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86900. /**
  86901. * Creates a video texture straight from your WebCam video feed.
  86902. * @param scene Define the scene the texture should be created in
  86903. * @param onReady Define a callback to triggered once the texture will be ready
  86904. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86905. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86906. */
  86907. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86908. minWidth: number;
  86909. maxWidth: number;
  86910. minHeight: number;
  86911. maxHeight: number;
  86912. deviceId: string;
  86913. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86914. }
  86915. }
  86916. declare module BABYLON {
  86917. /**
  86918. * Interface for attribute information associated with buffer instanciation
  86919. */
  86920. export class InstancingAttributeInfo {
  86921. /**
  86922. * Index/offset of the attribute in the vertex shader
  86923. */
  86924. index: number;
  86925. /**
  86926. * size of the attribute, 1, 2, 3 or 4
  86927. */
  86928. attributeSize: number;
  86929. /**
  86930. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86931. * default is FLOAT
  86932. */
  86933. attribyteType: number;
  86934. /**
  86935. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86936. */
  86937. normalized: boolean;
  86938. /**
  86939. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86940. */
  86941. offset: number;
  86942. /**
  86943. * Name of the GLSL attribute, for debugging purpose only
  86944. */
  86945. attributeName: string;
  86946. }
  86947. /**
  86948. * Define options used to create a depth texture
  86949. */
  86950. export class DepthTextureCreationOptions {
  86951. /** Specifies whether or not a stencil should be allocated in the texture */
  86952. generateStencil?: boolean;
  86953. /** Specifies whether or not bilinear filtering is enable on the texture */
  86954. bilinearFiltering?: boolean;
  86955. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86956. comparisonFunction?: number;
  86957. /** Specifies if the created texture is a cube texture */
  86958. isCube?: boolean;
  86959. }
  86960. /**
  86961. * Class used to describe the capabilities of the engine relatively to the current browser
  86962. */
  86963. export class EngineCapabilities {
  86964. /** Maximum textures units per fragment shader */
  86965. maxTexturesImageUnits: number;
  86966. /** Maximum texture units per vertex shader */
  86967. maxVertexTextureImageUnits: number;
  86968. /** Maximum textures units in the entire pipeline */
  86969. maxCombinedTexturesImageUnits: number;
  86970. /** Maximum texture size */
  86971. maxTextureSize: number;
  86972. /** Maximum cube texture size */
  86973. maxCubemapTextureSize: number;
  86974. /** Maximum render texture size */
  86975. maxRenderTextureSize: number;
  86976. /** Maximum number of vertex attributes */
  86977. maxVertexAttribs: number;
  86978. /** Maximum number of varyings */
  86979. maxVaryingVectors: number;
  86980. /** Maximum number of uniforms per vertex shader */
  86981. maxVertexUniformVectors: number;
  86982. /** Maximum number of uniforms per fragment shader */
  86983. maxFragmentUniformVectors: number;
  86984. /** Defines if standard derivates (dx/dy) are supported */
  86985. standardDerivatives: boolean;
  86986. /** Defines if s3tc texture compression is supported */
  86987. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  86988. /** Defines if pvrtc texture compression is supported */
  86989. pvrtc: any;
  86990. /** Defines if etc1 texture compression is supported */
  86991. etc1: any;
  86992. /** Defines if etc2 texture compression is supported */
  86993. etc2: any;
  86994. /** Defines if astc texture compression is supported */
  86995. astc: any;
  86996. /** Defines if float textures are supported */
  86997. textureFloat: boolean;
  86998. /** Defines if vertex array objects are supported */
  86999. vertexArrayObject: boolean;
  87000. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  87001. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  87002. /** Gets the maximum level of anisotropy supported */
  87003. maxAnisotropy: number;
  87004. /** Defines if instancing is supported */
  87005. instancedArrays: boolean;
  87006. /** Defines if 32 bits indices are supported */
  87007. uintIndices: boolean;
  87008. /** Defines if high precision shaders are supported */
  87009. highPrecisionShaderSupported: boolean;
  87010. /** Defines if depth reading in the fragment shader is supported */
  87011. fragmentDepthSupported: boolean;
  87012. /** Defines if float texture linear filtering is supported*/
  87013. textureFloatLinearFiltering: boolean;
  87014. /** Defines if rendering to float textures is supported */
  87015. textureFloatRender: boolean;
  87016. /** Defines if half float textures are supported*/
  87017. textureHalfFloat: boolean;
  87018. /** Defines if half float texture linear filtering is supported*/
  87019. textureHalfFloatLinearFiltering: boolean;
  87020. /** Defines if rendering to half float textures is supported */
  87021. textureHalfFloatRender: boolean;
  87022. /** Defines if textureLOD shader command is supported */
  87023. textureLOD: boolean;
  87024. /** Defines if draw buffers extension is supported */
  87025. drawBuffersExtension: boolean;
  87026. /** Defines if depth textures are supported */
  87027. depthTextureExtension: boolean;
  87028. /** Defines if float color buffer are supported */
  87029. colorBufferFloat: boolean;
  87030. /** Gets disjoint timer query extension (null if not supported) */
  87031. timerQuery: EXT_disjoint_timer_query;
  87032. /** Defines if timestamp can be used with timer query */
  87033. canUseTimestampForTimerQuery: boolean;
  87034. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  87035. multiview: any;
  87036. /** Function used to let the system compiles shaders in background */
  87037. parallelShaderCompile: {
  87038. COMPLETION_STATUS_KHR: number;
  87039. };
  87040. }
  87041. /** Interface defining initialization parameters for Engine class */
  87042. export interface EngineOptions extends WebGLContextAttributes {
  87043. /**
  87044. * Defines if the engine should no exceed a specified device ratio
  87045. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  87046. */
  87047. limitDeviceRatio?: number;
  87048. /**
  87049. * Defines if webvr should be enabled automatically
  87050. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87051. */
  87052. autoEnableWebVR?: boolean;
  87053. /**
  87054. * Defines if webgl2 should be turned off even if supported
  87055. * @see http://doc.babylonjs.com/features/webgl2
  87056. */
  87057. disableWebGL2Support?: boolean;
  87058. /**
  87059. * Defines if webaudio should be initialized as well
  87060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87061. */
  87062. audioEngine?: boolean;
  87063. /**
  87064. * Defines if animations should run using a deterministic lock step
  87065. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87066. */
  87067. deterministicLockstep?: boolean;
  87068. /** Defines the maximum steps to use with deterministic lock step mode */
  87069. lockstepMaxSteps?: number;
  87070. /**
  87071. * Defines that engine should ignore context lost events
  87072. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  87073. */
  87074. doNotHandleContextLost?: boolean;
  87075. /**
  87076. * Defines that engine should ignore modifying touch action attribute and style
  87077. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  87078. */
  87079. doNotHandleTouchAction?: boolean;
  87080. /**
  87081. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  87082. */
  87083. useHighPrecisionFloats?: boolean;
  87084. }
  87085. /**
  87086. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  87087. */
  87088. export class Engine {
  87089. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  87090. static ExceptionList: ({
  87091. key: string;
  87092. capture: string;
  87093. captureConstraint: number;
  87094. targets: string[];
  87095. } | {
  87096. key: string;
  87097. capture: null;
  87098. captureConstraint: null;
  87099. targets: string[];
  87100. })[];
  87101. /** Gets the list of created engines */
  87102. static readonly Instances: Engine[];
  87103. /**
  87104. * Gets the latest created engine
  87105. */
  87106. static readonly LastCreatedEngine: Nullable<Engine>;
  87107. /**
  87108. * Gets the latest created scene
  87109. */
  87110. static readonly LastCreatedScene: Nullable<Scene>;
  87111. /**
  87112. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  87113. * @param flag defines which part of the materials must be marked as dirty
  87114. * @param predicate defines a predicate used to filter which materials should be affected
  87115. */
  87116. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  87117. /**
  87118. * Hidden
  87119. */
  87120. static _TextureLoaders: IInternalTextureLoader[];
  87121. /** Defines that alpha blending is disabled */
  87122. static readonly ALPHA_DISABLE: number;
  87123. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  87124. static readonly ALPHA_ADD: number;
  87125. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  87126. static readonly ALPHA_COMBINE: number;
  87127. /** Defines that alpha blending to DEST - SRC * DEST */
  87128. static readonly ALPHA_SUBTRACT: number;
  87129. /** Defines that alpha blending to SRC * DEST */
  87130. static readonly ALPHA_MULTIPLY: number;
  87131. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  87132. static readonly ALPHA_MAXIMIZED: number;
  87133. /** Defines that alpha blending to SRC + DEST */
  87134. static readonly ALPHA_ONEONE: number;
  87135. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  87136. static readonly ALPHA_PREMULTIPLIED: number;
  87137. /**
  87138. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  87139. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  87140. */
  87141. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  87142. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  87143. static readonly ALPHA_INTERPOLATE: number;
  87144. /**
  87145. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  87146. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  87147. */
  87148. static readonly ALPHA_SCREENMODE: number;
  87149. /** Defines that the ressource is not delayed*/
  87150. static readonly DELAYLOADSTATE_NONE: number;
  87151. /** Defines that the ressource was successfully delay loaded */
  87152. static readonly DELAYLOADSTATE_LOADED: number;
  87153. /** Defines that the ressource is currently delay loading */
  87154. static readonly DELAYLOADSTATE_LOADING: number;
  87155. /** Defines that the ressource is delayed and has not started loading */
  87156. static readonly DELAYLOADSTATE_NOTLOADED: number;
  87157. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  87158. static readonly NEVER: number;
  87159. /** 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 */
  87160. static readonly ALWAYS: number;
  87161. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  87162. static readonly LESS: number;
  87163. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  87164. static readonly EQUAL: number;
  87165. /** 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 */
  87166. static readonly LEQUAL: number;
  87167. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  87168. static readonly GREATER: number;
  87169. /** 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 */
  87170. static readonly GEQUAL: number;
  87171. /** 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 */
  87172. static readonly NOTEQUAL: number;
  87173. /** Passed to stencilOperation to specify that stencil value must be kept */
  87174. static readonly KEEP: number;
  87175. /** Passed to stencilOperation to specify that stencil value must be replaced */
  87176. static readonly REPLACE: number;
  87177. /** Passed to stencilOperation to specify that stencil value must be incremented */
  87178. static readonly INCR: number;
  87179. /** Passed to stencilOperation to specify that stencil value must be decremented */
  87180. static readonly DECR: number;
  87181. /** Passed to stencilOperation to specify that stencil value must be inverted */
  87182. static readonly INVERT: number;
  87183. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  87184. static readonly INCR_WRAP: number;
  87185. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  87186. static readonly DECR_WRAP: number;
  87187. /** Texture is not repeating outside of 0..1 UVs */
  87188. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  87189. /** Texture is repeating outside of 0..1 UVs */
  87190. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  87191. /** Texture is repeating and mirrored */
  87192. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  87193. /** ALPHA */
  87194. static readonly TEXTUREFORMAT_ALPHA: number;
  87195. /** LUMINANCE */
  87196. static readonly TEXTUREFORMAT_LUMINANCE: number;
  87197. /** LUMINANCE_ALPHA */
  87198. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  87199. /** RGB */
  87200. static readonly TEXTUREFORMAT_RGB: number;
  87201. /** RGBA */
  87202. static readonly TEXTUREFORMAT_RGBA: number;
  87203. /** RED */
  87204. static readonly TEXTUREFORMAT_RED: number;
  87205. /** RED (2nd reference) */
  87206. static readonly TEXTUREFORMAT_R: number;
  87207. /** RG */
  87208. static readonly TEXTUREFORMAT_RG: number;
  87209. /** RED_INTEGER */
  87210. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  87211. /** RED_INTEGER (2nd reference) */
  87212. static readonly TEXTUREFORMAT_R_INTEGER: number;
  87213. /** RG_INTEGER */
  87214. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  87215. /** RGB_INTEGER */
  87216. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  87217. /** RGBA_INTEGER */
  87218. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  87219. /** UNSIGNED_BYTE */
  87220. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  87221. /** UNSIGNED_BYTE (2nd reference) */
  87222. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  87223. /** FLOAT */
  87224. static readonly TEXTURETYPE_FLOAT: number;
  87225. /** HALF_FLOAT */
  87226. static readonly TEXTURETYPE_HALF_FLOAT: number;
  87227. /** BYTE */
  87228. static readonly TEXTURETYPE_BYTE: number;
  87229. /** SHORT */
  87230. static readonly TEXTURETYPE_SHORT: number;
  87231. /** UNSIGNED_SHORT */
  87232. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  87233. /** INT */
  87234. static readonly TEXTURETYPE_INT: number;
  87235. /** UNSIGNED_INT */
  87236. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  87237. /** UNSIGNED_SHORT_4_4_4_4 */
  87238. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  87239. /** UNSIGNED_SHORT_5_5_5_1 */
  87240. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  87241. /** UNSIGNED_SHORT_5_6_5 */
  87242. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  87243. /** UNSIGNED_INT_2_10_10_10_REV */
  87244. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  87245. /** UNSIGNED_INT_24_8 */
  87246. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  87247. /** UNSIGNED_INT_10F_11F_11F_REV */
  87248. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  87249. /** UNSIGNED_INT_5_9_9_9_REV */
  87250. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  87251. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  87252. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  87253. /** nearest is mag = nearest and min = nearest and mip = linear */
  87254. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  87255. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87256. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  87257. /** Trilinear is mag = linear and min = linear and mip = linear */
  87258. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  87259. /** nearest is mag = nearest and min = nearest and mip = linear */
  87260. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  87261. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87262. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  87263. /** Trilinear is mag = linear and min = linear and mip = linear */
  87264. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  87265. /** mag = nearest and min = nearest and mip = nearest */
  87266. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  87267. /** mag = nearest and min = linear and mip = nearest */
  87268. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  87269. /** mag = nearest and min = linear and mip = linear */
  87270. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  87271. /** mag = nearest and min = linear and mip = none */
  87272. static readonly TEXTURE_NEAREST_LINEAR: number;
  87273. /** mag = nearest and min = nearest and mip = none */
  87274. static readonly TEXTURE_NEAREST_NEAREST: number;
  87275. /** mag = linear and min = nearest and mip = nearest */
  87276. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  87277. /** mag = linear and min = nearest and mip = linear */
  87278. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  87279. /** mag = linear and min = linear and mip = none */
  87280. static readonly TEXTURE_LINEAR_LINEAR: number;
  87281. /** mag = linear and min = nearest and mip = none */
  87282. static readonly TEXTURE_LINEAR_NEAREST: number;
  87283. /** Explicit coordinates mode */
  87284. static readonly TEXTURE_EXPLICIT_MODE: number;
  87285. /** Spherical coordinates mode */
  87286. static readonly TEXTURE_SPHERICAL_MODE: number;
  87287. /** Planar coordinates mode */
  87288. static readonly TEXTURE_PLANAR_MODE: number;
  87289. /** Cubic coordinates mode */
  87290. static readonly TEXTURE_CUBIC_MODE: number;
  87291. /** Projection coordinates mode */
  87292. static readonly TEXTURE_PROJECTION_MODE: number;
  87293. /** Skybox coordinates mode */
  87294. static readonly TEXTURE_SKYBOX_MODE: number;
  87295. /** Inverse Cubic coordinates mode */
  87296. static readonly TEXTURE_INVCUBIC_MODE: number;
  87297. /** Equirectangular coordinates mode */
  87298. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  87299. /** Equirectangular Fixed coordinates mode */
  87300. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  87301. /** Equirectangular Fixed Mirrored coordinates mode */
  87302. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87303. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  87304. static readonly SCALEMODE_FLOOR: number;
  87305. /** Defines that texture rescaling will look for the nearest power of 2 size */
  87306. static readonly SCALEMODE_NEAREST: number;
  87307. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  87308. static readonly SCALEMODE_CEILING: number;
  87309. /**
  87310. * Returns the current npm package of the sdk
  87311. */
  87312. static readonly NpmPackage: string;
  87313. /**
  87314. * Returns the current version of the framework
  87315. */
  87316. static readonly Version: string;
  87317. /**
  87318. * Returns a string describing the current engine
  87319. */
  87320. readonly description: string;
  87321. /**
  87322. * Gets or sets the epsilon value used by collision engine
  87323. */
  87324. static CollisionsEpsilon: number;
  87325. /**
  87326. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87327. */
  87328. static ShadersRepository: string;
  87329. /**
  87330. * Method called to create the default loading screen.
  87331. * This can be overriden in your own app.
  87332. * @param canvas The rendering canvas element
  87333. * @returns The loading screen
  87334. */
  87335. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  87336. /**
  87337. * Method called to create the default rescale post process on each engine.
  87338. */
  87339. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  87340. /**
  87341. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  87342. */
  87343. forcePOTTextures: boolean;
  87344. /**
  87345. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  87346. */
  87347. isFullscreen: boolean;
  87348. /**
  87349. * Gets a boolean indicating if the pointer is currently locked
  87350. */
  87351. isPointerLock: boolean;
  87352. /**
  87353. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  87354. */
  87355. cullBackFaces: boolean;
  87356. /**
  87357. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  87358. */
  87359. renderEvenInBackground: boolean;
  87360. /**
  87361. * Gets or sets a boolean indicating that cache can be kept between frames
  87362. */
  87363. preventCacheWipeBetweenFrames: boolean;
  87364. /**
  87365. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  87366. **/
  87367. enableOfflineSupport: boolean;
  87368. /**
  87369. * 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)
  87370. **/
  87371. disableManifestCheck: boolean;
  87372. /**
  87373. * Gets the list of created scenes
  87374. */
  87375. scenes: Scene[];
  87376. /**
  87377. * Event raised when a new scene is created
  87378. */
  87379. onNewSceneAddedObservable: Observable<Scene>;
  87380. /**
  87381. * Gets the list of created postprocesses
  87382. */
  87383. postProcesses: PostProcess[];
  87384. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  87385. validateShaderPrograms: boolean;
  87386. /**
  87387. * Observable event triggered each time the rendering canvas is resized
  87388. */
  87389. onResizeObservable: Observable<Engine>;
  87390. /**
  87391. * Observable event triggered each time the canvas loses focus
  87392. */
  87393. onCanvasBlurObservable: Observable<Engine>;
  87394. /**
  87395. * Observable event triggered each time the canvas gains focus
  87396. */
  87397. onCanvasFocusObservable: Observable<Engine>;
  87398. /**
  87399. * Observable event triggered each time the canvas receives pointerout event
  87400. */
  87401. onCanvasPointerOutObservable: Observable<PointerEvent>;
  87402. /**
  87403. * Observable event triggered before each texture is initialized
  87404. */
  87405. onBeforeTextureInitObservable: Observable<Texture>;
  87406. /**
  87407. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  87408. */
  87409. disableUniformBuffers: boolean;
  87410. /** @hidden */
  87411. _uniformBuffers: UniformBuffer[];
  87412. /**
  87413. * Gets a boolean indicating that the engine supports uniform buffers
  87414. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87415. */
  87416. readonly supportsUniformBuffers: boolean;
  87417. /**
  87418. * Observable raised when the engine begins a new frame
  87419. */
  87420. onBeginFrameObservable: Observable<Engine>;
  87421. /**
  87422. * If set, will be used to request the next animation frame for the render loop
  87423. */
  87424. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  87425. /**
  87426. * Observable raised when the engine ends the current frame
  87427. */
  87428. onEndFrameObservable: Observable<Engine>;
  87429. /**
  87430. * Observable raised when the engine is about to compile a shader
  87431. */
  87432. onBeforeShaderCompilationObservable: Observable<Engine>;
  87433. /**
  87434. * Observable raised when the engine has jsut compiled a shader
  87435. */
  87436. onAfterShaderCompilationObservable: Observable<Engine>;
  87437. /** @hidden */
  87438. _gl: WebGLRenderingContext;
  87439. private _renderingCanvas;
  87440. private _windowIsBackground;
  87441. private _webGLVersion;
  87442. protected _highPrecisionShadersAllowed: boolean;
  87443. /** @hidden */
  87444. readonly _shouldUseHighPrecisionShader: boolean;
  87445. /**
  87446. * Gets a boolean indicating that only power of 2 textures are supported
  87447. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87448. */
  87449. readonly needPOTTextures: boolean;
  87450. /** @hidden */
  87451. _badOS: boolean;
  87452. /** @hidden */
  87453. _badDesktopOS: boolean;
  87454. /**
  87455. * Gets the audio engine
  87456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87457. * @ignorenaming
  87458. */
  87459. static audioEngine: IAudioEngine;
  87460. /**
  87461. * Default AudioEngine factory responsible of creating the Audio Engine.
  87462. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87463. */
  87464. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87465. /**
  87466. * Default offline support factory responsible of creating a tool used to store data locally.
  87467. * By default, this will create a Database object if the workload has been embedded.
  87468. */
  87469. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87470. private _onFocus;
  87471. private _onBlur;
  87472. private _onCanvasPointerOut;
  87473. private _onCanvasBlur;
  87474. private _onCanvasFocus;
  87475. private _onFullscreenChange;
  87476. private _onPointerLockChange;
  87477. private _hardwareScalingLevel;
  87478. /** @hidden */
  87479. _caps: EngineCapabilities;
  87480. private _pointerLockRequested;
  87481. private _isStencilEnable;
  87482. private _colorWrite;
  87483. private _loadingScreen;
  87484. /** @hidden */
  87485. _drawCalls: PerfCounter;
  87486. private _glVersion;
  87487. private _glRenderer;
  87488. private _glVendor;
  87489. private _videoTextureSupported;
  87490. private _renderingQueueLaunched;
  87491. private _activeRenderLoops;
  87492. private _deterministicLockstep;
  87493. private _lockstepMaxSteps;
  87494. /**
  87495. * Observable signaled when a context lost event is raised
  87496. */
  87497. onContextLostObservable: Observable<Engine>;
  87498. /**
  87499. * Observable signaled when a context restored event is raised
  87500. */
  87501. onContextRestoredObservable: Observable<Engine>;
  87502. private _onContextLost;
  87503. private _onContextRestored;
  87504. private _contextWasLost;
  87505. /** @hidden */
  87506. _doNotHandleContextLost: boolean;
  87507. /**
  87508. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87509. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87510. */
  87511. doNotHandleContextLost: boolean;
  87512. private _performanceMonitor;
  87513. private _fps;
  87514. private _deltaTime;
  87515. /**
  87516. * Turn this value on if you want to pause FPS computation when in background
  87517. */
  87518. disablePerformanceMonitorInBackground: boolean;
  87519. /**
  87520. * Gets the performance monitor attached to this engine
  87521. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87522. */
  87523. readonly performanceMonitor: PerformanceMonitor;
  87524. /**
  87525. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87526. */
  87527. disableVertexArrayObjects: boolean;
  87528. /** @hidden */
  87529. protected _depthCullingState: _DepthCullingState;
  87530. /** @hidden */
  87531. protected _stencilState: _StencilState;
  87532. /** @hidden */
  87533. protected _alphaState: _AlphaState;
  87534. /** @hidden */
  87535. protected _alphaMode: number;
  87536. /** @hidden */
  87537. _internalTexturesCache: InternalTexture[];
  87538. /** @hidden */
  87539. protected _activeChannel: number;
  87540. private _currentTextureChannel;
  87541. /** @hidden */
  87542. protected _boundTexturesCache: {
  87543. [key: string]: Nullable<InternalTexture>;
  87544. };
  87545. /** @hidden */
  87546. protected _currentEffect: Nullable<Effect>;
  87547. /** @hidden */
  87548. protected _currentProgram: Nullable<WebGLProgram>;
  87549. private _compiledEffects;
  87550. private _vertexAttribArraysEnabled;
  87551. /** @hidden */
  87552. protected _cachedViewport: Nullable<Viewport>;
  87553. private _cachedVertexArrayObject;
  87554. /** @hidden */
  87555. protected _cachedVertexBuffers: any;
  87556. /** @hidden */
  87557. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  87558. /** @hidden */
  87559. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87560. /** @hidden */
  87561. _currentRenderTarget: Nullable<InternalTexture>;
  87562. private _uintIndicesCurrentlySet;
  87563. private _currentBoundBuffer;
  87564. /** @hidden */
  87565. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87566. private _currentBufferPointers;
  87567. private _currentInstanceLocations;
  87568. private _currentInstanceBuffers;
  87569. private _textureUnits;
  87570. /** @hidden */
  87571. _workingCanvas: Nullable<HTMLCanvasElement>;
  87572. /** @hidden */
  87573. _workingContext: Nullable<CanvasRenderingContext2D>;
  87574. private _rescalePostProcess;
  87575. private _dummyFramebuffer;
  87576. private _externalData;
  87577. /** @hidden */
  87578. _bindedRenderFunction: any;
  87579. private _vaoRecordInProgress;
  87580. private _mustWipeVertexAttributes;
  87581. private _emptyTexture;
  87582. private _emptyCubeTexture;
  87583. private _emptyTexture3D;
  87584. /** @hidden */
  87585. _frameHandler: number;
  87586. private _nextFreeTextureSlots;
  87587. private _maxSimultaneousTextures;
  87588. private _activeRequests;
  87589. private _texturesSupported;
  87590. /** @hidden */
  87591. _textureFormatInUse: Nullable<string>;
  87592. /**
  87593. * Gets the list of texture formats supported
  87594. */
  87595. readonly texturesSupported: Array<string>;
  87596. /**
  87597. * Gets the list of texture formats in use
  87598. */
  87599. readonly textureFormatInUse: Nullable<string>;
  87600. /**
  87601. * Gets the current viewport
  87602. */
  87603. readonly currentViewport: Nullable<Viewport>;
  87604. /**
  87605. * Gets the default empty texture
  87606. */
  87607. readonly emptyTexture: InternalTexture;
  87608. /**
  87609. * Gets the default empty 3D texture
  87610. */
  87611. readonly emptyTexture3D: InternalTexture;
  87612. /**
  87613. * Gets the default empty cube texture
  87614. */
  87615. readonly emptyCubeTexture: InternalTexture;
  87616. /**
  87617. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87618. */
  87619. readonly premultipliedAlpha: boolean;
  87620. /**
  87621. * Creates a new engine
  87622. * @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
  87623. * @param antialias defines enable antialiasing (default: false)
  87624. * @param options defines further options to be sent to the getContext() function
  87625. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87626. */
  87627. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87628. /**
  87629. * Initializes a webVR display and starts listening to display change events
  87630. * The onVRDisplayChangedObservable will be notified upon these changes
  87631. * @returns The onVRDisplayChangedObservable
  87632. */
  87633. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87634. /** @hidden */
  87635. _prepareVRComponent(): void;
  87636. /** @hidden */
  87637. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  87638. /** @hidden */
  87639. _submitVRFrame(): void;
  87640. /**
  87641. * Call this function to leave webVR mode
  87642. * Will do nothing if webVR is not supported or if there is no webVR device
  87643. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87644. */
  87645. disableVR(): void;
  87646. /**
  87647. * Gets a boolean indicating that the system is in VR mode and is presenting
  87648. * @returns true if VR mode is engaged
  87649. */
  87650. isVRPresenting(): boolean;
  87651. /** @hidden */
  87652. _requestVRFrame(): void;
  87653. private _disableTouchAction;
  87654. private _rebuildInternalTextures;
  87655. private _rebuildEffects;
  87656. /**
  87657. * Gets a boolean indicating if all created effects are ready
  87658. * @returns true if all effects are ready
  87659. */
  87660. areAllEffectsReady(): boolean;
  87661. private _rebuildBuffers;
  87662. private _initGLContext;
  87663. /**
  87664. * Gets version of the current webGL context
  87665. */
  87666. readonly webGLVersion: number;
  87667. /**
  87668. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87669. */
  87670. readonly isStencilEnable: boolean;
  87671. /** @hidden */
  87672. _prepareWorkingCanvas(): void;
  87673. /**
  87674. * Reset the texture cache to empty state
  87675. */
  87676. resetTextureCache(): void;
  87677. /**
  87678. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87679. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87680. * @returns true if engine is in deterministic lock step mode
  87681. */
  87682. isDeterministicLockStep(): boolean;
  87683. /**
  87684. * Gets the max steps when engine is running in deterministic lock step
  87685. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87686. * @returns the max steps
  87687. */
  87688. getLockstepMaxSteps(): number;
  87689. /**
  87690. * Gets an object containing information about the current webGL context
  87691. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87692. */
  87693. getGlInfo(): {
  87694. vendor: string;
  87695. renderer: string;
  87696. version: string;
  87697. };
  87698. /**
  87699. * Gets current aspect ratio
  87700. * @param camera defines the camera to use to get the aspect ratio
  87701. * @param useScreen defines if screen size must be used (or the current render target if any)
  87702. * @returns a number defining the aspect ratio
  87703. */
  87704. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87705. /**
  87706. * Gets current screen aspect ratio
  87707. * @returns a number defining the aspect ratio
  87708. */
  87709. getScreenAspectRatio(): number;
  87710. /**
  87711. * Gets the current render width
  87712. * @param useScreen defines if screen size must be used (or the current render target if any)
  87713. * @returns a number defining the current render width
  87714. */
  87715. getRenderWidth(useScreen?: boolean): number;
  87716. /**
  87717. * Gets the current render height
  87718. * @param useScreen defines if screen size must be used (or the current render target if any)
  87719. * @returns a number defining the current render height
  87720. */
  87721. getRenderHeight(useScreen?: boolean): number;
  87722. /**
  87723. * Gets the HTML canvas attached with the current webGL context
  87724. * @returns a HTML canvas
  87725. */
  87726. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87727. /**
  87728. * Gets the client rect of the HTML canvas attached with the current webGL context
  87729. * @returns a client rectanglee
  87730. */
  87731. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87732. /**
  87733. * Defines the hardware scaling level.
  87734. * By default the hardware scaling level is computed from the window device ratio.
  87735. * 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.
  87736. * @param level defines the level to use
  87737. */
  87738. setHardwareScalingLevel(level: number): void;
  87739. /**
  87740. * Gets the current hardware scaling level.
  87741. * By default the hardware scaling level is computed from the window device ratio.
  87742. * 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.
  87743. * @returns a number indicating the current hardware scaling level
  87744. */
  87745. getHardwareScalingLevel(): number;
  87746. /**
  87747. * Gets the list of loaded textures
  87748. * @returns an array containing all loaded textures
  87749. */
  87750. getLoadedTexturesCache(): InternalTexture[];
  87751. /**
  87752. * Gets the object containing all engine capabilities
  87753. * @returns the EngineCapabilities object
  87754. */
  87755. getCaps(): EngineCapabilities;
  87756. /**
  87757. * Gets the current depth function
  87758. * @returns a number defining the depth function
  87759. */
  87760. getDepthFunction(): Nullable<number>;
  87761. /**
  87762. * Sets the current depth function
  87763. * @param depthFunc defines the function to use
  87764. */
  87765. setDepthFunction(depthFunc: number): void;
  87766. /**
  87767. * Sets the current depth function to GREATER
  87768. */
  87769. setDepthFunctionToGreater(): void;
  87770. /**
  87771. * Sets the current depth function to GEQUAL
  87772. */
  87773. setDepthFunctionToGreaterOrEqual(): void;
  87774. /**
  87775. * Sets the current depth function to LESS
  87776. */
  87777. setDepthFunctionToLess(): void;
  87778. private _cachedStencilBuffer;
  87779. private _cachedStencilFunction;
  87780. private _cachedStencilMask;
  87781. private _cachedStencilOperationPass;
  87782. private _cachedStencilOperationFail;
  87783. private _cachedStencilOperationDepthFail;
  87784. private _cachedStencilReference;
  87785. /**
  87786. * Caches the the state of the stencil buffer
  87787. */
  87788. cacheStencilState(): void;
  87789. /**
  87790. * Restores the state of the stencil buffer
  87791. */
  87792. restoreStencilState(): void;
  87793. /**
  87794. * Sets the current depth function to LEQUAL
  87795. */
  87796. setDepthFunctionToLessOrEqual(): void;
  87797. /**
  87798. * Gets a boolean indicating if stencil buffer is enabled
  87799. * @returns the current stencil buffer state
  87800. */
  87801. getStencilBuffer(): boolean;
  87802. /**
  87803. * Enable or disable the stencil buffer
  87804. * @param enable defines if the stencil buffer must be enabled or disabled
  87805. */
  87806. setStencilBuffer(enable: boolean): void;
  87807. /**
  87808. * Gets the current stencil mask
  87809. * @returns a number defining the new stencil mask to use
  87810. */
  87811. getStencilMask(): number;
  87812. /**
  87813. * Sets the current stencil mask
  87814. * @param mask defines the new stencil mask to use
  87815. */
  87816. setStencilMask(mask: number): void;
  87817. /**
  87818. * Gets the current stencil function
  87819. * @returns a number defining the stencil function to use
  87820. */
  87821. getStencilFunction(): number;
  87822. /**
  87823. * Gets the current stencil reference value
  87824. * @returns a number defining the stencil reference value to use
  87825. */
  87826. getStencilFunctionReference(): number;
  87827. /**
  87828. * Gets the current stencil mask
  87829. * @returns a number defining the stencil mask to use
  87830. */
  87831. getStencilFunctionMask(): number;
  87832. /**
  87833. * Sets the current stencil function
  87834. * @param stencilFunc defines the new stencil function to use
  87835. */
  87836. setStencilFunction(stencilFunc: number): void;
  87837. /**
  87838. * Sets the current stencil reference
  87839. * @param reference defines the new stencil reference to use
  87840. */
  87841. setStencilFunctionReference(reference: number): void;
  87842. /**
  87843. * Sets the current stencil mask
  87844. * @param mask defines the new stencil mask to use
  87845. */
  87846. setStencilFunctionMask(mask: number): void;
  87847. /**
  87848. * Gets the current stencil operation when stencil fails
  87849. * @returns a number defining stencil operation to use when stencil fails
  87850. */
  87851. getStencilOperationFail(): number;
  87852. /**
  87853. * Gets the current stencil operation when depth fails
  87854. * @returns a number defining stencil operation to use when depth fails
  87855. */
  87856. getStencilOperationDepthFail(): number;
  87857. /**
  87858. * Gets the current stencil operation when stencil passes
  87859. * @returns a number defining stencil operation to use when stencil passes
  87860. */
  87861. getStencilOperationPass(): number;
  87862. /**
  87863. * Sets the stencil operation to use when stencil fails
  87864. * @param operation defines the stencil operation to use when stencil fails
  87865. */
  87866. setStencilOperationFail(operation: number): void;
  87867. /**
  87868. * Sets the stencil operation to use when depth fails
  87869. * @param operation defines the stencil operation to use when depth fails
  87870. */
  87871. setStencilOperationDepthFail(operation: number): void;
  87872. /**
  87873. * Sets the stencil operation to use when stencil passes
  87874. * @param operation defines the stencil operation to use when stencil passes
  87875. */
  87876. setStencilOperationPass(operation: number): void;
  87877. /**
  87878. * Sets a boolean indicating if the dithering state is enabled or disabled
  87879. * @param value defines the dithering state
  87880. */
  87881. setDitheringState(value: boolean): void;
  87882. /**
  87883. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87884. * @param value defines the rasterizer state
  87885. */
  87886. setRasterizerState(value: boolean): void;
  87887. /**
  87888. * stop executing a render loop function and remove it from the execution array
  87889. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87890. */
  87891. stopRenderLoop(renderFunction?: () => void): void;
  87892. /** @hidden */
  87893. _renderLoop(): void;
  87894. /**
  87895. * Register and execute a render loop. The engine can have more than one render function
  87896. * @param renderFunction defines the function to continuously execute
  87897. */
  87898. runRenderLoop(renderFunction: () => void): void;
  87899. /**
  87900. * Toggle full screen mode
  87901. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87902. */
  87903. switchFullscreen(requestPointerLock: boolean): void;
  87904. /**
  87905. * Enters full screen mode
  87906. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87907. */
  87908. enterFullscreen(requestPointerLock: boolean): void;
  87909. /**
  87910. * Exits full screen mode
  87911. */
  87912. exitFullscreen(): void;
  87913. /**
  87914. * Clear the current render buffer or the current render target (if any is set up)
  87915. * @param color defines the color to use
  87916. * @param backBuffer defines if the back buffer must be cleared
  87917. * @param depth defines if the depth buffer must be cleared
  87918. * @param stencil defines if the stencil buffer must be cleared
  87919. */
  87920. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87921. /**
  87922. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87923. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87924. * @param y defines the y-coordinate of the corner of the clear rectangle
  87925. * @param width defines the width of the clear rectangle
  87926. * @param height defines the height of the clear rectangle
  87927. * @param clearColor defines the clear color
  87928. */
  87929. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87930. /**
  87931. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87932. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87933. * @param y defines the y-coordinate of the corner of the clear rectangle
  87934. * @param width defines the width of the clear rectangle
  87935. * @param height defines the height of the clear rectangle
  87936. */
  87937. enableScissor(x: number, y: number, width: number, height: number): void;
  87938. /**
  87939. * Disable previously set scissor test rectangle
  87940. */
  87941. disableScissor(): void;
  87942. private _viewportCached;
  87943. /** @hidden */
  87944. _viewport(x: number, y: number, width: number, height: number): void;
  87945. /**
  87946. * Set the WebGL's viewport
  87947. * @param viewport defines the viewport element to be used
  87948. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87949. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87950. */
  87951. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87952. /**
  87953. * Directly set the WebGL Viewport
  87954. * @param x defines the x coordinate of the viewport (in screen space)
  87955. * @param y defines the y coordinate of the viewport (in screen space)
  87956. * @param width defines the width of the viewport (in screen space)
  87957. * @param height defines the height of the viewport (in screen space)
  87958. * @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
  87959. */
  87960. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87961. /**
  87962. * Begin a new frame
  87963. */
  87964. beginFrame(): void;
  87965. /**
  87966. * Enf the current frame
  87967. */
  87968. endFrame(): void;
  87969. /**
  87970. * Resize the view according to the canvas' size
  87971. */
  87972. resize(): void;
  87973. /**
  87974. * Force a specific size of the canvas
  87975. * @param width defines the new canvas' width
  87976. * @param height defines the new canvas' height
  87977. */
  87978. setSize(width: number, height: number): void;
  87979. /**
  87980. * Binds the frame buffer to the specified texture.
  87981. * @param texture The texture to render to or null for the default canvas
  87982. * @param faceIndex The face of the texture to render to in case of cube texture
  87983. * @param requiredWidth The width of the target to render to
  87984. * @param requiredHeight The height of the target to render to
  87985. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87986. * @param depthStencilTexture The depth stencil texture to use to render
  87987. * @param lodLevel defines le lod level to bind to the frame buffer
  87988. */
  87989. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  87990. /** @hidden */
  87991. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  87992. /**
  87993. * Unbind the current render target texture from the webGL context
  87994. * @param texture defines the render target texture to unbind
  87995. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87996. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87997. */
  87998. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87999. /**
  88000. * Force the mipmap generation for the given render target texture
  88001. * @param texture defines the render target texture to use
  88002. */
  88003. generateMipMapsForCubemap(texture: InternalTexture): void;
  88004. /**
  88005. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  88006. */
  88007. flushFramebuffer(): void;
  88008. /**
  88009. * Unbind the current render target and bind the default framebuffer
  88010. */
  88011. restoreDefaultFramebuffer(): void;
  88012. /**
  88013. * Create an uniform buffer
  88014. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88015. * @param elements defines the content of the uniform buffer
  88016. * @returns the webGL uniform buffer
  88017. */
  88018. createUniformBuffer(elements: FloatArray): DataBuffer;
  88019. /**
  88020. * Create a dynamic uniform buffer
  88021. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88022. * @param elements defines the content of the uniform buffer
  88023. * @returns the webGL uniform buffer
  88024. */
  88025. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88026. /**
  88027. * Update an existing uniform buffer
  88028. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88029. * @param uniformBuffer defines the target uniform buffer
  88030. * @param elements defines the content to update
  88031. * @param offset defines the offset in the uniform buffer where update should start
  88032. * @param count defines the size of the data to update
  88033. */
  88034. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88035. private _resetVertexBufferBinding;
  88036. /**
  88037. * Creates a vertex buffer
  88038. * @param data the data for the vertex buffer
  88039. * @returns the new WebGL static buffer
  88040. */
  88041. createVertexBuffer(data: DataArray): DataBuffer;
  88042. /**
  88043. * Creates a dynamic vertex buffer
  88044. * @param data the data for the dynamic vertex buffer
  88045. * @returns the new WebGL dynamic buffer
  88046. */
  88047. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  88048. /**
  88049. * Update a dynamic index buffer
  88050. * @param indexBuffer defines the target index buffer
  88051. * @param indices defines the data to update
  88052. * @param offset defines the offset in the target index buffer where update should start
  88053. */
  88054. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  88055. /**
  88056. * Updates a dynamic vertex buffer.
  88057. * @param vertexBuffer the vertex buffer to update
  88058. * @param data the data used to update the vertex buffer
  88059. * @param byteOffset the byte offset of the data
  88060. * @param byteLength the byte length of the data
  88061. */
  88062. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  88063. private _resetIndexBufferBinding;
  88064. /**
  88065. * Creates a new index buffer
  88066. * @param indices defines the content of the index buffer
  88067. * @param updatable defines if the index buffer must be updatable
  88068. * @returns a new webGL buffer
  88069. */
  88070. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  88071. /**
  88072. * Bind a webGL buffer to the webGL context
  88073. * @param buffer defines the buffer to bind
  88074. */
  88075. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  88076. /**
  88077. * Bind an uniform buffer to the current webGL context
  88078. * @param buffer defines the buffer to bind
  88079. */
  88080. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88081. /**
  88082. * Bind a buffer to the current webGL context at a given location
  88083. * @param buffer defines the buffer to bind
  88084. * @param location defines the index where to bind the buffer
  88085. */
  88086. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88087. /**
  88088. * Bind a specific block at a given index in a specific shader program
  88089. * @param pipelineContext defines the pipeline context to use
  88090. * @param blockName defines the block name
  88091. * @param index defines the index where to bind the block
  88092. */
  88093. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88094. private bindIndexBuffer;
  88095. private bindBuffer;
  88096. /**
  88097. * update the bound buffer with the given data
  88098. * @param data defines the data to update
  88099. */
  88100. updateArrayBuffer(data: Float32Array): void;
  88101. private _vertexAttribPointer;
  88102. private _bindIndexBufferWithCache;
  88103. private _bindVertexBuffersAttributes;
  88104. /**
  88105. * Records a vertex array object
  88106. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88107. * @param vertexBuffers defines the list of vertex buffers to store
  88108. * @param indexBuffer defines the index buffer to store
  88109. * @param effect defines the effect to store
  88110. * @returns the new vertex array object
  88111. */
  88112. recordVertexArrayObject(vertexBuffers: {
  88113. [key: string]: VertexBuffer;
  88114. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  88115. /**
  88116. * Bind a specific vertex array object
  88117. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88118. * @param vertexArrayObject defines the vertex array object to bind
  88119. * @param indexBuffer defines the index buffer to bind
  88120. */
  88121. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  88122. /**
  88123. * Bind webGl buffers directly to the webGL context
  88124. * @param vertexBuffer defines the vertex buffer to bind
  88125. * @param indexBuffer defines the index buffer to bind
  88126. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  88127. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  88128. * @param effect defines the effect associated with the vertex buffer
  88129. */
  88130. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  88131. private _unbindVertexArrayObject;
  88132. /**
  88133. * Bind a list of vertex buffers to the webGL context
  88134. * @param vertexBuffers defines the list of vertex buffers to bind
  88135. * @param indexBuffer defines the index buffer to bind
  88136. * @param effect defines the effect associated with the vertex buffers
  88137. */
  88138. bindBuffers(vertexBuffers: {
  88139. [key: string]: Nullable<VertexBuffer>;
  88140. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  88141. /**
  88142. * Unbind all instance attributes
  88143. */
  88144. unbindInstanceAttributes(): void;
  88145. /**
  88146. * Release and free the memory of a vertex array object
  88147. * @param vao defines the vertex array object to delete
  88148. */
  88149. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  88150. /** @hidden */
  88151. _releaseBuffer(buffer: DataBuffer): boolean;
  88152. /**
  88153. * Creates a webGL buffer to use with instanciation
  88154. * @param capacity defines the size of the buffer
  88155. * @returns the webGL buffer
  88156. */
  88157. createInstancesBuffer(capacity: number): DataBuffer;
  88158. /**
  88159. * Delete a webGL buffer used with instanciation
  88160. * @param buffer defines the webGL buffer to delete
  88161. */
  88162. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  88163. /**
  88164. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  88165. * @param instancesBuffer defines the webGL buffer to update and bind
  88166. * @param data defines the data to store in the buffer
  88167. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  88168. */
  88169. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  88170. /**
  88171. * Apply all cached states (depth, culling, stencil and alpha)
  88172. */
  88173. applyStates(): void;
  88174. /**
  88175. * Send a draw order
  88176. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88177. * @param indexStart defines the starting index
  88178. * @param indexCount defines the number of index to draw
  88179. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88180. */
  88181. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  88182. /**
  88183. * Draw a list of points
  88184. * @param verticesStart defines the index of first vertex to draw
  88185. * @param verticesCount defines the count of vertices to draw
  88186. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88187. */
  88188. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88189. /**
  88190. * Draw a list of unindexed primitives
  88191. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88192. * @param verticesStart defines the index of first vertex to draw
  88193. * @param verticesCount defines the count of vertices to draw
  88194. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88195. */
  88196. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88197. /**
  88198. * Draw a list of indexed primitives
  88199. * @param fillMode defines the primitive to use
  88200. * @param indexStart defines the starting index
  88201. * @param indexCount defines the number of index to draw
  88202. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88203. */
  88204. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  88205. /**
  88206. * Draw a list of unindexed primitives
  88207. * @param fillMode defines the primitive to use
  88208. * @param verticesStart defines the index of first vertex to draw
  88209. * @param verticesCount defines the count of vertices to draw
  88210. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88211. */
  88212. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88213. private _drawMode;
  88214. /** @hidden */
  88215. _releaseEffect(effect: Effect): void;
  88216. /** @hidden */
  88217. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  88218. /**
  88219. * Create a new effect (used to store vertex/fragment shaders)
  88220. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  88221. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  88222. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  88223. * @param samplers defines an array of string used to represent textures
  88224. * @param defines defines the string containing the defines to use to compile the shaders
  88225. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  88226. * @param onCompiled defines a function to call when the effect creation is successful
  88227. * @param onError defines a function to call when the effect creation has failed
  88228. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  88229. * @returns the new Effect
  88230. */
  88231. 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;
  88232. private _compileShader;
  88233. private _compileRawShader;
  88234. /**
  88235. * Directly creates a webGL program
  88236. * @param pipelineContext defines the pipeline context to attach to
  88237. * @param vertexCode defines the vertex shader code to use
  88238. * @param fragmentCode defines the fragment shader code to use
  88239. * @param context defines the webGL context to use (if not set, the current one will be used)
  88240. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88241. * @returns the new webGL program
  88242. */
  88243. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88244. /**
  88245. * Creates a webGL program
  88246. * @param pipelineContext defines the pipeline context to attach to
  88247. * @param vertexCode defines the vertex shader code to use
  88248. * @param fragmentCode defines the fragment shader code to use
  88249. * @param defines defines the string containing the defines to use to compile the shaders
  88250. * @param context defines the webGL context to use (if not set, the current one will be used)
  88251. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88252. * @returns the new webGL program
  88253. */
  88254. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88255. /**
  88256. * Creates a new pipeline context
  88257. * @returns the new pipeline
  88258. */
  88259. createPipelineContext(): WebGLPipelineContext;
  88260. private _createShaderProgram;
  88261. private _finalizePipelineContext;
  88262. /** @hidden */
  88263. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  88264. /** @hidden */
  88265. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  88266. /** @hidden */
  88267. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  88268. /**
  88269. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  88270. * @param pipelineContext defines the pipeline context to use
  88271. * @param uniformsNames defines the list of uniform names
  88272. * @returns an array of webGL uniform locations
  88273. */
  88274. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  88275. /**
  88276. * Gets the lsit of active attributes for a given webGL program
  88277. * @param pipelineContext defines the pipeline context to use
  88278. * @param attributesNames defines the list of attribute names to get
  88279. * @returns an array of indices indicating the offset of each attribute
  88280. */
  88281. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  88282. /**
  88283. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  88284. * @param effect defines the effect to activate
  88285. */
  88286. enableEffect(effect: Nullable<Effect>): void;
  88287. /**
  88288. * Set the value of an uniform to an array of int32
  88289. * @param uniform defines the webGL uniform location where to store the value
  88290. * @param array defines the array of int32 to store
  88291. */
  88292. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88293. /**
  88294. * Set the value of an uniform to an array of int32 (stored as vec2)
  88295. * @param uniform defines the webGL uniform location where to store the value
  88296. * @param array defines the array of int32 to store
  88297. */
  88298. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88299. /**
  88300. * Set the value of an uniform to an array of int32 (stored as vec3)
  88301. * @param uniform defines the webGL uniform location where to store the value
  88302. * @param array defines the array of int32 to store
  88303. */
  88304. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88305. /**
  88306. * Set the value of an uniform to an array of int32 (stored as vec4)
  88307. * @param uniform defines the webGL uniform location where to store the value
  88308. * @param array defines the array of int32 to store
  88309. */
  88310. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88311. /**
  88312. * Set the value of an uniform to an array of float32
  88313. * @param uniform defines the webGL uniform location where to store the value
  88314. * @param array defines the array of float32 to store
  88315. */
  88316. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88317. /**
  88318. * Set the value of an uniform to an array of float32 (stored as vec2)
  88319. * @param uniform defines the webGL uniform location where to store the value
  88320. * @param array defines the array of float32 to store
  88321. */
  88322. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88323. /**
  88324. * Set the value of an uniform to an array of float32 (stored as vec3)
  88325. * @param uniform defines the webGL uniform location where to store the value
  88326. * @param array defines the array of float32 to store
  88327. */
  88328. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88329. /**
  88330. * Set the value of an uniform to an array of float32 (stored as vec4)
  88331. * @param uniform defines the webGL uniform location where to store the value
  88332. * @param array defines the array of float32 to store
  88333. */
  88334. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88335. /**
  88336. * Set the value of an uniform to an array of number
  88337. * @param uniform defines the webGL uniform location where to store the value
  88338. * @param array defines the array of number to store
  88339. */
  88340. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88341. /**
  88342. * Set the value of an uniform to an array of number (stored as vec2)
  88343. * @param uniform defines the webGL uniform location where to store the value
  88344. * @param array defines the array of number to store
  88345. */
  88346. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88347. /**
  88348. * Set the value of an uniform to an array of number (stored as vec3)
  88349. * @param uniform defines the webGL uniform location where to store the value
  88350. * @param array defines the array of number to store
  88351. */
  88352. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88353. /**
  88354. * Set the value of an uniform to an array of number (stored as vec4)
  88355. * @param uniform defines the webGL uniform location where to store the value
  88356. * @param array defines the array of number to store
  88357. */
  88358. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88359. /**
  88360. * Set the value of an uniform to an array of float32 (stored as matrices)
  88361. * @param uniform defines the webGL uniform location where to store the value
  88362. * @param matrices defines the array of float32 to store
  88363. */
  88364. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  88365. /**
  88366. * Set the value of an uniform to a matrix
  88367. * @param uniform defines the webGL uniform location where to store the value
  88368. * @param matrix defines the matrix to store
  88369. */
  88370. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  88371. /**
  88372. * Set the value of an uniform to a matrix (3x3)
  88373. * @param uniform defines the webGL uniform location where to store the value
  88374. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  88375. */
  88376. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88377. /**
  88378. * Set the value of an uniform to a matrix (2x2)
  88379. * @param uniform defines the webGL uniform location where to store the value
  88380. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  88381. */
  88382. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88383. /**
  88384. * Set the value of an uniform to a number (int)
  88385. * @param uniform defines the webGL uniform location where to store the value
  88386. * @param value defines the int number to store
  88387. */
  88388. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88389. /**
  88390. * Set the value of an uniform to a number (float)
  88391. * @param uniform defines the webGL uniform location where to store the value
  88392. * @param value defines the float number to store
  88393. */
  88394. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88395. /**
  88396. * Set the value of an uniform to a vec2
  88397. * @param uniform defines the webGL uniform location where to store the value
  88398. * @param x defines the 1st component of the value
  88399. * @param y defines the 2nd component of the value
  88400. */
  88401. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  88402. /**
  88403. * Set the value of an uniform to a vec3
  88404. * @param uniform defines the webGL uniform location where to store the value
  88405. * @param x defines the 1st component of the value
  88406. * @param y defines the 2nd component of the value
  88407. * @param z defines the 3rd component of the value
  88408. */
  88409. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88410. /**
  88411. * Set the value of an uniform to a boolean
  88412. * @param uniform defines the webGL uniform location where to store the value
  88413. * @param bool defines the boolean to store
  88414. */
  88415. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88416. /**
  88417. * Set the value of an uniform to a vec4
  88418. * @param uniform defines the webGL uniform location where to store the value
  88419. * @param x defines the 1st component of the value
  88420. * @param y defines the 2nd component of the value
  88421. * @param z defines the 3rd component of the value
  88422. * @param w defines the 4th component of the value
  88423. */
  88424. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88425. /**
  88426. * Set the value of an uniform to a Color3
  88427. * @param uniform defines the webGL uniform location where to store the value
  88428. * @param color3 defines the color to store
  88429. */
  88430. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88431. /**
  88432. * Set the value of an uniform to a Color3 and an alpha value
  88433. * @param uniform defines the webGL uniform location where to store the value
  88434. * @param color3 defines the color to store
  88435. * @param alpha defines the alpha component to store
  88436. */
  88437. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88438. /**
  88439. * Sets a Color4 on a uniform variable
  88440. * @param uniform defines the uniform location
  88441. * @param color4 defines the value to be set
  88442. */
  88443. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88444. /**
  88445. * Set various states to the webGL context
  88446. * @param culling defines backface culling state
  88447. * @param zOffset defines the value to apply to zOffset (0 by default)
  88448. * @param force defines if states must be applied even if cache is up to date
  88449. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88450. */
  88451. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88452. /**
  88453. * Set the z offset to apply to current rendering
  88454. * @param value defines the offset to apply
  88455. */
  88456. setZOffset(value: number): void;
  88457. /**
  88458. * Gets the current value of the zOffset
  88459. * @returns the current zOffset state
  88460. */
  88461. getZOffset(): number;
  88462. /**
  88463. * Enable or disable depth buffering
  88464. * @param enable defines the state to set
  88465. */
  88466. setDepthBuffer(enable: boolean): void;
  88467. /**
  88468. * Gets a boolean indicating if depth writing is enabled
  88469. * @returns the current depth writing state
  88470. */
  88471. getDepthWrite(): boolean;
  88472. /**
  88473. * Enable or disable depth writing
  88474. * @param enable defines the state to set
  88475. */
  88476. setDepthWrite(enable: boolean): void;
  88477. /**
  88478. * Enable or disable color writing
  88479. * @param enable defines the state to set
  88480. */
  88481. setColorWrite(enable: boolean): void;
  88482. /**
  88483. * Gets a boolean indicating if color writing is enabled
  88484. * @returns the current color writing state
  88485. */
  88486. getColorWrite(): boolean;
  88487. /**
  88488. * Sets alpha constants used by some alpha blending modes
  88489. * @param r defines the red component
  88490. * @param g defines the green component
  88491. * @param b defines the blue component
  88492. * @param a defines the alpha component
  88493. */
  88494. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88495. /**
  88496. * Sets the current alpha mode
  88497. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88498. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88499. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88500. */
  88501. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88502. /**
  88503. * Gets the current alpha mode
  88504. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88505. * @returns the current alpha mode
  88506. */
  88507. getAlphaMode(): number;
  88508. /**
  88509. * Clears the list of texture accessible through engine.
  88510. * This can help preventing texture load conflict due to name collision.
  88511. */
  88512. clearInternalTexturesCache(): void;
  88513. /**
  88514. * Force the entire cache to be cleared
  88515. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88516. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88517. */
  88518. wipeCaches(bruteForce?: boolean): void;
  88519. /**
  88520. * Set the compressed texture format to use, based on the formats you have, and the formats
  88521. * supported by the hardware / browser.
  88522. *
  88523. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88524. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88525. * to API arguments needed to compressed textures. This puts the burden on the container
  88526. * generator to house the arcane code for determining these for current & future formats.
  88527. *
  88528. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88529. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88530. *
  88531. * Note: The result of this call is not taken into account when a texture is base64.
  88532. *
  88533. * @param formatsAvailable defines the list of those format families you have created
  88534. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88535. *
  88536. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88537. * @returns The extension selected.
  88538. */
  88539. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88540. /** @hidden */
  88541. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88542. min: number;
  88543. mag: number;
  88544. };
  88545. /** @hidden */
  88546. _createTexture(): WebGLTexture;
  88547. /**
  88548. * Usually called from Texture.ts.
  88549. * Passed information to create a WebGLTexture
  88550. * @param urlArg defines a value which contains one of the following:
  88551. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88552. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88553. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88554. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88555. * @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)
  88556. * @param scene needed for loading to the correct scene
  88557. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88558. * @param onLoad optional callback to be called upon successful completion
  88559. * @param onError optional callback to be called upon failure
  88560. * @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
  88561. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88562. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88563. * @param forcedExtension defines the extension to use to pick the right loader
  88564. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88565. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88566. */
  88567. 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;
  88568. private _rescaleTexture;
  88569. private _unpackFlipYCached;
  88570. /**
  88571. * In case you are sharing the context with other applications, it might
  88572. * be interested to not cache the unpack flip y state to ensure a consistent
  88573. * value would be set.
  88574. */
  88575. enableUnpackFlipYCached: boolean;
  88576. /** @hidden */
  88577. _unpackFlipY(value: boolean): void;
  88578. /** @hidden */
  88579. _getUnpackAlignement(): number;
  88580. /**
  88581. * Creates a dynamic texture
  88582. * @param width defines the width of the texture
  88583. * @param height defines the height of the texture
  88584. * @param generateMipMaps defines if the engine should generate the mip levels
  88585. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88586. * @returns the dynamic texture inside an InternalTexture
  88587. */
  88588. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88589. /**
  88590. * Update the sampling mode of a given texture
  88591. * @param samplingMode defines the required sampling mode
  88592. * @param texture defines the texture to update
  88593. */
  88594. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88595. /**
  88596. * Update the content of a dynamic texture
  88597. * @param texture defines the texture to update
  88598. * @param canvas defines the canvas containing the source
  88599. * @param invertY defines if data must be stored with Y axis inverted
  88600. * @param premulAlpha defines if alpha is stored as premultiplied
  88601. * @param format defines the format of the data
  88602. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88603. */
  88604. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88605. /**
  88606. * Update a video texture
  88607. * @param texture defines the texture to update
  88608. * @param video defines the video element to use
  88609. * @param invertY defines if data must be stored with Y axis inverted
  88610. */
  88611. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88612. /**
  88613. * Updates a depth texture Comparison Mode and Function.
  88614. * If the comparison Function is equal to 0, the mode will be set to none.
  88615. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88616. * @param texture The texture to set the comparison function for
  88617. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88618. */
  88619. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88620. /** @hidden */
  88621. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88622. width: number;
  88623. height: number;
  88624. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88625. /**
  88626. * Creates a depth stencil texture.
  88627. * This is only available in WebGL 2 or with the depth texture extension available.
  88628. * @param size The size of face edge in the texture.
  88629. * @param options The options defining the texture.
  88630. * @returns The texture
  88631. */
  88632. createDepthStencilTexture(size: number | {
  88633. width: number;
  88634. height: number;
  88635. }, options: DepthTextureCreationOptions): InternalTexture;
  88636. /**
  88637. * Creates a depth stencil texture.
  88638. * This is only available in WebGL 2 or with the depth texture extension available.
  88639. * @param size The size of face edge in the texture.
  88640. * @param options The options defining the texture.
  88641. * @returns The texture
  88642. */
  88643. private _createDepthStencilTexture;
  88644. /**
  88645. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88646. * @param renderTarget The render target to set the frame buffer for
  88647. */
  88648. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88649. /**
  88650. * Creates a new render target texture
  88651. * @param size defines the size of the texture
  88652. * @param options defines the options used to create the texture
  88653. * @returns a new render target texture stored in an InternalTexture
  88654. */
  88655. createRenderTargetTexture(size: number | {
  88656. width: number;
  88657. height: number;
  88658. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88659. /** @hidden */
  88660. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88661. /**
  88662. * Updates the sample count of a render target texture
  88663. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88664. * @param texture defines the texture to update
  88665. * @param samples defines the sample count to set
  88666. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88667. */
  88668. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88669. /** @hidden */
  88670. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88671. /** @hidden */
  88672. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88673. /** @hidden */
  88674. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88675. /** @hidden */
  88676. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88677. /**
  88678. * @hidden
  88679. */
  88680. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88681. private _prepareWebGLTextureContinuation;
  88682. private _prepareWebGLTexture;
  88683. /** @hidden */
  88684. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88685. /** @hidden */
  88686. _releaseFramebufferObjects(texture: InternalTexture): void;
  88687. /** @hidden */
  88688. _releaseTexture(texture: InternalTexture): void;
  88689. private setProgram;
  88690. private _boundUniforms;
  88691. /**
  88692. * Binds an effect to the webGL context
  88693. * @param effect defines the effect to bind
  88694. */
  88695. bindSamplers(effect: Effect): void;
  88696. private _activateCurrentTexture;
  88697. /** @hidden */
  88698. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88699. /** @hidden */
  88700. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88701. /**
  88702. * Sets a texture to the webGL context from a postprocess
  88703. * @param channel defines the channel to use
  88704. * @param postProcess defines the source postprocess
  88705. */
  88706. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88707. /**
  88708. * Binds the output of the passed in post process to the texture channel specified
  88709. * @param channel The channel the texture should be bound to
  88710. * @param postProcess The post process which's output should be bound
  88711. */
  88712. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88713. /**
  88714. * Unbind all textures from the webGL context
  88715. */
  88716. unbindAllTextures(): void;
  88717. /**
  88718. * Sets a texture to the according uniform.
  88719. * @param channel The texture channel
  88720. * @param uniform The uniform to set
  88721. * @param texture The texture to apply
  88722. */
  88723. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88724. /**
  88725. * Sets a depth stencil texture from a render target to the according uniform.
  88726. * @param channel The texture channel
  88727. * @param uniform The uniform to set
  88728. * @param texture The render target texture containing the depth stencil texture to apply
  88729. */
  88730. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88731. private _bindSamplerUniformToChannel;
  88732. private _getTextureWrapMode;
  88733. private _setTexture;
  88734. /**
  88735. * Sets an array of texture to the webGL context
  88736. * @param channel defines the channel where the texture array must be set
  88737. * @param uniform defines the associated uniform location
  88738. * @param textures defines the array of textures to bind
  88739. */
  88740. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88741. /** @hidden */
  88742. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88743. private _setTextureParameterFloat;
  88744. private _setTextureParameterInteger;
  88745. /**
  88746. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88747. * @param x defines the x coordinate of the rectangle where pixels must be read
  88748. * @param y defines the y coordinate of the rectangle where pixels must be read
  88749. * @param width defines the width of the rectangle where pixels must be read
  88750. * @param height defines the height of the rectangle where pixels must be read
  88751. * @returns a Uint8Array containing RGBA colors
  88752. */
  88753. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88754. /**
  88755. * Add an externaly attached data from its key.
  88756. * This method call will fail and return false, if such key already exists.
  88757. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88758. * @param key the unique key that identifies the data
  88759. * @param data the data object to associate to the key for this Engine instance
  88760. * @return true if no such key were already present and the data was added successfully, false otherwise
  88761. */
  88762. addExternalData<T>(key: string, data: T): boolean;
  88763. /**
  88764. * Get an externaly attached data from its key
  88765. * @param key the unique key that identifies the data
  88766. * @return the associated data, if present (can be null), or undefined if not present
  88767. */
  88768. getExternalData<T>(key: string): T;
  88769. /**
  88770. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88771. * @param key the unique key that identifies the data
  88772. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88773. * @return the associated data, can be null if the factory returned null.
  88774. */
  88775. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88776. /**
  88777. * Remove an externaly attached data from the Engine instance
  88778. * @param key the unique key that identifies the data
  88779. * @return true if the data was successfully removed, false if it doesn't exist
  88780. */
  88781. removeExternalData(key: string): boolean;
  88782. /**
  88783. * Unbind all vertex attributes from the webGL context
  88784. */
  88785. unbindAllAttributes(): void;
  88786. /**
  88787. * 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
  88788. */
  88789. releaseEffects(): void;
  88790. /**
  88791. * Dispose and release all associated resources
  88792. */
  88793. dispose(): void;
  88794. /**
  88795. * Display the loading screen
  88796. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88797. */
  88798. displayLoadingUI(): void;
  88799. /**
  88800. * Hide the loading screen
  88801. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88802. */
  88803. hideLoadingUI(): void;
  88804. /**
  88805. * Gets the current loading screen object
  88806. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88807. */
  88808. /**
  88809. * Sets the current loading screen object
  88810. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88811. */
  88812. loadingScreen: ILoadingScreen;
  88813. /**
  88814. * Sets the current loading screen text
  88815. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88816. */
  88817. loadingUIText: string;
  88818. /**
  88819. * Sets the current loading screen background color
  88820. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88821. */
  88822. loadingUIBackgroundColor: string;
  88823. /**
  88824. * Attach a new callback raised when context lost event is fired
  88825. * @param callback defines the callback to call
  88826. */
  88827. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88828. /**
  88829. * Attach a new callback raised when context restored event is fired
  88830. * @param callback defines the callback to call
  88831. */
  88832. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88833. /**
  88834. * Gets the source code of the vertex shader associated with a specific webGL program
  88835. * @param program defines the program to use
  88836. * @returns a string containing the source code of the vertex shader associated with the program
  88837. */
  88838. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88839. /**
  88840. * Gets the source code of the fragment shader associated with a specific webGL program
  88841. * @param program defines the program to use
  88842. * @returns a string containing the source code of the fragment shader associated with the program
  88843. */
  88844. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88845. /**
  88846. * Get the current error code of the webGL context
  88847. * @returns the error code
  88848. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88849. */
  88850. getError(): number;
  88851. /**
  88852. * Gets the current framerate
  88853. * @returns a number representing the framerate
  88854. */
  88855. getFps(): number;
  88856. /**
  88857. * Gets the time spent between current and previous frame
  88858. * @returns a number representing the delta time in ms
  88859. */
  88860. getDeltaTime(): number;
  88861. private _measureFps;
  88862. /** @hidden */
  88863. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88864. private _canRenderToFloatFramebuffer;
  88865. private _canRenderToHalfFloatFramebuffer;
  88866. private _canRenderToFramebuffer;
  88867. /** @hidden */
  88868. _getWebGLTextureType(type: number): number;
  88869. /** @hidden */
  88870. _getInternalFormat(format: number): number;
  88871. /** @hidden */
  88872. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88873. /** @hidden */
  88874. _getRGBAMultiSampleBufferFormat(type: number): number;
  88875. /** @hidden */
  88876. _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;
  88877. /** @hidden */
  88878. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88879. /**
  88880. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88881. * @returns true if the engine can be created
  88882. * @ignorenaming
  88883. */
  88884. static isSupported(): boolean;
  88885. }
  88886. }
  88887. declare module BABYLON {
  88888. /**
  88889. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88890. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88891. */
  88892. export class EffectFallbacks {
  88893. private _defines;
  88894. private _currentRank;
  88895. private _maxRank;
  88896. private _mesh;
  88897. /**
  88898. * Removes the fallback from the bound mesh.
  88899. */
  88900. unBindMesh(): void;
  88901. /**
  88902. * Adds a fallback on the specified property.
  88903. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88904. * @param define The name of the define in the shader
  88905. */
  88906. addFallback(rank: number, define: string): void;
  88907. /**
  88908. * Sets the mesh to use CPU skinning when needing to fallback.
  88909. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88910. * @param mesh The mesh to use the fallbacks.
  88911. */
  88912. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88913. /**
  88914. * Checks to see if more fallbacks are still availible.
  88915. */
  88916. readonly isMoreFallbacks: boolean;
  88917. /**
  88918. * Removes the defines that shoould be removed when falling back.
  88919. * @param currentDefines defines the current define statements for the shader.
  88920. * @param effect defines the current effect we try to compile
  88921. * @returns The resulting defines with defines of the current rank removed.
  88922. */
  88923. reduce(currentDefines: string, effect: Effect): string;
  88924. }
  88925. /**
  88926. * Options to be used when creating an effect.
  88927. */
  88928. export class EffectCreationOptions {
  88929. /**
  88930. * Atrributes that will be used in the shader.
  88931. */
  88932. attributes: string[];
  88933. /**
  88934. * Uniform varible names that will be set in the shader.
  88935. */
  88936. uniformsNames: string[];
  88937. /**
  88938. * Uniform buffer varible names that will be set in the shader.
  88939. */
  88940. uniformBuffersNames: string[];
  88941. /**
  88942. * Sampler texture variable names that will be set in the shader.
  88943. */
  88944. samplers: string[];
  88945. /**
  88946. * Define statements that will be set in the shader.
  88947. */
  88948. defines: any;
  88949. /**
  88950. * Possible fallbacks for this effect to improve performance when needed.
  88951. */
  88952. fallbacks: Nullable<EffectFallbacks>;
  88953. /**
  88954. * Callback that will be called when the shader is compiled.
  88955. */
  88956. onCompiled: Nullable<(effect: Effect) => void>;
  88957. /**
  88958. * Callback that will be called if an error occurs during shader compilation.
  88959. */
  88960. onError: Nullable<(effect: Effect, errors: string) => void>;
  88961. /**
  88962. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88963. */
  88964. indexParameters: any;
  88965. /**
  88966. * Max number of lights that can be used in the shader.
  88967. */
  88968. maxSimultaneousLights: number;
  88969. /**
  88970. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88971. */
  88972. transformFeedbackVaryings: Nullable<string[]>;
  88973. }
  88974. /**
  88975. * Effect containing vertex and fragment shader that can be executed on an object.
  88976. */
  88977. export class Effect implements IDisposable {
  88978. /**
  88979. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88980. */
  88981. static ShadersRepository: string;
  88982. /**
  88983. * Name of the effect.
  88984. */
  88985. name: any;
  88986. /**
  88987. * String container all the define statements that should be set on the shader.
  88988. */
  88989. defines: string;
  88990. /**
  88991. * Callback that will be called when the shader is compiled.
  88992. */
  88993. onCompiled: Nullable<(effect: Effect) => void>;
  88994. /**
  88995. * Callback that will be called if an error occurs during shader compilation.
  88996. */
  88997. onError: Nullable<(effect: Effect, errors: string) => void>;
  88998. /**
  88999. * Callback that will be called when effect is bound.
  89000. */
  89001. onBind: Nullable<(effect: Effect) => void>;
  89002. /**
  89003. * Unique ID of the effect.
  89004. */
  89005. uniqueId: number;
  89006. /**
  89007. * Observable that will be called when the shader is compiled.
  89008. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  89009. */
  89010. onCompileObservable: Observable<Effect>;
  89011. /**
  89012. * Observable that will be called if an error occurs during shader compilation.
  89013. */
  89014. onErrorObservable: Observable<Effect>;
  89015. /** @hidden */
  89016. _onBindObservable: Nullable<Observable<Effect>>;
  89017. /**
  89018. * Observable that will be called when effect is bound.
  89019. */
  89020. readonly onBindObservable: Observable<Effect>;
  89021. /** @hidden */
  89022. _bonesComputationForcedToCPU: boolean;
  89023. private static _uniqueIdSeed;
  89024. private _engine;
  89025. private _uniformBuffersNames;
  89026. private _uniformsNames;
  89027. private _samplerList;
  89028. private _samplers;
  89029. private _isReady;
  89030. private _compilationError;
  89031. private _attributesNames;
  89032. private _attributes;
  89033. private _uniforms;
  89034. /**
  89035. * Key for the effect.
  89036. * @hidden
  89037. */
  89038. _key: string;
  89039. private _indexParameters;
  89040. private _fallbacks;
  89041. private _vertexSourceCode;
  89042. private _fragmentSourceCode;
  89043. private _vertexSourceCodeOverride;
  89044. private _fragmentSourceCodeOverride;
  89045. private _transformFeedbackVaryings;
  89046. /**
  89047. * Compiled shader to webGL program.
  89048. * @hidden
  89049. */
  89050. _pipelineContext: IPipelineContext;
  89051. private _valueCache;
  89052. private static _baseCache;
  89053. /**
  89054. * Instantiates an effect.
  89055. * An effect can be used to create/manage/execute vertex and fragment shaders.
  89056. * @param baseName Name of the effect.
  89057. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  89058. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  89059. * @param samplers List of sampler variables that will be passed to the shader.
  89060. * @param engine Engine to be used to render the effect
  89061. * @param defines Define statements to be added to the shader.
  89062. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  89063. * @param onCompiled Callback that will be called when the shader is compiled.
  89064. * @param onError Callback that will be called if an error occurs during shader compilation.
  89065. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89066. */
  89067. 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);
  89068. /**
  89069. * Unique key for this effect
  89070. */
  89071. readonly key: string;
  89072. /**
  89073. * If the effect has been compiled and prepared.
  89074. * @returns if the effect is compiled and prepared.
  89075. */
  89076. isReady(): boolean;
  89077. /**
  89078. * The engine the effect was initialized with.
  89079. * @returns the engine.
  89080. */
  89081. getEngine(): Engine;
  89082. /**
  89083. * The pipeline context for this effect
  89084. * @returns the associated pipeline context
  89085. */
  89086. getPipelineContext(): IPipelineContext;
  89087. /**
  89088. * The set of names of attribute variables for the shader.
  89089. * @returns An array of attribute names.
  89090. */
  89091. getAttributesNames(): string[];
  89092. /**
  89093. * Returns the attribute at the given index.
  89094. * @param index The index of the attribute.
  89095. * @returns The location of the attribute.
  89096. */
  89097. getAttributeLocation(index: number): number;
  89098. /**
  89099. * Returns the attribute based on the name of the variable.
  89100. * @param name of the attribute to look up.
  89101. * @returns the attribute location.
  89102. */
  89103. getAttributeLocationByName(name: string): number;
  89104. /**
  89105. * The number of attributes.
  89106. * @returns the numnber of attributes.
  89107. */
  89108. getAttributesCount(): number;
  89109. /**
  89110. * Gets the index of a uniform variable.
  89111. * @param uniformName of the uniform to look up.
  89112. * @returns the index.
  89113. */
  89114. getUniformIndex(uniformName: string): number;
  89115. /**
  89116. * Returns the attribute based on the name of the variable.
  89117. * @param uniformName of the uniform to look up.
  89118. * @returns the location of the uniform.
  89119. */
  89120. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  89121. /**
  89122. * Returns an array of sampler variable names
  89123. * @returns The array of sampler variable neames.
  89124. */
  89125. getSamplers(): string[];
  89126. /**
  89127. * The error from the last compilation.
  89128. * @returns the error string.
  89129. */
  89130. getCompilationError(): string;
  89131. /**
  89132. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  89133. * @param func The callback to be used.
  89134. */
  89135. executeWhenCompiled(func: (effect: Effect) => void): void;
  89136. private _checkIsReady;
  89137. /** @hidden */
  89138. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  89139. /** @hidden */
  89140. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  89141. /** @hidden */
  89142. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  89143. private _processShaderConversion;
  89144. private _processIncludes;
  89145. private _processPrecision;
  89146. /**
  89147. * Recompiles the webGL program
  89148. * @param vertexSourceCode The source code for the vertex shader.
  89149. * @param fragmentSourceCode The source code for the fragment shader.
  89150. * @param onCompiled Callback called when completed.
  89151. * @param onError Callback called on error.
  89152. * @hidden
  89153. */
  89154. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  89155. /**
  89156. * Prepares the effect
  89157. * @hidden
  89158. */
  89159. _prepareEffect(): void;
  89160. /**
  89161. * Checks if the effect is supported. (Must be called after compilation)
  89162. */
  89163. readonly isSupported: boolean;
  89164. /**
  89165. * Binds a texture to the engine to be used as output of the shader.
  89166. * @param channel Name of the output variable.
  89167. * @param texture Texture to bind.
  89168. * @hidden
  89169. */
  89170. _bindTexture(channel: string, texture: InternalTexture): void;
  89171. /**
  89172. * Sets a texture on the engine to be used in the shader.
  89173. * @param channel Name of the sampler variable.
  89174. * @param texture Texture to set.
  89175. */
  89176. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  89177. /**
  89178. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  89179. * @param channel Name of the sampler variable.
  89180. * @param texture Texture to set.
  89181. */
  89182. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  89183. /**
  89184. * Sets an array of textures on the engine to be used in the shader.
  89185. * @param channel Name of the variable.
  89186. * @param textures Textures to set.
  89187. */
  89188. setTextureArray(channel: string, textures: BaseTexture[]): void;
  89189. /**
  89190. * 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)
  89191. * @param channel Name of the sampler variable.
  89192. * @param postProcess Post process to get the input texture from.
  89193. */
  89194. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  89195. /**
  89196. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  89197. * 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)
  89198. * @param channel Name of the sampler variable.
  89199. * @param postProcess Post process to get the output texture from.
  89200. */
  89201. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  89202. /** @hidden */
  89203. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  89204. /** @hidden */
  89205. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  89206. /** @hidden */
  89207. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  89208. /** @hidden */
  89209. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  89210. /**
  89211. * Binds a buffer to a uniform.
  89212. * @param buffer Buffer to bind.
  89213. * @param name Name of the uniform variable to bind to.
  89214. */
  89215. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  89216. /**
  89217. * Binds block to a uniform.
  89218. * @param blockName Name of the block to bind.
  89219. * @param index Index to bind.
  89220. */
  89221. bindUniformBlock(blockName: string, index: number): void;
  89222. /**
  89223. * Sets an interger value on a uniform variable.
  89224. * @param uniformName Name of the variable.
  89225. * @param value Value to be set.
  89226. * @returns this effect.
  89227. */
  89228. setInt(uniformName: string, value: number): Effect;
  89229. /**
  89230. * Sets an int array on a uniform variable.
  89231. * @param uniformName Name of the variable.
  89232. * @param array array to be set.
  89233. * @returns this effect.
  89234. */
  89235. setIntArray(uniformName: string, array: Int32Array): Effect;
  89236. /**
  89237. * 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)
  89238. * @param uniformName Name of the variable.
  89239. * @param array array to be set.
  89240. * @returns this effect.
  89241. */
  89242. setIntArray2(uniformName: string, array: Int32Array): Effect;
  89243. /**
  89244. * 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)
  89245. * @param uniformName Name of the variable.
  89246. * @param array array to be set.
  89247. * @returns this effect.
  89248. */
  89249. setIntArray3(uniformName: string, array: Int32Array): Effect;
  89250. /**
  89251. * 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)
  89252. * @param uniformName Name of the variable.
  89253. * @param array array to be set.
  89254. * @returns this effect.
  89255. */
  89256. setIntArray4(uniformName: string, array: Int32Array): Effect;
  89257. /**
  89258. * Sets an float array on a uniform variable.
  89259. * @param uniformName Name of the variable.
  89260. * @param array array to be set.
  89261. * @returns this effect.
  89262. */
  89263. setFloatArray(uniformName: string, array: Float32Array): Effect;
  89264. /**
  89265. * 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)
  89266. * @param uniformName Name of the variable.
  89267. * @param array array to be set.
  89268. * @returns this effect.
  89269. */
  89270. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  89271. /**
  89272. * 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)
  89273. * @param uniformName Name of the variable.
  89274. * @param array array to be set.
  89275. * @returns this effect.
  89276. */
  89277. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  89278. /**
  89279. * 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)
  89280. * @param uniformName Name of the variable.
  89281. * @param array array to be set.
  89282. * @returns this effect.
  89283. */
  89284. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  89285. /**
  89286. * Sets an array on a uniform variable.
  89287. * @param uniformName Name of the variable.
  89288. * @param array array to be set.
  89289. * @returns this effect.
  89290. */
  89291. setArray(uniformName: string, array: number[]): Effect;
  89292. /**
  89293. * 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)
  89294. * @param uniformName Name of the variable.
  89295. * @param array array to be set.
  89296. * @returns this effect.
  89297. */
  89298. setArray2(uniformName: string, array: number[]): Effect;
  89299. /**
  89300. * 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)
  89301. * @param uniformName Name of the variable.
  89302. * @param array array to be set.
  89303. * @returns this effect.
  89304. */
  89305. setArray3(uniformName: string, array: number[]): Effect;
  89306. /**
  89307. * 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)
  89308. * @param uniformName Name of the variable.
  89309. * @param array array to be set.
  89310. * @returns this effect.
  89311. */
  89312. setArray4(uniformName: string, array: number[]): Effect;
  89313. /**
  89314. * Sets matrices on a uniform variable.
  89315. * @param uniformName Name of the variable.
  89316. * @param matrices matrices to be set.
  89317. * @returns this effect.
  89318. */
  89319. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  89320. /**
  89321. * Sets matrix on a uniform variable.
  89322. * @param uniformName Name of the variable.
  89323. * @param matrix matrix to be set.
  89324. * @returns this effect.
  89325. */
  89326. setMatrix(uniformName: string, matrix: Matrix): Effect;
  89327. /**
  89328. * 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)
  89329. * @param uniformName Name of the variable.
  89330. * @param matrix matrix to be set.
  89331. * @returns this effect.
  89332. */
  89333. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  89334. /**
  89335. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  89336. * @param uniformName Name of the variable.
  89337. * @param matrix matrix to be set.
  89338. * @returns this effect.
  89339. */
  89340. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  89341. /**
  89342. * Sets a float on a uniform variable.
  89343. * @param uniformName Name of the variable.
  89344. * @param value value to be set.
  89345. * @returns this effect.
  89346. */
  89347. setFloat(uniformName: string, value: number): Effect;
  89348. /**
  89349. * Sets a boolean on a uniform variable.
  89350. * @param uniformName Name of the variable.
  89351. * @param bool value to be set.
  89352. * @returns this effect.
  89353. */
  89354. setBool(uniformName: string, bool: boolean): Effect;
  89355. /**
  89356. * Sets a Vector2 on a uniform variable.
  89357. * @param uniformName Name of the variable.
  89358. * @param vector2 vector2 to be set.
  89359. * @returns this effect.
  89360. */
  89361. setVector2(uniformName: string, vector2: Vector2): Effect;
  89362. /**
  89363. * Sets a float2 on a uniform variable.
  89364. * @param uniformName Name of the variable.
  89365. * @param x First float in float2.
  89366. * @param y Second float in float2.
  89367. * @returns this effect.
  89368. */
  89369. setFloat2(uniformName: string, x: number, y: number): Effect;
  89370. /**
  89371. * Sets a Vector3 on a uniform variable.
  89372. * @param uniformName Name of the variable.
  89373. * @param vector3 Value to be set.
  89374. * @returns this effect.
  89375. */
  89376. setVector3(uniformName: string, vector3: Vector3): Effect;
  89377. /**
  89378. * Sets a float3 on a uniform variable.
  89379. * @param uniformName Name of the variable.
  89380. * @param x First float in float3.
  89381. * @param y Second float in float3.
  89382. * @param z Third float in float3.
  89383. * @returns this effect.
  89384. */
  89385. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  89386. /**
  89387. * Sets a Vector4 on a uniform variable.
  89388. * @param uniformName Name of the variable.
  89389. * @param vector4 Value to be set.
  89390. * @returns this effect.
  89391. */
  89392. setVector4(uniformName: string, vector4: Vector4): Effect;
  89393. /**
  89394. * Sets a float4 on a uniform variable.
  89395. * @param uniformName Name of the variable.
  89396. * @param x First float in float4.
  89397. * @param y Second float in float4.
  89398. * @param z Third float in float4.
  89399. * @param w Fourth float in float4.
  89400. * @returns this effect.
  89401. */
  89402. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89403. /**
  89404. * Sets a Color3 on a uniform variable.
  89405. * @param uniformName Name of the variable.
  89406. * @param color3 Value to be set.
  89407. * @returns this effect.
  89408. */
  89409. setColor3(uniformName: string, color3: Color3): Effect;
  89410. /**
  89411. * Sets a Color4 on a uniform variable.
  89412. * @param uniformName Name of the variable.
  89413. * @param color3 Value to be set.
  89414. * @param alpha Alpha value to be set.
  89415. * @returns this effect.
  89416. */
  89417. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89418. /**
  89419. * Sets a Color4 on a uniform variable
  89420. * @param uniformName defines the name of the variable
  89421. * @param color4 defines the value to be set
  89422. * @returns this effect.
  89423. */
  89424. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89425. /** Release all associated resources */
  89426. dispose(): void;
  89427. /**
  89428. * This function will add a new shader to the shader store
  89429. * @param name the name of the shader
  89430. * @param pixelShader optional pixel shader content
  89431. * @param vertexShader optional vertex shader content
  89432. */
  89433. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89434. /**
  89435. * Store of each shader (The can be looked up using effect.key)
  89436. */
  89437. static ShadersStore: {
  89438. [key: string]: string;
  89439. };
  89440. /**
  89441. * Store of each included file for a shader (The can be looked up using effect.key)
  89442. */
  89443. static IncludesShadersStore: {
  89444. [key: string]: string;
  89445. };
  89446. /**
  89447. * Resets the cache of effects.
  89448. */
  89449. static ResetCache(): void;
  89450. }
  89451. }
  89452. declare module BABYLON {
  89453. /**
  89454. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89455. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89456. * 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;
  89457. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89458. */
  89459. export class ColorCurves {
  89460. private _dirty;
  89461. private _tempColor;
  89462. private _globalCurve;
  89463. private _highlightsCurve;
  89464. private _midtonesCurve;
  89465. private _shadowsCurve;
  89466. private _positiveCurve;
  89467. private _negativeCurve;
  89468. private _globalHue;
  89469. private _globalDensity;
  89470. private _globalSaturation;
  89471. private _globalExposure;
  89472. /**
  89473. * Gets the global Hue value.
  89474. * 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).
  89475. */
  89476. /**
  89477. * Sets the global Hue value.
  89478. * 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).
  89479. */
  89480. globalHue: number;
  89481. /**
  89482. * Gets the global Density value.
  89483. * 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.
  89484. * Values less than zero provide a filter of opposite hue.
  89485. */
  89486. /**
  89487. * Sets the global Density value.
  89488. * 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.
  89489. * Values less than zero provide a filter of opposite hue.
  89490. */
  89491. globalDensity: number;
  89492. /**
  89493. * Gets the global Saturation value.
  89494. * 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.
  89495. */
  89496. /**
  89497. * Sets the global Saturation value.
  89498. * 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.
  89499. */
  89500. globalSaturation: number;
  89501. /**
  89502. * Gets the global Exposure value.
  89503. * 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.
  89504. */
  89505. /**
  89506. * Sets the global Exposure value.
  89507. * 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.
  89508. */
  89509. globalExposure: number;
  89510. private _highlightsHue;
  89511. private _highlightsDensity;
  89512. private _highlightsSaturation;
  89513. private _highlightsExposure;
  89514. /**
  89515. * Gets the highlights Hue value.
  89516. * 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).
  89517. */
  89518. /**
  89519. * Sets the highlights Hue value.
  89520. * 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).
  89521. */
  89522. highlightsHue: number;
  89523. /**
  89524. * Gets the highlights Density value.
  89525. * 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.
  89526. * Values less than zero provide a filter of opposite hue.
  89527. */
  89528. /**
  89529. * Sets the highlights Density value.
  89530. * 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.
  89531. * Values less than zero provide a filter of opposite hue.
  89532. */
  89533. highlightsDensity: number;
  89534. /**
  89535. * Gets the highlights Saturation value.
  89536. * 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.
  89537. */
  89538. /**
  89539. * Sets the highlights Saturation value.
  89540. * 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.
  89541. */
  89542. highlightsSaturation: number;
  89543. /**
  89544. * Gets the highlights Exposure value.
  89545. * 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.
  89546. */
  89547. /**
  89548. * Sets the highlights Exposure value.
  89549. * 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.
  89550. */
  89551. highlightsExposure: number;
  89552. private _midtonesHue;
  89553. private _midtonesDensity;
  89554. private _midtonesSaturation;
  89555. private _midtonesExposure;
  89556. /**
  89557. * Gets the midtones Hue value.
  89558. * 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).
  89559. */
  89560. /**
  89561. * Sets the midtones Hue value.
  89562. * 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).
  89563. */
  89564. midtonesHue: number;
  89565. /**
  89566. * Gets the midtones Density value.
  89567. * 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.
  89568. * Values less than zero provide a filter of opposite hue.
  89569. */
  89570. /**
  89571. * Sets the midtones Density value.
  89572. * 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.
  89573. * Values less than zero provide a filter of opposite hue.
  89574. */
  89575. midtonesDensity: number;
  89576. /**
  89577. * Gets the midtones Saturation value.
  89578. * 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.
  89579. */
  89580. /**
  89581. * Sets the midtones Saturation value.
  89582. * 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.
  89583. */
  89584. midtonesSaturation: number;
  89585. /**
  89586. * Gets the midtones Exposure value.
  89587. * 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.
  89588. */
  89589. /**
  89590. * Sets the midtones Exposure value.
  89591. * 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.
  89592. */
  89593. midtonesExposure: number;
  89594. private _shadowsHue;
  89595. private _shadowsDensity;
  89596. private _shadowsSaturation;
  89597. private _shadowsExposure;
  89598. /**
  89599. * Gets the shadows Hue value.
  89600. * 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).
  89601. */
  89602. /**
  89603. * Sets the shadows Hue value.
  89604. * 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).
  89605. */
  89606. shadowsHue: number;
  89607. /**
  89608. * Gets the shadows Density value.
  89609. * 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.
  89610. * Values less than zero provide a filter of opposite hue.
  89611. */
  89612. /**
  89613. * Sets the shadows Density value.
  89614. * 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.
  89615. * Values less than zero provide a filter of opposite hue.
  89616. */
  89617. shadowsDensity: number;
  89618. /**
  89619. * Gets the shadows Saturation value.
  89620. * 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.
  89621. */
  89622. /**
  89623. * Sets the shadows Saturation value.
  89624. * 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.
  89625. */
  89626. shadowsSaturation: number;
  89627. /**
  89628. * Gets the shadows Exposure value.
  89629. * 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.
  89630. */
  89631. /**
  89632. * Sets the shadows Exposure value.
  89633. * 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.
  89634. */
  89635. shadowsExposure: number;
  89636. /**
  89637. * Returns the class name
  89638. * @returns The class name
  89639. */
  89640. getClassName(): string;
  89641. /**
  89642. * Binds the color curves to the shader.
  89643. * @param colorCurves The color curve to bind
  89644. * @param effect The effect to bind to
  89645. * @param positiveUniform The positive uniform shader parameter
  89646. * @param neutralUniform The neutral uniform shader parameter
  89647. * @param negativeUniform The negative uniform shader parameter
  89648. */
  89649. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89650. /**
  89651. * Prepare the list of uniforms associated with the ColorCurves effects.
  89652. * @param uniformsList The list of uniforms used in the effect
  89653. */
  89654. static PrepareUniforms(uniformsList: string[]): void;
  89655. /**
  89656. * Returns color grading data based on a hue, density, saturation and exposure value.
  89657. * @param filterHue The hue of the color filter.
  89658. * @param filterDensity The density of the color filter.
  89659. * @param saturation The saturation.
  89660. * @param exposure The exposure.
  89661. * @param result The result data container.
  89662. */
  89663. private getColorGradingDataToRef;
  89664. /**
  89665. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89666. * @param value The input slider value in range [-100,100].
  89667. * @returns Adjusted value.
  89668. */
  89669. private static applyColorGradingSliderNonlinear;
  89670. /**
  89671. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89672. * @param hue The hue (H) input.
  89673. * @param saturation The saturation (S) input.
  89674. * @param brightness The brightness (B) input.
  89675. * @result An RGBA color represented as Vector4.
  89676. */
  89677. private static fromHSBToRef;
  89678. /**
  89679. * Returns a value clamped between min and max
  89680. * @param value The value to clamp
  89681. * @param min The minimum of value
  89682. * @param max The maximum of value
  89683. * @returns The clamped value.
  89684. */
  89685. private static clamp;
  89686. /**
  89687. * Clones the current color curve instance.
  89688. * @return The cloned curves
  89689. */
  89690. clone(): ColorCurves;
  89691. /**
  89692. * Serializes the current color curve instance to a json representation.
  89693. * @return a JSON representation
  89694. */
  89695. serialize(): any;
  89696. /**
  89697. * Parses the color curve from a json representation.
  89698. * @param source the JSON source to parse
  89699. * @return The parsed curves
  89700. */
  89701. static Parse(source: any): ColorCurves;
  89702. }
  89703. }
  89704. declare module BABYLON {
  89705. /**
  89706. * Interface to follow in your material defines to integrate easily the
  89707. * Image proccessing functions.
  89708. * @hidden
  89709. */
  89710. export interface IImageProcessingConfigurationDefines {
  89711. IMAGEPROCESSING: boolean;
  89712. VIGNETTE: boolean;
  89713. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89714. VIGNETTEBLENDMODEOPAQUE: boolean;
  89715. TONEMAPPING: boolean;
  89716. TONEMAPPING_ACES: boolean;
  89717. CONTRAST: boolean;
  89718. EXPOSURE: boolean;
  89719. COLORCURVES: boolean;
  89720. COLORGRADING: boolean;
  89721. COLORGRADING3D: boolean;
  89722. SAMPLER3DGREENDEPTH: boolean;
  89723. SAMPLER3DBGRMAP: boolean;
  89724. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89725. }
  89726. /**
  89727. * @hidden
  89728. */
  89729. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89730. IMAGEPROCESSING: boolean;
  89731. VIGNETTE: boolean;
  89732. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89733. VIGNETTEBLENDMODEOPAQUE: boolean;
  89734. TONEMAPPING: boolean;
  89735. TONEMAPPING_ACES: boolean;
  89736. CONTRAST: boolean;
  89737. COLORCURVES: boolean;
  89738. COLORGRADING: boolean;
  89739. COLORGRADING3D: boolean;
  89740. SAMPLER3DGREENDEPTH: boolean;
  89741. SAMPLER3DBGRMAP: boolean;
  89742. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89743. EXPOSURE: boolean;
  89744. constructor();
  89745. }
  89746. /**
  89747. * This groups together the common properties used for image processing either in direct forward pass
  89748. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89749. * or not.
  89750. */
  89751. export class ImageProcessingConfiguration {
  89752. /**
  89753. * Default tone mapping applied in BabylonJS.
  89754. */
  89755. static readonly TONEMAPPING_STANDARD: number;
  89756. /**
  89757. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89758. * to other engines rendering to increase portability.
  89759. */
  89760. static readonly TONEMAPPING_ACES: number;
  89761. /**
  89762. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89763. */
  89764. colorCurves: Nullable<ColorCurves>;
  89765. private _colorCurvesEnabled;
  89766. /**
  89767. * Gets wether the color curves effect is enabled.
  89768. */
  89769. /**
  89770. * Sets wether the color curves effect is enabled.
  89771. */
  89772. colorCurvesEnabled: boolean;
  89773. private _colorGradingTexture;
  89774. /**
  89775. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89776. */
  89777. /**
  89778. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89779. */
  89780. colorGradingTexture: Nullable<BaseTexture>;
  89781. private _colorGradingEnabled;
  89782. /**
  89783. * Gets wether the color grading effect is enabled.
  89784. */
  89785. /**
  89786. * Sets wether the color grading effect is enabled.
  89787. */
  89788. colorGradingEnabled: boolean;
  89789. private _colorGradingWithGreenDepth;
  89790. /**
  89791. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89792. */
  89793. /**
  89794. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89795. */
  89796. colorGradingWithGreenDepth: boolean;
  89797. private _colorGradingBGR;
  89798. /**
  89799. * Gets wether the color grading texture contains BGR values.
  89800. */
  89801. /**
  89802. * Sets wether the color grading texture contains BGR values.
  89803. */
  89804. colorGradingBGR: boolean;
  89805. /** @hidden */
  89806. _exposure: number;
  89807. /**
  89808. * Gets the Exposure used in the effect.
  89809. */
  89810. /**
  89811. * Sets the Exposure used in the effect.
  89812. */
  89813. exposure: number;
  89814. private _toneMappingEnabled;
  89815. /**
  89816. * Gets wether the tone mapping effect is enabled.
  89817. */
  89818. /**
  89819. * Sets wether the tone mapping effect is enabled.
  89820. */
  89821. toneMappingEnabled: boolean;
  89822. private _toneMappingType;
  89823. /**
  89824. * Gets the type of tone mapping effect.
  89825. */
  89826. /**
  89827. * Sets the type of tone mapping effect used in BabylonJS.
  89828. */
  89829. toneMappingType: number;
  89830. protected _contrast: number;
  89831. /**
  89832. * Gets the contrast used in the effect.
  89833. */
  89834. /**
  89835. * Sets the contrast used in the effect.
  89836. */
  89837. contrast: number;
  89838. /**
  89839. * Vignette stretch size.
  89840. */
  89841. vignetteStretch: number;
  89842. /**
  89843. * Vignette centre X Offset.
  89844. */
  89845. vignetteCentreX: number;
  89846. /**
  89847. * Vignette centre Y Offset.
  89848. */
  89849. vignetteCentreY: number;
  89850. /**
  89851. * Vignette weight or intensity of the vignette effect.
  89852. */
  89853. vignetteWeight: number;
  89854. /**
  89855. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89856. * if vignetteEnabled is set to true.
  89857. */
  89858. vignetteColor: Color4;
  89859. /**
  89860. * Camera field of view used by the Vignette effect.
  89861. */
  89862. vignetteCameraFov: number;
  89863. private _vignetteBlendMode;
  89864. /**
  89865. * Gets the vignette blend mode allowing different kind of effect.
  89866. */
  89867. /**
  89868. * Sets the vignette blend mode allowing different kind of effect.
  89869. */
  89870. vignetteBlendMode: number;
  89871. private _vignetteEnabled;
  89872. /**
  89873. * Gets wether the vignette effect is enabled.
  89874. */
  89875. /**
  89876. * Sets wether the vignette effect is enabled.
  89877. */
  89878. vignetteEnabled: boolean;
  89879. private _applyByPostProcess;
  89880. /**
  89881. * Gets wether the image processing is applied through a post process or not.
  89882. */
  89883. /**
  89884. * Sets wether the image processing is applied through a post process or not.
  89885. */
  89886. applyByPostProcess: boolean;
  89887. private _isEnabled;
  89888. /**
  89889. * Gets wether the image processing is enabled or not.
  89890. */
  89891. /**
  89892. * Sets wether the image processing is enabled or not.
  89893. */
  89894. isEnabled: boolean;
  89895. /**
  89896. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89897. */
  89898. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89899. /**
  89900. * Method called each time the image processing information changes requires to recompile the effect.
  89901. */
  89902. protected _updateParameters(): void;
  89903. /**
  89904. * Gets the current class name.
  89905. * @return "ImageProcessingConfiguration"
  89906. */
  89907. getClassName(): string;
  89908. /**
  89909. * Prepare the list of uniforms associated with the Image Processing effects.
  89910. * @param uniforms The list of uniforms used in the effect
  89911. * @param defines the list of defines currently in use
  89912. */
  89913. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89914. /**
  89915. * Prepare the list of samplers associated with the Image Processing effects.
  89916. * @param samplersList The list of uniforms used in the effect
  89917. * @param defines the list of defines currently in use
  89918. */
  89919. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89920. /**
  89921. * Prepare the list of defines associated to the shader.
  89922. * @param defines the list of defines to complete
  89923. * @param forPostProcess Define if we are currently in post process mode or not
  89924. */
  89925. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89926. /**
  89927. * Returns true if all the image processing information are ready.
  89928. * @returns True if ready, otherwise, false
  89929. */
  89930. isReady(): boolean;
  89931. /**
  89932. * Binds the image processing to the shader.
  89933. * @param effect The effect to bind to
  89934. * @param aspectRatio Define the current aspect ratio of the effect
  89935. */
  89936. bind(effect: Effect, aspectRatio?: number): void;
  89937. /**
  89938. * Clones the current image processing instance.
  89939. * @return The cloned image processing
  89940. */
  89941. clone(): ImageProcessingConfiguration;
  89942. /**
  89943. * Serializes the current image processing instance to a json representation.
  89944. * @return a JSON representation
  89945. */
  89946. serialize(): any;
  89947. /**
  89948. * Parses the image processing from a json representation.
  89949. * @param source the JSON source to parse
  89950. * @return The parsed image processing
  89951. */
  89952. static Parse(source: any): ImageProcessingConfiguration;
  89953. private static _VIGNETTEMODE_MULTIPLY;
  89954. private static _VIGNETTEMODE_OPAQUE;
  89955. /**
  89956. * Used to apply the vignette as a mix with the pixel color.
  89957. */
  89958. static readonly VIGNETTEMODE_MULTIPLY: number;
  89959. /**
  89960. * Used to apply the vignette as a replacement of the pixel color.
  89961. */
  89962. static readonly VIGNETTEMODE_OPAQUE: number;
  89963. }
  89964. }
  89965. declare module BABYLON {
  89966. /**
  89967. * This represents all the required information to add a fresnel effect on a material:
  89968. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89969. */
  89970. export class FresnelParameters {
  89971. private _isEnabled;
  89972. /**
  89973. * Define if the fresnel effect is enable or not.
  89974. */
  89975. isEnabled: boolean;
  89976. /**
  89977. * Define the color used on edges (grazing angle)
  89978. */
  89979. leftColor: Color3;
  89980. /**
  89981. * Define the color used on center
  89982. */
  89983. rightColor: Color3;
  89984. /**
  89985. * Define bias applied to computed fresnel term
  89986. */
  89987. bias: number;
  89988. /**
  89989. * Defined the power exponent applied to fresnel term
  89990. */
  89991. power: number;
  89992. /**
  89993. * Clones the current fresnel and its valuues
  89994. * @returns a clone fresnel configuration
  89995. */
  89996. clone(): FresnelParameters;
  89997. /**
  89998. * Serializes the current fresnel parameters to a JSON representation.
  89999. * @return the JSON serialization
  90000. */
  90001. serialize(): any;
  90002. /**
  90003. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  90004. * @param parsedFresnelParameters Define the JSON representation
  90005. * @returns the parsed parameters
  90006. */
  90007. static Parse(parsedFresnelParameters: any): FresnelParameters;
  90008. }
  90009. }
  90010. declare module BABYLON {
  90011. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  90012. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90013. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90014. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90015. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90016. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90017. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90018. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90019. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90020. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90021. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90022. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90023. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90024. /**
  90025. * Decorator used to define property that can be serialized as reference to a camera
  90026. * @param sourceName defines the name of the property to decorate
  90027. */
  90028. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90029. /**
  90030. * Class used to help serialization objects
  90031. */
  90032. export class SerializationHelper {
  90033. /** hidden */
  90034. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  90035. /** hidden */
  90036. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  90037. /** hidden */
  90038. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  90039. /** hidden */
  90040. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  90041. /**
  90042. * Appends the serialized animations from the source animations
  90043. * @param source Source containing the animations
  90044. * @param destination Target to store the animations
  90045. */
  90046. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90047. /**
  90048. * Static function used to serialized a specific entity
  90049. * @param entity defines the entity to serialize
  90050. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  90051. * @returns a JSON compatible object representing the serialization of the entity
  90052. */
  90053. static Serialize<T>(entity: T, serializationObject?: any): any;
  90054. /**
  90055. * Creates a new entity from a serialization data object
  90056. * @param creationFunction defines a function used to instanciated the new entity
  90057. * @param source defines the source serialization data
  90058. * @param scene defines the hosting scene
  90059. * @param rootUrl defines the root url for resources
  90060. * @returns a new entity
  90061. */
  90062. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90063. /**
  90064. * Clones an object
  90065. * @param creationFunction defines the function used to instanciate the new object
  90066. * @param source defines the source object
  90067. * @returns the cloned object
  90068. */
  90069. static Clone<T>(creationFunction: () => T, source: T): T;
  90070. /**
  90071. * Instanciates a new object based on a source one (some data will be shared between both object)
  90072. * @param creationFunction defines the function used to instanciate the new object
  90073. * @param source defines the source object
  90074. * @returns the new object
  90075. */
  90076. static Instanciate<T>(creationFunction: () => T, source: T): T;
  90077. }
  90078. }
  90079. declare module BABYLON {
  90080. /**
  90081. * This is the base class of all the camera used in the application.
  90082. * @see http://doc.babylonjs.com/features/cameras
  90083. */
  90084. export class Camera extends Node {
  90085. /** @hidden */
  90086. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90087. /**
  90088. * This is the default projection mode used by the cameras.
  90089. * It helps recreating a feeling of perspective and better appreciate depth.
  90090. * This is the best way to simulate real life cameras.
  90091. */
  90092. static readonly PERSPECTIVE_CAMERA: number;
  90093. /**
  90094. * This helps creating camera with an orthographic mode.
  90095. * 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.
  90096. */
  90097. static readonly ORTHOGRAPHIC_CAMERA: number;
  90098. /**
  90099. * This is the default FOV mode for perspective cameras.
  90100. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90101. */
  90102. static readonly FOVMODE_VERTICAL_FIXED: number;
  90103. /**
  90104. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90105. */
  90106. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90107. /**
  90108. * This specifies ther is no need for a camera rig.
  90109. * Basically only one eye is rendered corresponding to the camera.
  90110. */
  90111. static readonly RIG_MODE_NONE: number;
  90112. /**
  90113. * Simulates a camera Rig with one blue eye and one red eye.
  90114. * This can be use with 3d blue and red glasses.
  90115. */
  90116. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90117. /**
  90118. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90119. */
  90120. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90121. /**
  90122. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90123. */
  90124. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90125. /**
  90126. * Defines that both eyes of the camera will be rendered over under each other.
  90127. */
  90128. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90129. /**
  90130. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90131. */
  90132. static readonly RIG_MODE_VR: number;
  90133. /**
  90134. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90135. */
  90136. static readonly RIG_MODE_WEBVR: number;
  90137. /**
  90138. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90139. */
  90140. static readonly RIG_MODE_CUSTOM: number;
  90141. /**
  90142. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90143. */
  90144. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90145. /**
  90146. * Define the input manager associated with the camera.
  90147. */
  90148. inputs: CameraInputsManager<Camera>;
  90149. /** @hidden */
  90150. _position: Vector3;
  90151. /**
  90152. * Define the current local position of the camera in the scene
  90153. */
  90154. position: Vector3;
  90155. /**
  90156. * The vector the camera should consider as up.
  90157. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90158. */
  90159. upVector: Vector3;
  90160. /**
  90161. * Define the current limit on the left side for an orthographic camera
  90162. * In scene unit
  90163. */
  90164. orthoLeft: Nullable<number>;
  90165. /**
  90166. * Define the current limit on the right side for an orthographic camera
  90167. * In scene unit
  90168. */
  90169. orthoRight: Nullable<number>;
  90170. /**
  90171. * Define the current limit on the bottom side for an orthographic camera
  90172. * In scene unit
  90173. */
  90174. orthoBottom: Nullable<number>;
  90175. /**
  90176. * Define the current limit on the top side for an orthographic camera
  90177. * In scene unit
  90178. */
  90179. orthoTop: Nullable<number>;
  90180. /**
  90181. * Field Of View is set in Radians. (default is 0.8)
  90182. */
  90183. fov: number;
  90184. /**
  90185. * Define the minimum distance the camera can see from.
  90186. * This is important to note that the depth buffer are not infinite and the closer it starts
  90187. * the more your scene might encounter depth fighting issue.
  90188. */
  90189. minZ: number;
  90190. /**
  90191. * Define the maximum distance the camera can see to.
  90192. * This is important to note that the depth buffer are not infinite and the further it end
  90193. * the more your scene might encounter depth fighting issue.
  90194. */
  90195. maxZ: number;
  90196. /**
  90197. * Define the default inertia of the camera.
  90198. * This helps giving a smooth feeling to the camera movement.
  90199. */
  90200. inertia: number;
  90201. /**
  90202. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  90203. */
  90204. mode: number;
  90205. /**
  90206. * Define wether the camera is intermediate.
  90207. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90208. */
  90209. isIntermediate: boolean;
  90210. /**
  90211. * Define the viewport of the camera.
  90212. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90213. */
  90214. viewport: Viewport;
  90215. /**
  90216. * Restricts the camera to viewing objects with the same layerMask.
  90217. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90218. */
  90219. layerMask: number;
  90220. /**
  90221. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90222. */
  90223. fovMode: number;
  90224. /**
  90225. * Rig mode of the camera.
  90226. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90227. * This is normally controlled byt the camera themselves as internal use.
  90228. */
  90229. cameraRigMode: number;
  90230. /**
  90231. * Defines the distance between both "eyes" in case of a RIG
  90232. */
  90233. interaxialDistance: number;
  90234. /**
  90235. * Defines if stereoscopic rendering is done side by side or over under.
  90236. */
  90237. isStereoscopicSideBySide: boolean;
  90238. /**
  90239. * 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
  90240. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90241. * else in the scene.
  90242. */
  90243. customRenderTargets: RenderTargetTexture[];
  90244. /**
  90245. * When set, the camera will render to this render target instead of the default canvas
  90246. */
  90247. outputRenderTarget: Nullable<RenderTargetTexture>;
  90248. /**
  90249. * Observable triggered when the camera view matrix has changed.
  90250. */
  90251. onViewMatrixChangedObservable: Observable<Camera>;
  90252. /**
  90253. * Observable triggered when the camera Projection matrix has changed.
  90254. */
  90255. onProjectionMatrixChangedObservable: Observable<Camera>;
  90256. /**
  90257. * Observable triggered when the inputs have been processed.
  90258. */
  90259. onAfterCheckInputsObservable: Observable<Camera>;
  90260. /**
  90261. * Observable triggered when reset has been called and applied to the camera.
  90262. */
  90263. onRestoreStateObservable: Observable<Camera>;
  90264. /** @hidden */
  90265. _cameraRigParams: any;
  90266. /** @hidden */
  90267. _rigCameras: Camera[];
  90268. /** @hidden */
  90269. _rigPostProcess: Nullable<PostProcess>;
  90270. protected _webvrViewMatrix: Matrix;
  90271. /** @hidden */
  90272. _skipRendering: boolean;
  90273. /** @hidden */
  90274. _projectionMatrix: Matrix;
  90275. /** @hidden */
  90276. _postProcesses: Nullable<PostProcess>[];
  90277. /** @hidden */
  90278. _activeMeshes: SmartArray<AbstractMesh>;
  90279. protected _globalPosition: Vector3;
  90280. /** hidden */
  90281. _computedViewMatrix: Matrix;
  90282. private _doNotComputeProjectionMatrix;
  90283. private _transformMatrix;
  90284. private _frustumPlanes;
  90285. private _refreshFrustumPlanes;
  90286. private _storedFov;
  90287. private _stateStored;
  90288. /**
  90289. * Instantiates a new camera object.
  90290. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90291. * @see http://doc.babylonjs.com/features/cameras
  90292. * @param name Defines the name of the camera in the scene
  90293. * @param position Defines the position of the camera
  90294. * @param scene Defines the scene the camera belongs too
  90295. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90296. */
  90297. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90298. /**
  90299. * Store current camera state (fov, position, etc..)
  90300. * @returns the camera
  90301. */
  90302. storeState(): Camera;
  90303. /**
  90304. * Restores the camera state values if it has been stored. You must call storeState() first
  90305. */
  90306. protected _restoreStateValues(): boolean;
  90307. /**
  90308. * Restored camera state. You must call storeState() first.
  90309. * @returns true if restored and false otherwise
  90310. */
  90311. restoreState(): boolean;
  90312. /**
  90313. * Gets the class name of the camera.
  90314. * @returns the class name
  90315. */
  90316. getClassName(): string;
  90317. /** @hidden */
  90318. readonly _isCamera: boolean;
  90319. /**
  90320. * Gets a string representation of the camera useful for debug purpose.
  90321. * @param fullDetails Defines that a more verboe level of logging is required
  90322. * @returns the string representation
  90323. */
  90324. toString(fullDetails?: boolean): string;
  90325. /**
  90326. * Gets the current world space position of the camera.
  90327. */
  90328. readonly globalPosition: Vector3;
  90329. /**
  90330. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90331. * @returns the active meshe list
  90332. */
  90333. getActiveMeshes(): SmartArray<AbstractMesh>;
  90334. /**
  90335. * Check wether a mesh is part of the current active mesh list of the camera
  90336. * @param mesh Defines the mesh to check
  90337. * @returns true if active, false otherwise
  90338. */
  90339. isActiveMesh(mesh: Mesh): boolean;
  90340. /**
  90341. * Is this camera ready to be used/rendered
  90342. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90343. * @return true if the camera is ready
  90344. */
  90345. isReady(completeCheck?: boolean): boolean;
  90346. /** @hidden */
  90347. _initCache(): void;
  90348. /** @hidden */
  90349. _updateCache(ignoreParentClass?: boolean): void;
  90350. /** @hidden */
  90351. _isSynchronized(): boolean;
  90352. /** @hidden */
  90353. _isSynchronizedViewMatrix(): boolean;
  90354. /** @hidden */
  90355. _isSynchronizedProjectionMatrix(): boolean;
  90356. /**
  90357. * Attach the input controls to a specific dom element to get the input from.
  90358. * @param element Defines the element the controls should be listened from
  90359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90360. */
  90361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90362. /**
  90363. * Detach the current controls from the specified dom element.
  90364. * @param element Defines the element to stop listening the inputs from
  90365. */
  90366. detachControl(element: HTMLElement): void;
  90367. /**
  90368. * Update the camera state according to the different inputs gathered during the frame.
  90369. */
  90370. update(): void;
  90371. /** @hidden */
  90372. _checkInputs(): void;
  90373. /** @hidden */
  90374. readonly rigCameras: Camera[];
  90375. /**
  90376. * Gets the post process used by the rig cameras
  90377. */
  90378. readonly rigPostProcess: Nullable<PostProcess>;
  90379. /**
  90380. * Internal, gets the first post proces.
  90381. * @returns the first post process to be run on this camera.
  90382. */
  90383. _getFirstPostProcess(): Nullable<PostProcess>;
  90384. private _cascadePostProcessesToRigCams;
  90385. /**
  90386. * Attach a post process to the camera.
  90387. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90388. * @param postProcess The post process to attach to the camera
  90389. * @param insertAt The position of the post process in case several of them are in use in the scene
  90390. * @returns the position the post process has been inserted at
  90391. */
  90392. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90393. /**
  90394. * Detach a post process to the camera.
  90395. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90396. * @param postProcess The post process to detach from the camera
  90397. */
  90398. detachPostProcess(postProcess: PostProcess): void;
  90399. /**
  90400. * Gets the current world matrix of the camera
  90401. */
  90402. getWorldMatrix(): Matrix;
  90403. /** @hidden */
  90404. _getViewMatrix(): Matrix;
  90405. /**
  90406. * Gets the current view matrix of the camera.
  90407. * @param force forces the camera to recompute the matrix without looking at the cached state
  90408. * @returns the view matrix
  90409. */
  90410. getViewMatrix(force?: boolean): Matrix;
  90411. /**
  90412. * Freeze the projection matrix.
  90413. * It will prevent the cache check of the camera projection compute and can speed up perf
  90414. * if no parameter of the camera are meant to change
  90415. * @param projection Defines manually a projection if necessary
  90416. */
  90417. freezeProjectionMatrix(projection?: Matrix): void;
  90418. /**
  90419. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90420. */
  90421. unfreezeProjectionMatrix(): void;
  90422. /**
  90423. * Gets the current projection matrix of the camera.
  90424. * @param force forces the camera to recompute the matrix without looking at the cached state
  90425. * @returns the projection matrix
  90426. */
  90427. getProjectionMatrix(force?: boolean): Matrix;
  90428. /**
  90429. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90430. * @returns a Matrix
  90431. */
  90432. getTransformationMatrix(): Matrix;
  90433. private _updateFrustumPlanes;
  90434. /**
  90435. * Checks if a cullable object (mesh...) is in the camera frustum
  90436. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90437. * @param target The object to check
  90438. * @returns true if the object is in frustum otherwise false
  90439. */
  90440. isInFrustum(target: ICullable): boolean;
  90441. /**
  90442. * Checks if a cullable object (mesh...) is in the camera frustum
  90443. * Unlike isInFrustum this cheks the full bounding box
  90444. * @param target The object to check
  90445. * @returns true if the object is in frustum otherwise false
  90446. */
  90447. isCompletelyInFrustum(target: ICullable): boolean;
  90448. /**
  90449. * Gets a ray in the forward direction from the camera.
  90450. * @param length Defines the length of the ray to create
  90451. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90452. * @param origin Defines the start point of the ray which defaults to the camera position
  90453. * @returns the forward ray
  90454. */
  90455. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90456. /**
  90457. * Releases resources associated with this node.
  90458. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90459. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90460. */
  90461. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90462. /** @hidden */
  90463. _isLeftCamera: boolean;
  90464. /**
  90465. * Gets the left camera of a rig setup in case of Rigged Camera
  90466. */
  90467. readonly isLeftCamera: boolean;
  90468. /** @hidden */
  90469. _isRightCamera: boolean;
  90470. /**
  90471. * Gets the right camera of a rig setup in case of Rigged Camera
  90472. */
  90473. readonly isRightCamera: boolean;
  90474. /**
  90475. * Gets the left camera of a rig setup in case of Rigged Camera
  90476. */
  90477. readonly leftCamera: Nullable<FreeCamera>;
  90478. /**
  90479. * Gets the right camera of a rig setup in case of Rigged Camera
  90480. */
  90481. readonly rightCamera: Nullable<FreeCamera>;
  90482. /**
  90483. * Gets the left camera target of a rig setup in case of Rigged Camera
  90484. * @returns the target position
  90485. */
  90486. getLeftTarget(): Nullable<Vector3>;
  90487. /**
  90488. * Gets the right camera target of a rig setup in case of Rigged Camera
  90489. * @returns the target position
  90490. */
  90491. getRightTarget(): Nullable<Vector3>;
  90492. /**
  90493. * @hidden
  90494. */
  90495. setCameraRigMode(mode: number, rigParams: any): void;
  90496. /** @hidden */
  90497. static _setStereoscopicRigMode(camera: Camera): void;
  90498. /** @hidden */
  90499. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90500. /** @hidden */
  90501. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90502. /** @hidden */
  90503. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90504. /** @hidden */
  90505. _getVRProjectionMatrix(): Matrix;
  90506. protected _updateCameraRotationMatrix(): void;
  90507. protected _updateWebVRCameraRotationMatrix(): void;
  90508. /**
  90509. * This function MUST be overwritten by the different WebVR cameras available.
  90510. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90511. * @hidden
  90512. */
  90513. _getWebVRProjectionMatrix(): Matrix;
  90514. /**
  90515. * This function MUST be overwritten by the different WebVR cameras available.
  90516. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90517. * @hidden
  90518. */
  90519. _getWebVRViewMatrix(): Matrix;
  90520. /** @hidden */
  90521. setCameraRigParameter(name: string, value: any): void;
  90522. /**
  90523. * needs to be overridden by children so sub has required properties to be copied
  90524. * @hidden
  90525. */
  90526. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90527. /**
  90528. * May need to be overridden by children
  90529. * @hidden
  90530. */
  90531. _updateRigCameras(): void;
  90532. /** @hidden */
  90533. _setupInputs(): void;
  90534. /**
  90535. * Serialiaze the camera setup to a json represention
  90536. * @returns the JSON representation
  90537. */
  90538. serialize(): any;
  90539. /**
  90540. * Clones the current camera.
  90541. * @param name The cloned camera name
  90542. * @returns the cloned camera
  90543. */
  90544. clone(name: string): Camera;
  90545. /**
  90546. * Gets the direction of the camera relative to a given local axis.
  90547. * @param localAxis Defines the reference axis to provide a relative direction.
  90548. * @return the direction
  90549. */
  90550. getDirection(localAxis: Vector3): Vector3;
  90551. /**
  90552. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90553. * @param localAxis Defines the reference axis to provide a relative direction.
  90554. * @param result Defines the vector to store the result in
  90555. */
  90556. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90557. /**
  90558. * Gets a camera constructor for a given camera type
  90559. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90560. * @param name The name of the camera the result will be able to instantiate
  90561. * @param scene The scene the result will construct the camera in
  90562. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90563. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90564. * @returns a factory method to construc the camera
  90565. */
  90566. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90567. /**
  90568. * Compute the world matrix of the camera.
  90569. * @returns the camera workd matrix
  90570. */
  90571. computeWorldMatrix(): Matrix;
  90572. /**
  90573. * Parse a JSON and creates the camera from the parsed information
  90574. * @param parsedCamera The JSON to parse
  90575. * @param scene The scene to instantiate the camera in
  90576. * @returns the newly constructed camera
  90577. */
  90578. static Parse(parsedCamera: any, scene: Scene): Camera;
  90579. }
  90580. }
  90581. declare module BABYLON {
  90582. /**
  90583. * Interface for any object that can request an animation frame
  90584. */
  90585. export interface ICustomAnimationFrameRequester {
  90586. /**
  90587. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90588. */
  90589. renderFunction?: Function;
  90590. /**
  90591. * Called to request the next frame to render to
  90592. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90593. */
  90594. requestAnimationFrame: Function;
  90595. /**
  90596. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90597. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90598. */
  90599. requestID?: number;
  90600. }
  90601. /**
  90602. * Interface containing an array of animations
  90603. */
  90604. export interface IAnimatable {
  90605. /**
  90606. * Array of animations
  90607. */
  90608. animations: Nullable<Array<Animation>>;
  90609. }
  90610. /** Interface used by value gradients (color, factor, ...) */
  90611. export interface IValueGradient {
  90612. /**
  90613. * Gets or sets the gradient value (between 0 and 1)
  90614. */
  90615. gradient: number;
  90616. }
  90617. /** Class used to store color4 gradient */
  90618. export class ColorGradient implements IValueGradient {
  90619. /**
  90620. * Gets or sets the gradient value (between 0 and 1)
  90621. */
  90622. gradient: number;
  90623. /**
  90624. * Gets or sets first associated color
  90625. */
  90626. color1: Color4;
  90627. /**
  90628. * Gets or sets second associated color
  90629. */
  90630. color2?: Color4;
  90631. /**
  90632. * Will get a color picked randomly between color1 and color2.
  90633. * If color2 is undefined then color1 will be used
  90634. * @param result defines the target Color4 to store the result in
  90635. */
  90636. getColorToRef(result: Color4): void;
  90637. }
  90638. /** Class used to store color 3 gradient */
  90639. export class Color3Gradient implements IValueGradient {
  90640. /**
  90641. * Gets or sets the gradient value (between 0 and 1)
  90642. */
  90643. gradient: number;
  90644. /**
  90645. * Gets or sets the associated color
  90646. */
  90647. color: Color3;
  90648. }
  90649. /** Class used to store factor gradient */
  90650. export class FactorGradient implements IValueGradient {
  90651. /**
  90652. * Gets or sets the gradient value (between 0 and 1)
  90653. */
  90654. gradient: number;
  90655. /**
  90656. * Gets or sets first associated factor
  90657. */
  90658. factor1: number;
  90659. /**
  90660. * Gets or sets second associated factor
  90661. */
  90662. factor2?: number;
  90663. /**
  90664. * Will get a number picked randomly between factor1 and factor2.
  90665. * If factor2 is undefined then factor1 will be used
  90666. * @returns the picked number
  90667. */
  90668. getFactor(): number;
  90669. }
  90670. /**
  90671. * @ignore
  90672. * Application error to support additional information when loading a file
  90673. */
  90674. export class LoadFileError extends Error {
  90675. /** defines the optional web request */
  90676. request?: WebRequest | undefined;
  90677. private static _setPrototypeOf;
  90678. /**
  90679. * Creates a new LoadFileError
  90680. * @param message defines the message of the error
  90681. * @param request defines the optional web request
  90682. */
  90683. constructor(message: string,
  90684. /** defines the optional web request */
  90685. request?: WebRequest | undefined);
  90686. }
  90687. /**
  90688. * Class used to define a retry strategy when error happens while loading assets
  90689. */
  90690. export class RetryStrategy {
  90691. /**
  90692. * Function used to defines an exponential back off strategy
  90693. * @param maxRetries defines the maximum number of retries (3 by default)
  90694. * @param baseInterval defines the interval between retries
  90695. * @returns the strategy function to use
  90696. */
  90697. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90698. }
  90699. /**
  90700. * File request interface
  90701. */
  90702. export interface IFileRequest {
  90703. /**
  90704. * Raised when the request is complete (success or error).
  90705. */
  90706. onCompleteObservable: Observable<IFileRequest>;
  90707. /**
  90708. * Aborts the request for a file.
  90709. */
  90710. abort: () => void;
  90711. }
  90712. /**
  90713. * Class containing a set of static utilities functions
  90714. */
  90715. export class Tools {
  90716. /**
  90717. * Gets or sets the base URL to use to load assets
  90718. */
  90719. static BaseUrl: string;
  90720. /**
  90721. * Enable/Disable Custom HTTP Request Headers globally.
  90722. * default = false
  90723. * @see CustomRequestHeaders
  90724. */
  90725. static UseCustomRequestHeaders: boolean;
  90726. /**
  90727. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90728. * i.e. when loading files, where the server/service expects an Authorization header
  90729. */
  90730. static CustomRequestHeaders: {
  90731. [key: string]: string;
  90732. };
  90733. /**
  90734. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90735. */
  90736. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90737. /**
  90738. * Default behaviour for cors in the application.
  90739. * It can be a string if the expected behavior is identical in the entire app.
  90740. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90741. */
  90742. static CorsBehavior: string | ((url: string | string[]) => string);
  90743. /**
  90744. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90745. * @ignorenaming
  90746. */
  90747. static UseFallbackTexture: boolean;
  90748. /**
  90749. * Use this object to register external classes like custom textures or material
  90750. * to allow the laoders to instantiate them
  90751. */
  90752. static RegisteredExternalClasses: {
  90753. [key: string]: Object;
  90754. };
  90755. /**
  90756. * Texture content used if a texture cannot loaded
  90757. * @ignorenaming
  90758. */
  90759. static fallbackTexture: string;
  90760. /**
  90761. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90762. * @param u defines the coordinate on X axis
  90763. * @param v defines the coordinate on Y axis
  90764. * @param width defines the width of the source data
  90765. * @param height defines the height of the source data
  90766. * @param pixels defines the source byte array
  90767. * @param color defines the output color
  90768. */
  90769. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90770. /**
  90771. * Interpolates between a and b via alpha
  90772. * @param a The lower value (returned when alpha = 0)
  90773. * @param b The upper value (returned when alpha = 1)
  90774. * @param alpha The interpolation-factor
  90775. * @return The mixed value
  90776. */
  90777. static Mix(a: number, b: number, alpha: number): number;
  90778. /**
  90779. * Tries to instantiate a new object from a given class name
  90780. * @param className defines the class name to instantiate
  90781. * @returns the new object or null if the system was not able to do the instantiation
  90782. */
  90783. static Instantiate(className: string): any;
  90784. /**
  90785. * Provides a slice function that will work even on IE
  90786. * @param data defines the array to slice
  90787. * @param start defines the start of the data (optional)
  90788. * @param end defines the end of the data (optional)
  90789. * @returns the new sliced array
  90790. */
  90791. static Slice<T>(data: T, start?: number, end?: number): T;
  90792. /**
  90793. * Polyfill for setImmediate
  90794. * @param action defines the action to execute after the current execution block
  90795. */
  90796. static SetImmediate(action: () => void): void;
  90797. /**
  90798. * Function indicating if a number is an exponent of 2
  90799. * @param value defines the value to test
  90800. * @returns true if the value is an exponent of 2
  90801. */
  90802. static IsExponentOfTwo(value: number): boolean;
  90803. private static _tmpFloatArray;
  90804. /**
  90805. * Returns the nearest 32-bit single precision float representation of a Number
  90806. * @param value A Number. If the parameter is of a different type, it will get converted
  90807. * to a number or to NaN if it cannot be converted
  90808. * @returns number
  90809. */
  90810. static FloatRound(value: number): number;
  90811. /**
  90812. * Find the next highest power of two.
  90813. * @param x Number to start search from.
  90814. * @return Next highest power of two.
  90815. */
  90816. static CeilingPOT(x: number): number;
  90817. /**
  90818. * Find the next lowest power of two.
  90819. * @param x Number to start search from.
  90820. * @return Next lowest power of two.
  90821. */
  90822. static FloorPOT(x: number): number;
  90823. /**
  90824. * Find the nearest power of two.
  90825. * @param x Number to start search from.
  90826. * @return Next nearest power of two.
  90827. */
  90828. static NearestPOT(x: number): number;
  90829. /**
  90830. * Get the closest exponent of two
  90831. * @param value defines the value to approximate
  90832. * @param max defines the maximum value to return
  90833. * @param mode defines how to define the closest value
  90834. * @returns closest exponent of two of the given value
  90835. */
  90836. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90837. /**
  90838. * Extracts the filename from a path
  90839. * @param path defines the path to use
  90840. * @returns the filename
  90841. */
  90842. static GetFilename(path: string): string;
  90843. /**
  90844. * Extracts the "folder" part of a path (everything before the filename).
  90845. * @param uri The URI to extract the info from
  90846. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90847. * @returns The "folder" part of the path
  90848. */
  90849. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90850. /**
  90851. * Extracts text content from a DOM element hierarchy
  90852. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90853. */
  90854. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90855. /**
  90856. * Convert an angle in radians to degrees
  90857. * @param angle defines the angle to convert
  90858. * @returns the angle in degrees
  90859. */
  90860. static ToDegrees(angle: number): number;
  90861. /**
  90862. * Convert an angle in degrees to radians
  90863. * @param angle defines the angle to convert
  90864. * @returns the angle in radians
  90865. */
  90866. static ToRadians(angle: number): number;
  90867. /**
  90868. * Encode a buffer to a base64 string
  90869. * @param buffer defines the buffer to encode
  90870. * @returns the encoded string
  90871. */
  90872. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90873. /**
  90874. * Extracts minimum and maximum values from a list of indexed positions
  90875. * @param positions defines the positions to use
  90876. * @param indices defines the indices to the positions
  90877. * @param indexStart defines the start index
  90878. * @param indexCount defines the end index
  90879. * @param bias defines bias value to add to the result
  90880. * @return minimum and maximum values
  90881. */
  90882. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90883. minimum: Vector3;
  90884. maximum: Vector3;
  90885. };
  90886. /**
  90887. * Extracts minimum and maximum values from a list of positions
  90888. * @param positions defines the positions to use
  90889. * @param start defines the start index in the positions array
  90890. * @param count defines the number of positions to handle
  90891. * @param bias defines bias value to add to the result
  90892. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90893. * @return minimum and maximum values
  90894. */
  90895. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90896. minimum: Vector3;
  90897. maximum: Vector3;
  90898. };
  90899. /**
  90900. * Returns an array if obj is not an array
  90901. * @param obj defines the object to evaluate as an array
  90902. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90903. * @returns either obj directly if obj is an array or a new array containing obj
  90904. */
  90905. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90906. /**
  90907. * Gets the pointer prefix to use
  90908. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90909. */
  90910. static GetPointerPrefix(): string;
  90911. /**
  90912. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90913. * @param func - the function to be called
  90914. * @param requester - the object that will request the next frame. Falls back to window.
  90915. * @returns frame number
  90916. */
  90917. static QueueNewFrame(func: () => void, requester?: any): number;
  90918. /**
  90919. * Ask the browser to promote the current element to fullscreen rendering mode
  90920. * @param element defines the DOM element to promote
  90921. */
  90922. static RequestFullscreen(element: HTMLElement): void;
  90923. /**
  90924. * Asks the browser to exit fullscreen mode
  90925. */
  90926. static ExitFullscreen(): void;
  90927. /**
  90928. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90929. * @param url define the url we are trying
  90930. * @param element define the dom element where to configure the cors policy
  90931. */
  90932. static SetCorsBehavior(url: string | string[], element: {
  90933. crossOrigin: string | null;
  90934. }): void;
  90935. /**
  90936. * Removes unwanted characters from an url
  90937. * @param url defines the url to clean
  90938. * @returns the cleaned url
  90939. */
  90940. static CleanUrl(url: string): string;
  90941. /**
  90942. * Gets or sets a function used to pre-process url before using them to load assets
  90943. */
  90944. static PreprocessUrl: (url: string) => string;
  90945. /**
  90946. * Loads an image as an HTMLImageElement.
  90947. * @param input url string, ArrayBuffer, or Blob to load
  90948. * @param onLoad callback called when the image successfully loads
  90949. * @param onError callback called when the image fails to load
  90950. * @param offlineProvider offline provider for caching
  90951. * @returns the HTMLImageElement of the loaded image
  90952. */
  90953. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90954. /**
  90955. * Loads a file
  90956. * @param url url string, ArrayBuffer, or Blob to load
  90957. * @param onSuccess callback called when the file successfully loads
  90958. * @param onProgress callback called while file is loading (if the server supports this mode)
  90959. * @param offlineProvider defines the offline provider for caching
  90960. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90961. * @param onError callback called when the file fails to load
  90962. * @returns a file request object
  90963. */
  90964. 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;
  90965. /**
  90966. * Load a script (identified by an url). When the url returns, the
  90967. * content of this file is added into a new script element, attached to the DOM (body element)
  90968. * @param scriptUrl defines the url of the script to laod
  90969. * @param onSuccess defines the callback called when the script is loaded
  90970. * @param onError defines the callback to call if an error occurs
  90971. * @param scriptId defines the id of the script element
  90972. */
  90973. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90974. /**
  90975. * Load an asynchronous script (identified by an url). When the url returns, the
  90976. * content of this file is added into a new script element, attached to the DOM (body element)
  90977. * @param scriptUrl defines the url of the script to laod
  90978. * @param scriptId defines the id of the script element
  90979. * @returns a promise request object
  90980. */
  90981. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90982. /**
  90983. * Loads a file from a blob
  90984. * @param fileToLoad defines the blob to use
  90985. * @param callback defines the callback to call when data is loaded
  90986. * @param progressCallback defines the callback to call during loading process
  90987. * @returns a file request object
  90988. */
  90989. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90990. /**
  90991. * Loads a file
  90992. * @param fileToLoad defines the file to load
  90993. * @param callback defines the callback to call when data is loaded
  90994. * @param progressCallBack defines the callback to call during loading process
  90995. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90996. * @returns a file request object
  90997. */
  90998. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90999. /**
  91000. * Creates a data url from a given string content
  91001. * @param content defines the content to convert
  91002. * @returns the new data url link
  91003. */
  91004. static FileAsURL(content: string): string;
  91005. /**
  91006. * Format the given number to a specific decimal format
  91007. * @param value defines the number to format
  91008. * @param decimals defines the number of decimals to use
  91009. * @returns the formatted string
  91010. */
  91011. static Format(value: number, decimals?: number): string;
  91012. /**
  91013. * Checks if a given vector is inside a specific range
  91014. * @param v defines the vector to test
  91015. * @param min defines the minimum range
  91016. * @param max defines the maximum range
  91017. */
  91018. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  91019. /**
  91020. * Tries to copy an object by duplicating every property
  91021. * @param source defines the source object
  91022. * @param destination defines the target object
  91023. * @param doNotCopyList defines a list of properties to avoid
  91024. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  91025. */
  91026. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  91027. /**
  91028. * Gets a boolean indicating if the given object has no own property
  91029. * @param obj defines the object to test
  91030. * @returns true if object has no own property
  91031. */
  91032. static IsEmpty(obj: any): boolean;
  91033. /**
  91034. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  91035. * @param str Source string
  91036. * @param suffix Suffix to search for in the source string
  91037. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  91038. */
  91039. static EndsWith(str: string, suffix: string): boolean;
  91040. /**
  91041. * Function used to register events at window level
  91042. * @param events defines the events to register
  91043. */
  91044. static RegisterTopRootEvents(events: {
  91045. name: string;
  91046. handler: Nullable<(e: FocusEvent) => any>;
  91047. }[]): void;
  91048. /**
  91049. * Function used to unregister events from window level
  91050. * @param events defines the events to unregister
  91051. */
  91052. static UnregisterTopRootEvents(events: {
  91053. name: string;
  91054. handler: Nullable<(e: FocusEvent) => any>;
  91055. }[]): void;
  91056. /**
  91057. * @ignore
  91058. */
  91059. static _ScreenshotCanvas: HTMLCanvasElement;
  91060. /**
  91061. * Dumps the current bound framebuffer
  91062. * @param width defines the rendering width
  91063. * @param height defines the rendering height
  91064. * @param engine defines the hosting engine
  91065. * @param successCallback defines the callback triggered once the data are available
  91066. * @param mimeType defines the mime type of the result
  91067. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  91068. */
  91069. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91070. /**
  91071. * Converts the canvas data to blob.
  91072. * This acts as a polyfill for browsers not supporting the to blob function.
  91073. * @param canvas Defines the canvas to extract the data from
  91074. * @param successCallback Defines the callback triggered once the data are available
  91075. * @param mimeType Defines the mime type of the result
  91076. */
  91077. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  91078. /**
  91079. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  91080. * @param successCallback defines the callback triggered once the data are available
  91081. * @param mimeType defines the mime type of the result
  91082. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  91083. */
  91084. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91085. /**
  91086. * Downloads a blob in the browser
  91087. * @param blob defines the blob to download
  91088. * @param fileName defines the name of the downloaded file
  91089. */
  91090. static Download(blob: Blob, fileName: string): void;
  91091. /**
  91092. * Captures a screenshot of the current rendering
  91093. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91094. * @param engine defines the rendering engine
  91095. * @param camera defines the source camera
  91096. * @param size This parameter can be set to a single number or to an object with the
  91097. * following (optional) properties: precision, width, height. If a single number is passed,
  91098. * it will be used for both width and height. If an object is passed, the screenshot size
  91099. * will be derived from the parameters. The precision property is a multiplier allowing
  91100. * rendering at a higher or lower resolution
  91101. * @param successCallback defines the callback receives a single parameter which contains the
  91102. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91103. * src parameter of an <img> to display it
  91104. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  91105. * Check your browser for supported MIME types
  91106. */
  91107. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  91108. /**
  91109. * Generates an image screenshot from the specified camera.
  91110. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91111. * @param engine The engine to use for rendering
  91112. * @param camera The camera to use for rendering
  91113. * @param size This parameter can be set to a single number or to an object with the
  91114. * following (optional) properties: precision, width, height. If a single number is passed,
  91115. * it will be used for both width and height. If an object is passed, the screenshot size
  91116. * will be derived from the parameters. The precision property is a multiplier allowing
  91117. * rendering at a higher or lower resolution
  91118. * @param successCallback The callback receives a single parameter which contains the
  91119. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91120. * src parameter of an <img> to display it
  91121. * @param mimeType The MIME type of the screenshot image (default: image/png).
  91122. * Check your browser for supported MIME types
  91123. * @param samples Texture samples (default: 1)
  91124. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  91125. * @param fileName A name for for the downloaded file.
  91126. */
  91127. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  91128. /**
  91129. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91130. * Be aware Math.random() could cause collisions, but:
  91131. * "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"
  91132. * @returns a pseudo random id
  91133. */
  91134. static RandomId(): string;
  91135. /**
  91136. * Test if the given uri is a base64 string
  91137. * @param uri The uri to test
  91138. * @return True if the uri is a base64 string or false otherwise
  91139. */
  91140. static IsBase64(uri: string): boolean;
  91141. /**
  91142. * Decode the given base64 uri.
  91143. * @param uri The uri to decode
  91144. * @return The decoded base64 data.
  91145. */
  91146. static DecodeBase64(uri: string): ArrayBuffer;
  91147. /**
  91148. * Gets the absolute url.
  91149. * @param url the input url
  91150. * @return the absolute url
  91151. */
  91152. static GetAbsoluteUrl(url: string): string;
  91153. /**
  91154. * No log
  91155. */
  91156. static readonly NoneLogLevel: number;
  91157. /**
  91158. * Only message logs
  91159. */
  91160. static readonly MessageLogLevel: number;
  91161. /**
  91162. * Only warning logs
  91163. */
  91164. static readonly WarningLogLevel: number;
  91165. /**
  91166. * Only error logs
  91167. */
  91168. static readonly ErrorLogLevel: number;
  91169. /**
  91170. * All logs
  91171. */
  91172. static readonly AllLogLevel: number;
  91173. /**
  91174. * Gets a value indicating the number of loading errors
  91175. * @ignorenaming
  91176. */
  91177. static readonly errorsCount: number;
  91178. /**
  91179. * Callback called when a new log is added
  91180. */
  91181. static OnNewCacheEntry: (entry: string) => void;
  91182. /**
  91183. * Log a message to the console
  91184. * @param message defines the message to log
  91185. */
  91186. static Log(message: string): void;
  91187. /**
  91188. * Write a warning message to the console
  91189. * @param message defines the message to log
  91190. */
  91191. static Warn(message: string): void;
  91192. /**
  91193. * Write an error message to the console
  91194. * @param message defines the message to log
  91195. */
  91196. static Error(message: string): void;
  91197. /**
  91198. * Gets current log cache (list of logs)
  91199. */
  91200. static readonly LogCache: string;
  91201. /**
  91202. * Clears the log cache
  91203. */
  91204. static ClearLogCache(): void;
  91205. /**
  91206. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  91207. */
  91208. static LogLevels: number;
  91209. /**
  91210. * Checks if the loaded document was accessed via `file:`-Protocol.
  91211. * @returns boolean
  91212. */
  91213. static IsFileURL(): boolean;
  91214. /**
  91215. * Checks if the window object exists
  91216. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  91217. */
  91218. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  91219. /**
  91220. * No performance log
  91221. */
  91222. static readonly PerformanceNoneLogLevel: number;
  91223. /**
  91224. * Use user marks to log performance
  91225. */
  91226. static readonly PerformanceUserMarkLogLevel: number;
  91227. /**
  91228. * Log performance to the console
  91229. */
  91230. static readonly PerformanceConsoleLogLevel: number;
  91231. private static _performance;
  91232. /**
  91233. * Sets the current performance log level
  91234. */
  91235. static PerformanceLogLevel: number;
  91236. private static _StartPerformanceCounterDisabled;
  91237. private static _EndPerformanceCounterDisabled;
  91238. private static _StartUserMark;
  91239. private static _EndUserMark;
  91240. private static _StartPerformanceConsole;
  91241. private static _EndPerformanceConsole;
  91242. /**
  91243. * Starts a performance counter
  91244. */
  91245. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91246. /**
  91247. * Ends a specific performance coutner
  91248. */
  91249. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91250. /**
  91251. * Gets either window.performance.now() if supported or Date.now() else
  91252. */
  91253. static readonly Now: number;
  91254. /**
  91255. * This method will return the name of the class used to create the instance of the given object.
  91256. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  91257. * @param object the object to get the class name from
  91258. * @param isType defines if the object is actually a type
  91259. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  91260. */
  91261. static GetClassName(object: any, isType?: boolean): string;
  91262. /**
  91263. * Gets the first element of an array satisfying a given predicate
  91264. * @param array defines the array to browse
  91265. * @param predicate defines the predicate to use
  91266. * @returns null if not found or the element
  91267. */
  91268. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  91269. /**
  91270. * This method will return the name of the full name of the class, including its owning module (if any).
  91271. * 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).
  91272. * @param object the object to get the class name from
  91273. * @param isType defines if the object is actually a type
  91274. * @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.
  91275. * @ignorenaming
  91276. */
  91277. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  91278. /**
  91279. * Returns a promise that resolves after the given amount of time.
  91280. * @param delay Number of milliseconds to delay
  91281. * @returns Promise that resolves after the given amount of time
  91282. */
  91283. static DelayAsync(delay: number): Promise<void>;
  91284. /**
  91285. * Gets the current gradient from an array of IValueGradient
  91286. * @param ratio defines the current ratio to get
  91287. * @param gradients defines the array of IValueGradient
  91288. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91289. */
  91290. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91291. }
  91292. /**
  91293. * This class is used to track a performance counter which is number based.
  91294. * The user has access to many properties which give statistics of different nature.
  91295. *
  91296. * The implementer can track two kinds of Performance Counter: time and count.
  91297. * 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.
  91298. * 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.
  91299. */
  91300. export class PerfCounter {
  91301. /**
  91302. * Gets or sets a global boolean to turn on and off all the counters
  91303. */
  91304. static Enabled: boolean;
  91305. /**
  91306. * Returns the smallest value ever
  91307. */
  91308. readonly min: number;
  91309. /**
  91310. * Returns the biggest value ever
  91311. */
  91312. readonly max: number;
  91313. /**
  91314. * Returns the average value since the performance counter is running
  91315. */
  91316. readonly average: number;
  91317. /**
  91318. * Returns the average value of the last second the counter was monitored
  91319. */
  91320. readonly lastSecAverage: number;
  91321. /**
  91322. * Returns the current value
  91323. */
  91324. readonly current: number;
  91325. /**
  91326. * Gets the accumulated total
  91327. */
  91328. readonly total: number;
  91329. /**
  91330. * Gets the total value count
  91331. */
  91332. readonly count: number;
  91333. /**
  91334. * Creates a new counter
  91335. */
  91336. constructor();
  91337. /**
  91338. * Call this method to start monitoring a new frame.
  91339. * 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.
  91340. */
  91341. fetchNewFrame(): void;
  91342. /**
  91343. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  91344. * @param newCount the count value to add to the monitored count
  91345. * @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.
  91346. */
  91347. addCount(newCount: number, fetchResult: boolean): void;
  91348. /**
  91349. * Start monitoring this performance counter
  91350. */
  91351. beginMonitoring(): void;
  91352. /**
  91353. * Compute the time lapsed since the previous beginMonitoring() call.
  91354. * @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
  91355. */
  91356. endMonitoring(newFrame?: boolean): void;
  91357. private _fetchResult;
  91358. private _startMonitoringTime;
  91359. private _min;
  91360. private _max;
  91361. private _average;
  91362. private _current;
  91363. private _totalValueCount;
  91364. private _totalAccumulated;
  91365. private _lastSecAverage;
  91366. private _lastSecAccumulated;
  91367. private _lastSecTime;
  91368. private _lastSecValueCount;
  91369. }
  91370. /**
  91371. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  91372. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  91373. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  91374. * @param name The name of the class, case should be preserved
  91375. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  91376. */
  91377. export function className(name: string, module?: string): (target: Object) => void;
  91378. /**
  91379. * An implementation of a loop for asynchronous functions.
  91380. */
  91381. export class AsyncLoop {
  91382. /**
  91383. * Defines the number of iterations for the loop
  91384. */
  91385. iterations: number;
  91386. /**
  91387. * Defines the current index of the loop.
  91388. */
  91389. index: number;
  91390. private _done;
  91391. private _fn;
  91392. private _successCallback;
  91393. /**
  91394. * Constructor.
  91395. * @param iterations the number of iterations.
  91396. * @param func the function to run each iteration
  91397. * @param successCallback the callback that will be called upon succesful execution
  91398. * @param offset starting offset.
  91399. */
  91400. constructor(
  91401. /**
  91402. * Defines the number of iterations for the loop
  91403. */
  91404. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91405. /**
  91406. * Execute the next iteration. Must be called after the last iteration was finished.
  91407. */
  91408. executeNext(): void;
  91409. /**
  91410. * Break the loop and run the success callback.
  91411. */
  91412. breakLoop(): void;
  91413. /**
  91414. * Create and run an async loop.
  91415. * @param iterations the number of iterations.
  91416. * @param fn the function to run each iteration
  91417. * @param successCallback the callback that will be called upon succesful execution
  91418. * @param offset starting offset.
  91419. * @returns the created async loop object
  91420. */
  91421. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91422. /**
  91423. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91424. * @param iterations total number of iterations
  91425. * @param syncedIterations number of synchronous iterations in each async iteration.
  91426. * @param fn the function to call each iteration.
  91427. * @param callback a success call back that will be called when iterating stops.
  91428. * @param breakFunction a break condition (optional)
  91429. * @param timeout timeout settings for the setTimeout function. default - 0.
  91430. * @returns the created async loop object
  91431. */
  91432. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91433. }
  91434. }
  91435. declare module BABYLON {
  91436. /** @hidden */
  91437. export interface ICollisionCoordinator {
  91438. createCollider(): Collider;
  91439. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91440. init(scene: Scene): void;
  91441. }
  91442. /** @hidden */
  91443. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91444. private _scene;
  91445. private _scaledPosition;
  91446. private _scaledVelocity;
  91447. private _finalPosition;
  91448. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91449. createCollider(): Collider;
  91450. init(scene: Scene): void;
  91451. private _collideWithWorld;
  91452. }
  91453. }
  91454. declare module BABYLON {
  91455. /**
  91456. * Class used to manage all inputs for the scene.
  91457. */
  91458. export class InputManager {
  91459. /** The distance in pixel that you have to move to prevent some events */
  91460. static DragMovementThreshold: number;
  91461. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91462. static LongPressDelay: number;
  91463. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91464. static DoubleClickDelay: number;
  91465. /** If you need to check double click without raising a single click at first click, enable this flag */
  91466. static ExclusiveDoubleClickMode: boolean;
  91467. private _wheelEventName;
  91468. private _onPointerMove;
  91469. private _onPointerDown;
  91470. private _onPointerUp;
  91471. private _initClickEvent;
  91472. private _initActionManager;
  91473. private _delayedSimpleClick;
  91474. private _delayedSimpleClickTimeout;
  91475. private _previousDelayedSimpleClickTimeout;
  91476. private _meshPickProceed;
  91477. private _previousButtonPressed;
  91478. private _currentPickResult;
  91479. private _previousPickResult;
  91480. private _totalPointersPressed;
  91481. private _doubleClickOccured;
  91482. private _pointerOverMesh;
  91483. private _pickedDownMesh;
  91484. private _pickedUpMesh;
  91485. private _pointerX;
  91486. private _pointerY;
  91487. private _unTranslatedPointerX;
  91488. private _unTranslatedPointerY;
  91489. private _startingPointerPosition;
  91490. private _previousStartingPointerPosition;
  91491. private _startingPointerTime;
  91492. private _previousStartingPointerTime;
  91493. private _pointerCaptures;
  91494. private _onKeyDown;
  91495. private _onKeyUp;
  91496. private _onCanvasFocusObserver;
  91497. private _onCanvasBlurObserver;
  91498. private _scene;
  91499. /**
  91500. * Creates a new InputManager
  91501. * @param scene defines the hosting scene
  91502. */
  91503. constructor(scene: Scene);
  91504. /**
  91505. * Gets the mesh that is currently under the pointer
  91506. */
  91507. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91508. /**
  91509. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  91510. */
  91511. readonly unTranslatedPointer: Vector2;
  91512. /**
  91513. * Gets or sets the current on-screen X position of the pointer
  91514. */
  91515. pointerX: number;
  91516. /**
  91517. * Gets or sets the current on-screen Y position of the pointer
  91518. */
  91519. pointerY: number;
  91520. private _updatePointerPosition;
  91521. private _processPointerMove;
  91522. private _setRayOnPointerInfo;
  91523. private _checkPrePointerObservable;
  91524. /**
  91525. * Use this method to simulate a pointer move on a mesh
  91526. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91527. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91528. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91529. */
  91530. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91531. /**
  91532. * Use this method to simulate a pointer down on a mesh
  91533. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91534. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91535. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91536. */
  91537. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91538. private _processPointerDown;
  91539. /** @hidden */
  91540. _isPointerSwiping(): boolean;
  91541. /**
  91542. * Use this method to simulate a pointer up on a mesh
  91543. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91544. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91545. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91546. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91547. */
  91548. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  91549. private _processPointerUp;
  91550. /**
  91551. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91552. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91553. * @returns true if the pointer was captured
  91554. */
  91555. isPointerCaptured(pointerId?: number): boolean;
  91556. /**
  91557. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91558. * @param attachUp defines if you want to attach events to pointerup
  91559. * @param attachDown defines if you want to attach events to pointerdown
  91560. * @param attachMove defines if you want to attach events to pointermove
  91561. */
  91562. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91563. /**
  91564. * Detaches all event handlers
  91565. */
  91566. detachControl(): void;
  91567. /**
  91568. * Force the value of meshUnderPointer
  91569. * @param mesh defines the mesh to use
  91570. */
  91571. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91572. /**
  91573. * Gets the mesh under the pointer
  91574. * @returns a Mesh or null if no mesh is under the pointer
  91575. */
  91576. getPointerOverMesh(): Nullable<AbstractMesh>;
  91577. }
  91578. }
  91579. declare module BABYLON {
  91580. /**
  91581. * This class defines the direct association between an animation and a target
  91582. */
  91583. export class TargetedAnimation {
  91584. /**
  91585. * Animation to perform
  91586. */
  91587. animation: Animation;
  91588. /**
  91589. * Target to animate
  91590. */
  91591. target: any;
  91592. }
  91593. /**
  91594. * Use this class to create coordinated animations on multiple targets
  91595. */
  91596. export class AnimationGroup implements IDisposable {
  91597. /** The name of the animation group */
  91598. name: string;
  91599. private _scene;
  91600. private _targetedAnimations;
  91601. private _animatables;
  91602. private _from;
  91603. private _to;
  91604. private _isStarted;
  91605. private _isPaused;
  91606. private _speedRatio;
  91607. /**
  91608. * Gets or sets the unique id of the node
  91609. */
  91610. uniqueId: number;
  91611. /**
  91612. * This observable will notify when one animation have ended
  91613. */
  91614. onAnimationEndObservable: Observable<TargetedAnimation>;
  91615. /**
  91616. * Observer raised when one animation loops
  91617. */
  91618. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91619. /**
  91620. * This observable will notify when all animations have ended.
  91621. */
  91622. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91623. /**
  91624. * This observable will notify when all animations have paused.
  91625. */
  91626. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91627. /**
  91628. * This observable will notify when all animations are playing.
  91629. */
  91630. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91631. /**
  91632. * Gets the first frame
  91633. */
  91634. readonly from: number;
  91635. /**
  91636. * Gets the last frame
  91637. */
  91638. readonly to: number;
  91639. /**
  91640. * Define if the animations are started
  91641. */
  91642. readonly isStarted: boolean;
  91643. /**
  91644. * Gets a value indicating that the current group is playing
  91645. */
  91646. readonly isPlaying: boolean;
  91647. /**
  91648. * Gets or sets the speed ratio to use for all animations
  91649. */
  91650. /**
  91651. * Gets or sets the speed ratio to use for all animations
  91652. */
  91653. speedRatio: number;
  91654. /**
  91655. * Gets the targeted animations for this animation group
  91656. */
  91657. readonly targetedAnimations: Array<TargetedAnimation>;
  91658. /**
  91659. * returning the list of animatables controlled by this animation group.
  91660. */
  91661. readonly animatables: Array<Animatable>;
  91662. /**
  91663. * Instantiates a new Animation Group.
  91664. * This helps managing several animations at once.
  91665. * @see http://doc.babylonjs.com/how_to/group
  91666. * @param name Defines the name of the group
  91667. * @param scene Defines the scene the group belongs to
  91668. */
  91669. constructor(
  91670. /** The name of the animation group */
  91671. name: string, scene?: Nullable<Scene>);
  91672. /**
  91673. * Add an animation (with its target) in the group
  91674. * @param animation defines the animation we want to add
  91675. * @param target defines the target of the animation
  91676. * @returns the TargetedAnimation object
  91677. */
  91678. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91679. /**
  91680. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91681. * It can add constant keys at begin or end
  91682. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91683. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91684. * @returns the animation group
  91685. */
  91686. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91687. /**
  91688. * Start all animations on given targets
  91689. * @param loop defines if animations must loop
  91690. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91691. * @param from defines the from key (optional)
  91692. * @param to defines the to key (optional)
  91693. * @returns the current animation group
  91694. */
  91695. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91696. /**
  91697. * Pause all animations
  91698. * @returns the animation group
  91699. */
  91700. pause(): AnimationGroup;
  91701. /**
  91702. * Play all animations to initial state
  91703. * This function will start() the animations if they were not started or will restart() them if they were paused
  91704. * @param loop defines if animations must loop
  91705. * @returns the animation group
  91706. */
  91707. play(loop?: boolean): AnimationGroup;
  91708. /**
  91709. * Reset all animations to initial state
  91710. * @returns the animation group
  91711. */
  91712. reset(): AnimationGroup;
  91713. /**
  91714. * Restart animations from key 0
  91715. * @returns the animation group
  91716. */
  91717. restart(): AnimationGroup;
  91718. /**
  91719. * Stop all animations
  91720. * @returns the animation group
  91721. */
  91722. stop(): AnimationGroup;
  91723. /**
  91724. * Set animation weight for all animatables
  91725. * @param weight defines the weight to use
  91726. * @return the animationGroup
  91727. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91728. */
  91729. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91730. /**
  91731. * Synchronize and normalize all animatables with a source animatable
  91732. * @param root defines the root animatable to synchronize with
  91733. * @return the animationGroup
  91734. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91735. */
  91736. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91737. /**
  91738. * Goes to a specific frame in this animation group
  91739. * @param frame the frame number to go to
  91740. * @return the animationGroup
  91741. */
  91742. goToFrame(frame: number): AnimationGroup;
  91743. /**
  91744. * Dispose all associated resources
  91745. */
  91746. dispose(): void;
  91747. private _checkAnimationGroupEnded;
  91748. /**
  91749. * Clone the current animation group and returns a copy
  91750. * @param newName defines the name of the new group
  91751. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91752. * @returns the new aniamtion group
  91753. */
  91754. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91755. /**
  91756. * Returns a new AnimationGroup object parsed from the source provided.
  91757. * @param parsedAnimationGroup defines the source
  91758. * @param scene defines the scene that will receive the animationGroup
  91759. * @returns a new AnimationGroup
  91760. */
  91761. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91762. /**
  91763. * Returns the string "AnimationGroup"
  91764. * @returns "AnimationGroup"
  91765. */
  91766. getClassName(): string;
  91767. /**
  91768. * Creates a detailled string about the object
  91769. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91770. * @returns a string representing the object
  91771. */
  91772. toString(fullDetails?: boolean): string;
  91773. }
  91774. }
  91775. declare module BABYLON {
  91776. /**
  91777. * Define an interface for all classes that will hold resources
  91778. */
  91779. export interface IDisposable {
  91780. /**
  91781. * Releases all held resources
  91782. */
  91783. dispose(): void;
  91784. }
  91785. /** Interface defining initialization parameters for Scene class */
  91786. export interface SceneOptions {
  91787. /**
  91788. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91789. * It will improve performance when the number of geometries becomes important.
  91790. */
  91791. useGeometryUniqueIdsMap?: boolean;
  91792. /**
  91793. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91794. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91795. */
  91796. useMaterialMeshMap?: boolean;
  91797. /**
  91798. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91799. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91800. */
  91801. useClonedMeshhMap?: boolean;
  91802. }
  91803. /**
  91804. * Represents a scene to be rendered by the engine.
  91805. * @see http://doc.babylonjs.com/features/scene
  91806. */
  91807. export class Scene extends AbstractScene implements IAnimatable {
  91808. private static _uniqueIdCounter;
  91809. /** The fog is deactivated */
  91810. static readonly FOGMODE_NONE: number;
  91811. /** The fog density is following an exponential function */
  91812. static readonly FOGMODE_EXP: number;
  91813. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91814. static readonly FOGMODE_EXP2: number;
  91815. /** The fog density is following a linear function. */
  91816. static readonly FOGMODE_LINEAR: number;
  91817. /**
  91818. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91819. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91820. */
  91821. static MinDeltaTime: number;
  91822. /**
  91823. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91824. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91825. */
  91826. static MaxDeltaTime: number;
  91827. /**
  91828. * Factory used to create the default material.
  91829. * @param name The name of the material to create
  91830. * @param scene The scene to create the material for
  91831. * @returns The default material
  91832. */
  91833. static DefaultMaterialFactory(scene: Scene): Material;
  91834. /**
  91835. * Factory used to create the a collision coordinator.
  91836. * @returns The collision coordinator
  91837. */
  91838. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91839. /** @hidden */
  91840. _inputManager: InputManager;
  91841. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91842. cameraToUseForPointers: Nullable<Camera>;
  91843. /** @hidden */
  91844. readonly _isScene: boolean;
  91845. /**
  91846. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91847. */
  91848. autoClear: boolean;
  91849. /**
  91850. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91851. */
  91852. autoClearDepthAndStencil: boolean;
  91853. /**
  91854. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91855. */
  91856. clearColor: Color4;
  91857. /**
  91858. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91859. */
  91860. ambientColor: Color3;
  91861. /**
  91862. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91863. * It should only be one of the following (if not the default embedded one):
  91864. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91865. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91866. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91867. * The material properties need to be setup according to the type of texture in use.
  91868. */
  91869. environmentBRDFTexture: BaseTexture;
  91870. /** @hidden */
  91871. protected _environmentTexture: Nullable<BaseTexture>;
  91872. /**
  91873. * Texture used in all pbr material as the reflection texture.
  91874. * As in the majority of the scene they are the same (exception for multi room and so on),
  91875. * this is easier to reference from here than from all the materials.
  91876. */
  91877. /**
  91878. * Texture used in all pbr material as the reflection texture.
  91879. * As in the majority of the scene they are the same (exception for multi room and so on),
  91880. * this is easier to set here than in all the materials.
  91881. */
  91882. environmentTexture: Nullable<BaseTexture>;
  91883. /** @hidden */
  91884. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91885. /**
  91886. * Default image processing configuration used either in the rendering
  91887. * Forward main pass or through the imageProcessingPostProcess if present.
  91888. * As in the majority of the scene they are the same (exception for multi camera),
  91889. * this is easier to reference from here than from all the materials and post process.
  91890. *
  91891. * No setter as we it is a shared configuration, you can set the values instead.
  91892. */
  91893. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91894. private _forceWireframe;
  91895. /**
  91896. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91897. */
  91898. forceWireframe: boolean;
  91899. private _forcePointsCloud;
  91900. /**
  91901. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91902. */
  91903. forcePointsCloud: boolean;
  91904. /**
  91905. * Gets or sets the active clipplane 1
  91906. */
  91907. clipPlane: Nullable<Plane>;
  91908. /**
  91909. * Gets or sets the active clipplane 2
  91910. */
  91911. clipPlane2: Nullable<Plane>;
  91912. /**
  91913. * Gets or sets the active clipplane 3
  91914. */
  91915. clipPlane3: Nullable<Plane>;
  91916. /**
  91917. * Gets or sets the active clipplane 4
  91918. */
  91919. clipPlane4: Nullable<Plane>;
  91920. /**
  91921. * Gets or sets a boolean indicating if animations are enabled
  91922. */
  91923. animationsEnabled: boolean;
  91924. private _animationPropertiesOverride;
  91925. /**
  91926. * Gets or sets the animation properties override
  91927. */
  91928. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91929. /**
  91930. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91931. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91932. */
  91933. useConstantAnimationDeltaTime: boolean;
  91934. /**
  91935. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91936. * Please note that it requires to run a ray cast through the scene on every frame
  91937. */
  91938. constantlyUpdateMeshUnderPointer: boolean;
  91939. /**
  91940. * Defines the HTML cursor to use when hovering over interactive elements
  91941. */
  91942. hoverCursor: string;
  91943. /**
  91944. * Defines the HTML default cursor to use (empty by default)
  91945. */
  91946. defaultCursor: string;
  91947. /**
  91948. * This is used to call preventDefault() on pointer down
  91949. * in order to block unwanted artifacts like system double clicks
  91950. */
  91951. preventDefaultOnPointerDown: boolean;
  91952. /**
  91953. * This is used to call preventDefault() on pointer up
  91954. * in order to block unwanted artifacts like system double clicks
  91955. */
  91956. preventDefaultOnPointerUp: boolean;
  91957. /**
  91958. * Gets or sets user defined metadata
  91959. */
  91960. metadata: any;
  91961. /**
  91962. * For internal use only. Please do not use.
  91963. */
  91964. reservedDataStore: any;
  91965. /**
  91966. * Gets the name of the plugin used to load this scene (null by default)
  91967. */
  91968. loadingPluginName: string;
  91969. /**
  91970. * Use this array to add regular expressions used to disable offline support for specific urls
  91971. */
  91972. disableOfflineSupportExceptionRules: RegExp[];
  91973. /**
  91974. * An event triggered when the scene is disposed.
  91975. */
  91976. onDisposeObservable: Observable<Scene>;
  91977. private _onDisposeObserver;
  91978. /** Sets a function to be executed when this scene is disposed. */
  91979. onDispose: () => void;
  91980. /**
  91981. * An event triggered before rendering the scene (right after animations and physics)
  91982. */
  91983. onBeforeRenderObservable: Observable<Scene>;
  91984. private _onBeforeRenderObserver;
  91985. /** Sets a function to be executed before rendering this scene */
  91986. beforeRender: Nullable<() => void>;
  91987. /**
  91988. * An event triggered after rendering the scene
  91989. */
  91990. onAfterRenderObservable: Observable<Scene>;
  91991. private _onAfterRenderObserver;
  91992. /** Sets a function to be executed after rendering this scene */
  91993. afterRender: Nullable<() => void>;
  91994. /**
  91995. * An event triggered before animating the scene
  91996. */
  91997. onBeforeAnimationsObservable: Observable<Scene>;
  91998. /**
  91999. * An event triggered after animations processing
  92000. */
  92001. onAfterAnimationsObservable: Observable<Scene>;
  92002. /**
  92003. * An event triggered before draw calls are ready to be sent
  92004. */
  92005. onBeforeDrawPhaseObservable: Observable<Scene>;
  92006. /**
  92007. * An event triggered after draw calls have been sent
  92008. */
  92009. onAfterDrawPhaseObservable: Observable<Scene>;
  92010. /**
  92011. * An event triggered when the scene is ready
  92012. */
  92013. onReadyObservable: Observable<Scene>;
  92014. /**
  92015. * An event triggered before rendering a camera
  92016. */
  92017. onBeforeCameraRenderObservable: Observable<Camera>;
  92018. private _onBeforeCameraRenderObserver;
  92019. /** Sets a function to be executed before rendering a camera*/
  92020. beforeCameraRender: () => void;
  92021. /**
  92022. * An event triggered after rendering a camera
  92023. */
  92024. onAfterCameraRenderObservable: Observable<Camera>;
  92025. private _onAfterCameraRenderObserver;
  92026. /** Sets a function to be executed after rendering a camera*/
  92027. afterCameraRender: () => void;
  92028. /**
  92029. * An event triggered when active meshes evaluation is about to start
  92030. */
  92031. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  92032. /**
  92033. * An event triggered when active meshes evaluation is done
  92034. */
  92035. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  92036. /**
  92037. * An event triggered when particles rendering is about to start
  92038. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92039. */
  92040. onBeforeParticlesRenderingObservable: Observable<Scene>;
  92041. /**
  92042. * An event triggered when particles rendering is done
  92043. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92044. */
  92045. onAfterParticlesRenderingObservable: Observable<Scene>;
  92046. /**
  92047. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  92048. */
  92049. onDataLoadedObservable: Observable<Scene>;
  92050. /**
  92051. * An event triggered when a camera is created
  92052. */
  92053. onNewCameraAddedObservable: Observable<Camera>;
  92054. /**
  92055. * An event triggered when a camera is removed
  92056. */
  92057. onCameraRemovedObservable: Observable<Camera>;
  92058. /**
  92059. * An event triggered when a light is created
  92060. */
  92061. onNewLightAddedObservable: Observable<Light>;
  92062. /**
  92063. * An event triggered when a light is removed
  92064. */
  92065. onLightRemovedObservable: Observable<Light>;
  92066. /**
  92067. * An event triggered when a geometry is created
  92068. */
  92069. onNewGeometryAddedObservable: Observable<Geometry>;
  92070. /**
  92071. * An event triggered when a geometry is removed
  92072. */
  92073. onGeometryRemovedObservable: Observable<Geometry>;
  92074. /**
  92075. * An event triggered when a transform node is created
  92076. */
  92077. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  92078. /**
  92079. * An event triggered when a transform node is removed
  92080. */
  92081. onTransformNodeRemovedObservable: Observable<TransformNode>;
  92082. /**
  92083. * An event triggered when a mesh is created
  92084. */
  92085. onNewMeshAddedObservable: Observable<AbstractMesh>;
  92086. /**
  92087. * An event triggered when a mesh is removed
  92088. */
  92089. onMeshRemovedObservable: Observable<AbstractMesh>;
  92090. /**
  92091. * An event triggered when a skeleton is created
  92092. */
  92093. onNewSkeletonAddedObservable: Observable<Skeleton>;
  92094. /**
  92095. * An event triggered when a skeleton is removed
  92096. */
  92097. onSkeletonRemovedObservable: Observable<Skeleton>;
  92098. /**
  92099. * An event triggered when a material is created
  92100. */
  92101. onNewMaterialAddedObservable: Observable<Material>;
  92102. /**
  92103. * An event triggered when a material is removed
  92104. */
  92105. onMaterialRemovedObservable: Observable<Material>;
  92106. /**
  92107. * An event triggered when a texture is created
  92108. */
  92109. onNewTextureAddedObservable: Observable<BaseTexture>;
  92110. /**
  92111. * An event triggered when a texture is removed
  92112. */
  92113. onTextureRemovedObservable: Observable<BaseTexture>;
  92114. /**
  92115. * An event triggered when render targets are about to be rendered
  92116. * Can happen multiple times per frame.
  92117. */
  92118. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  92119. /**
  92120. * An event triggered when render targets were rendered.
  92121. * Can happen multiple times per frame.
  92122. */
  92123. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  92124. /**
  92125. * An event triggered before calculating deterministic simulation step
  92126. */
  92127. onBeforeStepObservable: Observable<Scene>;
  92128. /**
  92129. * An event triggered after calculating deterministic simulation step
  92130. */
  92131. onAfterStepObservable: Observable<Scene>;
  92132. /**
  92133. * An event triggered when the activeCamera property is updated
  92134. */
  92135. onActiveCameraChanged: Observable<Scene>;
  92136. /**
  92137. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  92138. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92139. * 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)
  92140. */
  92141. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92142. /**
  92143. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  92144. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92145. * 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)
  92146. */
  92147. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92148. /**
  92149. * This Observable will when a mesh has been imported into the scene.
  92150. */
  92151. onMeshImportedObservable: Observable<AbstractMesh>;
  92152. /**
  92153. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  92154. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  92155. */
  92156. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  92157. /** @hidden */
  92158. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  92159. /**
  92160. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  92161. */
  92162. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  92163. /**
  92164. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  92165. */
  92166. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  92167. /**
  92168. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  92169. */
  92170. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  92171. /** Callback called when a pointer move is detected */
  92172. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92173. /** Callback called when a pointer down is detected */
  92174. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92175. /** Callback called when a pointer up is detected */
  92176. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  92177. /** Callback called when a pointer pick is detected */
  92178. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  92179. /**
  92180. * 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).
  92181. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  92182. */
  92183. onPrePointerObservable: Observable<PointerInfoPre>;
  92184. /**
  92185. * Observable event triggered each time an input event is received from the rendering canvas
  92186. */
  92187. onPointerObservable: Observable<PointerInfo>;
  92188. /**
  92189. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  92190. */
  92191. readonly unTranslatedPointer: Vector2;
  92192. /**
  92193. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  92194. */
  92195. static DragMovementThreshold: number;
  92196. /**
  92197. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  92198. */
  92199. static LongPressDelay: number;
  92200. /**
  92201. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  92202. */
  92203. static DoubleClickDelay: number;
  92204. /** If you need to check double click without raising a single click at first click, enable this flag */
  92205. static ExclusiveDoubleClickMode: boolean;
  92206. /** @hidden */
  92207. _mirroredCameraPosition: Nullable<Vector3>;
  92208. /**
  92209. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  92210. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  92211. */
  92212. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  92213. /**
  92214. * Observable event triggered each time an keyboard event is received from the hosting window
  92215. */
  92216. onKeyboardObservable: Observable<KeyboardInfo>;
  92217. private _useRightHandedSystem;
  92218. /**
  92219. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  92220. */
  92221. useRightHandedSystem: boolean;
  92222. private _timeAccumulator;
  92223. private _currentStepId;
  92224. private _currentInternalStep;
  92225. /**
  92226. * Sets the step Id used by deterministic lock step
  92227. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92228. * @param newStepId defines the step Id
  92229. */
  92230. setStepId(newStepId: number): void;
  92231. /**
  92232. * Gets the step Id used by deterministic lock step
  92233. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92234. * @returns the step Id
  92235. */
  92236. getStepId(): number;
  92237. /**
  92238. * Gets the internal step used by deterministic lock step
  92239. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92240. * @returns the internal step
  92241. */
  92242. getInternalStep(): number;
  92243. private _fogEnabled;
  92244. /**
  92245. * Gets or sets a boolean indicating if fog is enabled on this scene
  92246. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92247. * (Default is true)
  92248. */
  92249. fogEnabled: boolean;
  92250. private _fogMode;
  92251. /**
  92252. * Gets or sets the fog mode to use
  92253. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92254. * | mode | value |
  92255. * | --- | --- |
  92256. * | FOGMODE_NONE | 0 |
  92257. * | FOGMODE_EXP | 1 |
  92258. * | FOGMODE_EXP2 | 2 |
  92259. * | FOGMODE_LINEAR | 3 |
  92260. */
  92261. fogMode: number;
  92262. /**
  92263. * Gets or sets the fog color to use
  92264. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92265. * (Default is Color3(0.2, 0.2, 0.3))
  92266. */
  92267. fogColor: Color3;
  92268. /**
  92269. * Gets or sets the fog density to use
  92270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92271. * (Default is 0.1)
  92272. */
  92273. fogDensity: number;
  92274. /**
  92275. * Gets or sets the fog start distance to use
  92276. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92277. * (Default is 0)
  92278. */
  92279. fogStart: number;
  92280. /**
  92281. * Gets or sets the fog end distance to use
  92282. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92283. * (Default is 1000)
  92284. */
  92285. fogEnd: number;
  92286. private _shadowsEnabled;
  92287. /**
  92288. * Gets or sets a boolean indicating if shadows are enabled on this scene
  92289. */
  92290. shadowsEnabled: boolean;
  92291. private _lightsEnabled;
  92292. /**
  92293. * Gets or sets a boolean indicating if lights are enabled on this scene
  92294. */
  92295. lightsEnabled: boolean;
  92296. /** All of the active cameras added to this scene. */
  92297. activeCameras: Camera[];
  92298. /** @hidden */
  92299. _activeCamera: Nullable<Camera>;
  92300. /** Gets or sets the current active camera */
  92301. activeCamera: Nullable<Camera>;
  92302. private _defaultMaterial;
  92303. /** The default material used on meshes when no material is affected */
  92304. /** The default material used on meshes when no material is affected */
  92305. defaultMaterial: Material;
  92306. private _texturesEnabled;
  92307. /**
  92308. * Gets or sets a boolean indicating if textures are enabled on this scene
  92309. */
  92310. texturesEnabled: boolean;
  92311. /**
  92312. * Gets or sets a boolean indicating if particles are enabled on this scene
  92313. */
  92314. particlesEnabled: boolean;
  92315. /**
  92316. * Gets or sets a boolean indicating if sprites are enabled on this scene
  92317. */
  92318. spritesEnabled: boolean;
  92319. private _skeletonsEnabled;
  92320. /**
  92321. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  92322. */
  92323. skeletonsEnabled: boolean;
  92324. /**
  92325. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  92326. */
  92327. lensFlaresEnabled: boolean;
  92328. /**
  92329. * Gets or sets a boolean indicating if collisions are enabled on this scene
  92330. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92331. */
  92332. collisionsEnabled: boolean;
  92333. private _collisionCoordinator;
  92334. /** @hidden */
  92335. readonly collisionCoordinator: ICollisionCoordinator;
  92336. /**
  92337. * Defines the gravity applied to this scene (used only for collisions)
  92338. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92339. */
  92340. gravity: Vector3;
  92341. /**
  92342. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  92343. */
  92344. postProcessesEnabled: boolean;
  92345. /**
  92346. * The list of postprocesses added to the scene
  92347. */
  92348. postProcesses: PostProcess[];
  92349. /**
  92350. * Gets the current postprocess manager
  92351. */
  92352. postProcessManager: PostProcessManager;
  92353. /**
  92354. * Gets or sets a boolean indicating if render targets are enabled on this scene
  92355. */
  92356. renderTargetsEnabled: boolean;
  92357. /**
  92358. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  92359. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  92360. */
  92361. dumpNextRenderTargets: boolean;
  92362. /**
  92363. * The list of user defined render targets added to the scene
  92364. */
  92365. customRenderTargets: RenderTargetTexture[];
  92366. /**
  92367. * Defines if texture loading must be delayed
  92368. * If true, textures will only be loaded when they need to be rendered
  92369. */
  92370. useDelayedTextureLoading: boolean;
  92371. /**
  92372. * Gets the list of meshes imported to the scene through SceneLoader
  92373. */
  92374. importedMeshesFiles: String[];
  92375. /**
  92376. * Gets or sets a boolean indicating if probes are enabled on this scene
  92377. */
  92378. probesEnabled: boolean;
  92379. /**
  92380. * Gets or sets the current offline provider to use to store scene data
  92381. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  92382. */
  92383. offlineProvider: IOfflineProvider;
  92384. /**
  92385. * Gets or sets the action manager associated with the scene
  92386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92387. */
  92388. actionManager: AbstractActionManager;
  92389. private _meshesForIntersections;
  92390. /**
  92391. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  92392. */
  92393. proceduralTexturesEnabled: boolean;
  92394. private _engine;
  92395. private _totalVertices;
  92396. /** @hidden */
  92397. _activeIndices: PerfCounter;
  92398. /** @hidden */
  92399. _activeParticles: PerfCounter;
  92400. /** @hidden */
  92401. _activeBones: PerfCounter;
  92402. private _animationRatio;
  92403. /** @hidden */
  92404. _animationTimeLast: number;
  92405. /** @hidden */
  92406. _animationTime: number;
  92407. /**
  92408. * Gets or sets a general scale for animation speed
  92409. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  92410. */
  92411. animationTimeScale: number;
  92412. /** @hidden */
  92413. _cachedMaterial: Nullable<Material>;
  92414. /** @hidden */
  92415. _cachedEffect: Nullable<Effect>;
  92416. /** @hidden */
  92417. _cachedVisibility: Nullable<number>;
  92418. private _renderId;
  92419. private _frameId;
  92420. private _executeWhenReadyTimeoutId;
  92421. private _intermediateRendering;
  92422. private _viewUpdateFlag;
  92423. private _projectionUpdateFlag;
  92424. /** @hidden */
  92425. _toBeDisposed: Nullable<IDisposable>[];
  92426. private _activeRequests;
  92427. /** @hidden */
  92428. _pendingData: any[];
  92429. private _isDisposed;
  92430. /**
  92431. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  92432. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  92433. */
  92434. dispatchAllSubMeshesOfActiveMeshes: boolean;
  92435. private _activeMeshes;
  92436. private _processedMaterials;
  92437. private _renderTargets;
  92438. /** @hidden */
  92439. _activeParticleSystems: SmartArray<IParticleSystem>;
  92440. private _activeSkeletons;
  92441. private _softwareSkinnedMeshes;
  92442. private _renderingManager;
  92443. /** @hidden */
  92444. _activeAnimatables: Animatable[];
  92445. private _transformMatrix;
  92446. private _sceneUbo;
  92447. /** @hidden */
  92448. _viewMatrix: Matrix;
  92449. private _projectionMatrix;
  92450. /** @hidden */
  92451. _forcedViewPosition: Nullable<Vector3>;
  92452. /** @hidden */
  92453. _frustumPlanes: Plane[];
  92454. /**
  92455. * Gets the list of frustum planes (built from the active camera)
  92456. */
  92457. readonly frustumPlanes: Plane[];
  92458. /**
  92459. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  92460. * This is useful if there are more lights that the maximum simulteanous authorized
  92461. */
  92462. requireLightSorting: boolean;
  92463. /** @hidden */
  92464. readonly useMaterialMeshMap: boolean;
  92465. /** @hidden */
  92466. readonly useClonedMeshhMap: boolean;
  92467. private _externalData;
  92468. private _uid;
  92469. /**
  92470. * @hidden
  92471. * Backing store of defined scene components.
  92472. */
  92473. _components: ISceneComponent[];
  92474. /**
  92475. * @hidden
  92476. * Backing store of defined scene components.
  92477. */
  92478. _serializableComponents: ISceneSerializableComponent[];
  92479. /**
  92480. * List of components to register on the next registration step.
  92481. */
  92482. private _transientComponents;
  92483. /**
  92484. * Registers the transient components if needed.
  92485. */
  92486. private _registerTransientComponents;
  92487. /**
  92488. * @hidden
  92489. * Add a component to the scene.
  92490. * Note that the ccomponent could be registered on th next frame if this is called after
  92491. * the register component stage.
  92492. * @param component Defines the component to add to the scene
  92493. */
  92494. _addComponent(component: ISceneComponent): void;
  92495. /**
  92496. * @hidden
  92497. * Gets a component from the scene.
  92498. * @param name defines the name of the component to retrieve
  92499. * @returns the component or null if not present
  92500. */
  92501. _getComponent(name: string): Nullable<ISceneComponent>;
  92502. /**
  92503. * @hidden
  92504. * Defines the actions happening before camera updates.
  92505. */
  92506. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92507. /**
  92508. * @hidden
  92509. * Defines the actions happening before clear the canvas.
  92510. */
  92511. _beforeClearStage: Stage<SimpleStageAction>;
  92512. /**
  92513. * @hidden
  92514. * Defines the actions when collecting render targets for the frame.
  92515. */
  92516. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92517. /**
  92518. * @hidden
  92519. * Defines the actions happening for one camera in the frame.
  92520. */
  92521. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92522. /**
  92523. * @hidden
  92524. * Defines the actions happening during the per mesh ready checks.
  92525. */
  92526. _isReadyForMeshStage: Stage<MeshStageAction>;
  92527. /**
  92528. * @hidden
  92529. * Defines the actions happening before evaluate active mesh checks.
  92530. */
  92531. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92532. /**
  92533. * @hidden
  92534. * Defines the actions happening during the evaluate sub mesh checks.
  92535. */
  92536. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92537. /**
  92538. * @hidden
  92539. * Defines the actions happening during the active mesh stage.
  92540. */
  92541. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92542. /**
  92543. * @hidden
  92544. * Defines the actions happening during the per camera render target step.
  92545. */
  92546. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92547. /**
  92548. * @hidden
  92549. * Defines the actions happening just before the active camera is drawing.
  92550. */
  92551. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92552. /**
  92553. * @hidden
  92554. * Defines the actions happening just before a render target is drawing.
  92555. */
  92556. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92557. /**
  92558. * @hidden
  92559. * Defines the actions happening just before a rendering group is drawing.
  92560. */
  92561. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92562. /**
  92563. * @hidden
  92564. * Defines the actions happening just before a mesh is drawing.
  92565. */
  92566. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92567. /**
  92568. * @hidden
  92569. * Defines the actions happening just after a mesh has been drawn.
  92570. */
  92571. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92572. /**
  92573. * @hidden
  92574. * Defines the actions happening just after a rendering group has been drawn.
  92575. */
  92576. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92577. /**
  92578. * @hidden
  92579. * Defines the actions happening just after the active camera has been drawn.
  92580. */
  92581. _afterCameraDrawStage: Stage<CameraStageAction>;
  92582. /**
  92583. * @hidden
  92584. * Defines the actions happening just after a render target has been drawn.
  92585. */
  92586. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92587. /**
  92588. * @hidden
  92589. * Defines the actions happening just after rendering all cameras and computing intersections.
  92590. */
  92591. _afterRenderStage: Stage<SimpleStageAction>;
  92592. /**
  92593. * @hidden
  92594. * Defines the actions happening when a pointer move event happens.
  92595. */
  92596. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92597. /**
  92598. * @hidden
  92599. * Defines the actions happening when a pointer down event happens.
  92600. */
  92601. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92602. /**
  92603. * @hidden
  92604. * Defines the actions happening when a pointer up event happens.
  92605. */
  92606. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92607. /**
  92608. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92609. */
  92610. private geometriesByUniqueId;
  92611. /**
  92612. * Creates a new Scene
  92613. * @param engine defines the engine to use to render this scene
  92614. * @param options defines the scene options
  92615. */
  92616. constructor(engine: Engine, options?: SceneOptions);
  92617. /**
  92618. * Gets a string idenfifying the name of the class
  92619. * @returns "Scene" string
  92620. */
  92621. getClassName(): string;
  92622. private _defaultMeshCandidates;
  92623. /**
  92624. * @hidden
  92625. */
  92626. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92627. private _defaultSubMeshCandidates;
  92628. /**
  92629. * @hidden
  92630. */
  92631. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92632. /**
  92633. * Sets the default candidate providers for the scene.
  92634. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92635. * and getCollidingSubMeshCandidates to their default function
  92636. */
  92637. setDefaultCandidateProviders(): void;
  92638. /**
  92639. * Gets the mesh that is currently under the pointer
  92640. */
  92641. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92642. /**
  92643. * Gets or sets the current on-screen X position of the pointer
  92644. */
  92645. pointerX: number;
  92646. /**
  92647. * Gets or sets the current on-screen Y position of the pointer
  92648. */
  92649. pointerY: number;
  92650. /**
  92651. * Gets the cached material (ie. the latest rendered one)
  92652. * @returns the cached material
  92653. */
  92654. getCachedMaterial(): Nullable<Material>;
  92655. /**
  92656. * Gets the cached effect (ie. the latest rendered one)
  92657. * @returns the cached effect
  92658. */
  92659. getCachedEffect(): Nullable<Effect>;
  92660. /**
  92661. * Gets the cached visibility state (ie. the latest rendered one)
  92662. * @returns the cached visibility state
  92663. */
  92664. getCachedVisibility(): Nullable<number>;
  92665. /**
  92666. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92667. * @param material defines the current material
  92668. * @param effect defines the current effect
  92669. * @param visibility defines the current visibility state
  92670. * @returns true if one parameter is not cached
  92671. */
  92672. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92673. /**
  92674. * Gets the engine associated with the scene
  92675. * @returns an Engine
  92676. */
  92677. getEngine(): Engine;
  92678. /**
  92679. * Gets the total number of vertices rendered per frame
  92680. * @returns the total number of vertices rendered per frame
  92681. */
  92682. getTotalVertices(): number;
  92683. /**
  92684. * Gets the performance counter for total vertices
  92685. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92686. */
  92687. readonly totalVerticesPerfCounter: PerfCounter;
  92688. /**
  92689. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92690. * @returns the total number of active indices rendered per frame
  92691. */
  92692. getActiveIndices(): number;
  92693. /**
  92694. * Gets the performance counter for active indices
  92695. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92696. */
  92697. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92698. /**
  92699. * Gets the total number of active particles rendered per frame
  92700. * @returns the total number of active particles rendered per frame
  92701. */
  92702. getActiveParticles(): number;
  92703. /**
  92704. * Gets the performance counter for active particles
  92705. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92706. */
  92707. readonly activeParticlesPerfCounter: PerfCounter;
  92708. /**
  92709. * Gets the total number of active bones rendered per frame
  92710. * @returns the total number of active bones rendered per frame
  92711. */
  92712. getActiveBones(): number;
  92713. /**
  92714. * Gets the performance counter for active bones
  92715. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92716. */
  92717. readonly activeBonesPerfCounter: PerfCounter;
  92718. /**
  92719. * Gets the array of active meshes
  92720. * @returns an array of AbstractMesh
  92721. */
  92722. getActiveMeshes(): SmartArray<AbstractMesh>;
  92723. /**
  92724. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92725. * @returns a number
  92726. */
  92727. getAnimationRatio(): number;
  92728. /**
  92729. * Gets an unique Id for the current render phase
  92730. * @returns a number
  92731. */
  92732. getRenderId(): number;
  92733. /**
  92734. * Gets an unique Id for the current frame
  92735. * @returns a number
  92736. */
  92737. getFrameId(): number;
  92738. /** Call this function if you want to manually increment the render Id*/
  92739. incrementRenderId(): void;
  92740. private _createUbo;
  92741. /**
  92742. * Use this method to simulate a pointer move on a mesh
  92743. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92744. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92745. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92746. * @returns the current scene
  92747. */
  92748. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92749. /**
  92750. * Use this method to simulate a pointer down on a mesh
  92751. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92752. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92753. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92754. * @returns the current scene
  92755. */
  92756. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92757. /**
  92758. * Use this method to simulate a pointer up on a mesh
  92759. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92760. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92761. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92762. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92763. * @returns the current scene
  92764. */
  92765. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92766. /**
  92767. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92768. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92769. * @returns true if the pointer was captured
  92770. */
  92771. isPointerCaptured(pointerId?: number): boolean;
  92772. /**
  92773. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92774. * @param attachUp defines if you want to attach events to pointerup
  92775. * @param attachDown defines if you want to attach events to pointerdown
  92776. * @param attachMove defines if you want to attach events to pointermove
  92777. */
  92778. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92779. /** Detaches all event handlers*/
  92780. detachControl(): void;
  92781. /**
  92782. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92783. * Delay loaded resources are not taking in account
  92784. * @return true if all required resources are ready
  92785. */
  92786. isReady(): boolean;
  92787. /** Resets all cached information relative to material (including effect and visibility) */
  92788. resetCachedMaterial(): void;
  92789. /**
  92790. * Registers a function to be called before every frame render
  92791. * @param func defines the function to register
  92792. */
  92793. registerBeforeRender(func: () => void): void;
  92794. /**
  92795. * Unregisters a function called before every frame render
  92796. * @param func defines the function to unregister
  92797. */
  92798. unregisterBeforeRender(func: () => void): void;
  92799. /**
  92800. * Registers a function to be called after every frame render
  92801. * @param func defines the function to register
  92802. */
  92803. registerAfterRender(func: () => void): void;
  92804. /**
  92805. * Unregisters a function called after every frame render
  92806. * @param func defines the function to unregister
  92807. */
  92808. unregisterAfterRender(func: () => void): void;
  92809. private _executeOnceBeforeRender;
  92810. /**
  92811. * The provided function will run before render once and will be disposed afterwards.
  92812. * A timeout delay can be provided so that the function will be executed in N ms.
  92813. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92814. * @param func The function to be executed.
  92815. * @param timeout optional delay in ms
  92816. */
  92817. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92818. /** @hidden */
  92819. _addPendingData(data: any): void;
  92820. /** @hidden */
  92821. _removePendingData(data: any): void;
  92822. /**
  92823. * Returns the number of items waiting to be loaded
  92824. * @returns the number of items waiting to be loaded
  92825. */
  92826. getWaitingItemsCount(): number;
  92827. /**
  92828. * Returns a boolean indicating if the scene is still loading data
  92829. */
  92830. readonly isLoading: boolean;
  92831. /**
  92832. * Registers a function to be executed when the scene is ready
  92833. * @param {Function} func - the function to be executed
  92834. */
  92835. executeWhenReady(func: () => void): void;
  92836. /**
  92837. * Returns a promise that resolves when the scene is ready
  92838. * @returns A promise that resolves when the scene is ready
  92839. */
  92840. whenReadyAsync(): Promise<void>;
  92841. /** @hidden */
  92842. _checkIsReady(): void;
  92843. /**
  92844. * Gets all animatable attached to the scene
  92845. */
  92846. readonly animatables: Animatable[];
  92847. /**
  92848. * Resets the last animation time frame.
  92849. * Useful to override when animations start running when loading a scene for the first time.
  92850. */
  92851. resetLastAnimationTimeFrame(): void;
  92852. /**
  92853. * Gets the current view matrix
  92854. * @returns a Matrix
  92855. */
  92856. getViewMatrix(): Matrix;
  92857. /**
  92858. * Gets the current projection matrix
  92859. * @returns a Matrix
  92860. */
  92861. getProjectionMatrix(): Matrix;
  92862. /**
  92863. * Gets the current transform matrix
  92864. * @returns a Matrix made of View * Projection
  92865. */
  92866. getTransformMatrix(): Matrix;
  92867. /**
  92868. * Sets the current transform matrix
  92869. * @param viewL defines the View matrix to use
  92870. * @param projectionL defines the Projection matrix to use
  92871. * @param viewR defines the right View matrix to use (if provided)
  92872. * @param projectionR defines the right Projection matrix to use (if provided)
  92873. */
  92874. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92875. /**
  92876. * Gets the uniform buffer used to store scene data
  92877. * @returns a UniformBuffer
  92878. */
  92879. getSceneUniformBuffer(): UniformBuffer;
  92880. /**
  92881. * Gets an unique (relatively to the current scene) Id
  92882. * @returns an unique number for the scene
  92883. */
  92884. getUniqueId(): number;
  92885. /**
  92886. * Add a mesh to the list of scene's meshes
  92887. * @param newMesh defines the mesh to add
  92888. * @param recursive if all child meshes should also be added to the scene
  92889. */
  92890. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92891. /**
  92892. * Remove a mesh for the list of scene's meshes
  92893. * @param toRemove defines the mesh to remove
  92894. * @param recursive if all child meshes should also be removed from the scene
  92895. * @returns the index where the mesh was in the mesh list
  92896. */
  92897. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92898. /**
  92899. * Add a transform node to the list of scene's transform nodes
  92900. * @param newTransformNode defines the transform node to add
  92901. */
  92902. addTransformNode(newTransformNode: TransformNode): void;
  92903. /**
  92904. * Remove a transform node for the list of scene's transform nodes
  92905. * @param toRemove defines the transform node to remove
  92906. * @returns the index where the transform node was in the transform node list
  92907. */
  92908. removeTransformNode(toRemove: TransformNode): number;
  92909. /**
  92910. * Remove a skeleton for the list of scene's skeletons
  92911. * @param toRemove defines the skeleton to remove
  92912. * @returns the index where the skeleton was in the skeleton list
  92913. */
  92914. removeSkeleton(toRemove: Skeleton): number;
  92915. /**
  92916. * Remove a morph target for the list of scene's morph targets
  92917. * @param toRemove defines the morph target to remove
  92918. * @returns the index where the morph target was in the morph target list
  92919. */
  92920. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92921. /**
  92922. * Remove a light for the list of scene's lights
  92923. * @param toRemove defines the light to remove
  92924. * @returns the index where the light was in the light list
  92925. */
  92926. removeLight(toRemove: Light): number;
  92927. /**
  92928. * Remove a camera for the list of scene's cameras
  92929. * @param toRemove defines the camera to remove
  92930. * @returns the index where the camera was in the camera list
  92931. */
  92932. removeCamera(toRemove: Camera): number;
  92933. /**
  92934. * Remove a particle system for the list of scene's particle systems
  92935. * @param toRemove defines the particle system to remove
  92936. * @returns the index where the particle system was in the particle system list
  92937. */
  92938. removeParticleSystem(toRemove: IParticleSystem): number;
  92939. /**
  92940. * Remove a animation for the list of scene's animations
  92941. * @param toRemove defines the animation to remove
  92942. * @returns the index where the animation was in the animation list
  92943. */
  92944. removeAnimation(toRemove: Animation): number;
  92945. /**
  92946. * Will stop the animation of the given target
  92947. * @param target - the target
  92948. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  92949. * @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)
  92950. */
  92951. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  92952. /**
  92953. * Removes the given animation group from this scene.
  92954. * @param toRemove The animation group to remove
  92955. * @returns The index of the removed animation group
  92956. */
  92957. removeAnimationGroup(toRemove: AnimationGroup): number;
  92958. /**
  92959. * Removes the given multi-material from this scene.
  92960. * @param toRemove The multi-material to remove
  92961. * @returns The index of the removed multi-material
  92962. */
  92963. removeMultiMaterial(toRemove: MultiMaterial): number;
  92964. /**
  92965. * Removes the given material from this scene.
  92966. * @param toRemove The material to remove
  92967. * @returns The index of the removed material
  92968. */
  92969. removeMaterial(toRemove: Material): number;
  92970. /**
  92971. * Removes the given action manager from this scene.
  92972. * @param toRemove The action manager to remove
  92973. * @returns The index of the removed action manager
  92974. */
  92975. removeActionManager(toRemove: AbstractActionManager): number;
  92976. /**
  92977. * Removes the given texture from this scene.
  92978. * @param toRemove The texture to remove
  92979. * @returns The index of the removed texture
  92980. */
  92981. removeTexture(toRemove: BaseTexture): number;
  92982. /**
  92983. * Adds the given light to this scene
  92984. * @param newLight The light to add
  92985. */
  92986. addLight(newLight: Light): void;
  92987. /**
  92988. * Sorts the list list based on light priorities
  92989. */
  92990. sortLightsByPriority(): void;
  92991. /**
  92992. * Adds the given camera to this scene
  92993. * @param newCamera The camera to add
  92994. */
  92995. addCamera(newCamera: Camera): void;
  92996. /**
  92997. * Adds the given skeleton to this scene
  92998. * @param newSkeleton The skeleton to add
  92999. */
  93000. addSkeleton(newSkeleton: Skeleton): void;
  93001. /**
  93002. * Adds the given particle system to this scene
  93003. * @param newParticleSystem The particle system to add
  93004. */
  93005. addParticleSystem(newParticleSystem: IParticleSystem): void;
  93006. /**
  93007. * Adds the given animation to this scene
  93008. * @param newAnimation The animation to add
  93009. */
  93010. addAnimation(newAnimation: Animation): void;
  93011. /**
  93012. * Adds the given animation group to this scene.
  93013. * @param newAnimationGroup The animation group to add
  93014. */
  93015. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  93016. /**
  93017. * Adds the given multi-material to this scene
  93018. * @param newMultiMaterial The multi-material to add
  93019. */
  93020. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  93021. /**
  93022. * Adds the given material to this scene
  93023. * @param newMaterial The material to add
  93024. */
  93025. addMaterial(newMaterial: Material): void;
  93026. /**
  93027. * Adds the given morph target to this scene
  93028. * @param newMorphTargetManager The morph target to add
  93029. */
  93030. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  93031. /**
  93032. * Adds the given geometry to this scene
  93033. * @param newGeometry The geometry to add
  93034. */
  93035. addGeometry(newGeometry: Geometry): void;
  93036. /**
  93037. * Adds the given action manager to this scene
  93038. * @param newActionManager The action manager to add
  93039. */
  93040. addActionManager(newActionManager: AbstractActionManager): void;
  93041. /**
  93042. * Adds the given texture to this scene.
  93043. * @param newTexture The texture to add
  93044. */
  93045. addTexture(newTexture: BaseTexture): void;
  93046. /**
  93047. * Switch active camera
  93048. * @param newCamera defines the new active camera
  93049. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  93050. */
  93051. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  93052. /**
  93053. * sets the active camera of the scene using its ID
  93054. * @param id defines the camera's ID
  93055. * @return the new active camera or null if none found.
  93056. */
  93057. setActiveCameraByID(id: string): Nullable<Camera>;
  93058. /**
  93059. * sets the active camera of the scene using its name
  93060. * @param name defines the camera's name
  93061. * @returns the new active camera or null if none found.
  93062. */
  93063. setActiveCameraByName(name: string): Nullable<Camera>;
  93064. /**
  93065. * get an animation group using its name
  93066. * @param name defines the material's name
  93067. * @return the animation group or null if none found.
  93068. */
  93069. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  93070. /**
  93071. * Get a material using its unique id
  93072. * @param uniqueId defines the material's unique id
  93073. * @return the material or null if none found.
  93074. */
  93075. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  93076. /**
  93077. * get a material using its id
  93078. * @param id defines the material's ID
  93079. * @return the material or null if none found.
  93080. */
  93081. getMaterialByID(id: string): Nullable<Material>;
  93082. /**
  93083. * Gets a material using its name
  93084. * @param name defines the material's name
  93085. * @return the material or null if none found.
  93086. */
  93087. getMaterialByName(name: string): Nullable<Material>;
  93088. /**
  93089. * Gets a camera using its id
  93090. * @param id defines the id to look for
  93091. * @returns the camera or null if not found
  93092. */
  93093. getCameraByID(id: string): Nullable<Camera>;
  93094. /**
  93095. * Gets a camera using its unique id
  93096. * @param uniqueId defines the unique id to look for
  93097. * @returns the camera or null if not found
  93098. */
  93099. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  93100. /**
  93101. * Gets a camera using its name
  93102. * @param name defines the camera's name
  93103. * @return the camera or null if none found.
  93104. */
  93105. getCameraByName(name: string): Nullable<Camera>;
  93106. /**
  93107. * Gets a bone using its id
  93108. * @param id defines the bone's id
  93109. * @return the bone or null if not found
  93110. */
  93111. getBoneByID(id: string): Nullable<Bone>;
  93112. /**
  93113. * Gets a bone using its id
  93114. * @param name defines the bone's name
  93115. * @return the bone or null if not found
  93116. */
  93117. getBoneByName(name: string): Nullable<Bone>;
  93118. /**
  93119. * Gets a light node using its name
  93120. * @param name defines the the light's name
  93121. * @return the light or null if none found.
  93122. */
  93123. getLightByName(name: string): Nullable<Light>;
  93124. /**
  93125. * Gets a light node using its id
  93126. * @param id defines the light's id
  93127. * @return the light or null if none found.
  93128. */
  93129. getLightByID(id: string): Nullable<Light>;
  93130. /**
  93131. * Gets a light node using its scene-generated unique ID
  93132. * @param uniqueId defines the light's unique id
  93133. * @return the light or null if none found.
  93134. */
  93135. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  93136. /**
  93137. * Gets a particle system by id
  93138. * @param id defines the particle system id
  93139. * @return the corresponding system or null if none found
  93140. */
  93141. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  93142. /**
  93143. * Gets a geometry using its ID
  93144. * @param id defines the geometry's id
  93145. * @return the geometry or null if none found.
  93146. */
  93147. getGeometryByID(id: string): Nullable<Geometry>;
  93148. private _getGeometryByUniqueID;
  93149. /**
  93150. * Add a new geometry to this scene
  93151. * @param geometry defines the geometry to be added to the scene.
  93152. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  93153. * @return a boolean defining if the geometry was added or not
  93154. */
  93155. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  93156. /**
  93157. * Removes an existing geometry
  93158. * @param geometry defines the geometry to be removed from the scene
  93159. * @return a boolean defining if the geometry was removed or not
  93160. */
  93161. removeGeometry(geometry: Geometry): boolean;
  93162. /**
  93163. * Gets the list of geometries attached to the scene
  93164. * @returns an array of Geometry
  93165. */
  93166. getGeometries(): Geometry[];
  93167. /**
  93168. * Gets the first added mesh found of a given ID
  93169. * @param id defines the id to search for
  93170. * @return the mesh found or null if not found at all
  93171. */
  93172. getMeshByID(id: string): Nullable<AbstractMesh>;
  93173. /**
  93174. * Gets a list of meshes using their id
  93175. * @param id defines the id to search for
  93176. * @returns a list of meshes
  93177. */
  93178. getMeshesByID(id: string): Array<AbstractMesh>;
  93179. /**
  93180. * Gets the first added transform node found of a given ID
  93181. * @param id defines the id to search for
  93182. * @return the found transform node or null if not found at all.
  93183. */
  93184. getTransformNodeByID(id: string): Nullable<TransformNode>;
  93185. /**
  93186. * Gets a transform node with its auto-generated unique id
  93187. * @param uniqueId efines the unique id to search for
  93188. * @return the found transform node or null if not found at all.
  93189. */
  93190. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  93191. /**
  93192. * Gets a list of transform nodes using their id
  93193. * @param id defines the id to search for
  93194. * @returns a list of transform nodes
  93195. */
  93196. getTransformNodesByID(id: string): Array<TransformNode>;
  93197. /**
  93198. * Gets a mesh with its auto-generated unique id
  93199. * @param uniqueId defines the unique id to search for
  93200. * @return the found mesh or null if not found at all.
  93201. */
  93202. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  93203. /**
  93204. * Gets a the last added mesh using a given id
  93205. * @param id defines the id to search for
  93206. * @return the found mesh or null if not found at all.
  93207. */
  93208. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  93209. /**
  93210. * Gets a the last added node (Mesh, Camera, Light) using a given id
  93211. * @param id defines the id to search for
  93212. * @return the found node or null if not found at all
  93213. */
  93214. getLastEntryByID(id: string): Nullable<Node>;
  93215. /**
  93216. * Gets a node (Mesh, Camera, Light) using a given id
  93217. * @param id defines the id to search for
  93218. * @return the found node or null if not found at all
  93219. */
  93220. getNodeByID(id: string): Nullable<Node>;
  93221. /**
  93222. * Gets a node (Mesh, Camera, Light) using a given name
  93223. * @param name defines the name to search for
  93224. * @return the found node or null if not found at all.
  93225. */
  93226. getNodeByName(name: string): Nullable<Node>;
  93227. /**
  93228. * Gets a mesh using a given name
  93229. * @param name defines the name to search for
  93230. * @return the found mesh or null if not found at all.
  93231. */
  93232. getMeshByName(name: string): Nullable<AbstractMesh>;
  93233. /**
  93234. * Gets a transform node using a given name
  93235. * @param name defines the name to search for
  93236. * @return the found transform node or null if not found at all.
  93237. */
  93238. getTransformNodeByName(name: string): Nullable<TransformNode>;
  93239. /**
  93240. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  93241. * @param id defines the id to search for
  93242. * @return the found skeleton or null if not found at all.
  93243. */
  93244. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  93245. /**
  93246. * Gets a skeleton using a given auto generated unique id
  93247. * @param uniqueId defines the unique id to search for
  93248. * @return the found skeleton or null if not found at all.
  93249. */
  93250. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  93251. /**
  93252. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  93253. * @param id defines the id to search for
  93254. * @return the found skeleton or null if not found at all.
  93255. */
  93256. getSkeletonById(id: string): Nullable<Skeleton>;
  93257. /**
  93258. * Gets a skeleton using a given name
  93259. * @param name defines the name to search for
  93260. * @return the found skeleton or null if not found at all.
  93261. */
  93262. getSkeletonByName(name: string): Nullable<Skeleton>;
  93263. /**
  93264. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  93265. * @param id defines the id to search for
  93266. * @return the found morph target manager or null if not found at all.
  93267. */
  93268. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  93269. /**
  93270. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  93271. * @param id defines the id to search for
  93272. * @return the found morph target or null if not found at all.
  93273. */
  93274. getMorphTargetById(id: string): Nullable<MorphTarget>;
  93275. /**
  93276. * Gets a boolean indicating if the given mesh is active
  93277. * @param mesh defines the mesh to look for
  93278. * @returns true if the mesh is in the active list
  93279. */
  93280. isActiveMesh(mesh: AbstractMesh): boolean;
  93281. /**
  93282. * Return a unique id as a string which can serve as an identifier for the scene
  93283. */
  93284. readonly uid: string;
  93285. /**
  93286. * Add an externaly attached data from its key.
  93287. * This method call will fail and return false, if such key already exists.
  93288. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  93289. * @param key the unique key that identifies the data
  93290. * @param data the data object to associate to the key for this Engine instance
  93291. * @return true if no such key were already present and the data was added successfully, false otherwise
  93292. */
  93293. addExternalData<T>(key: string, data: T): boolean;
  93294. /**
  93295. * Get an externaly attached data from its key
  93296. * @param key the unique key that identifies the data
  93297. * @return the associated data, if present (can be null), or undefined if not present
  93298. */
  93299. getExternalData<T>(key: string): Nullable<T>;
  93300. /**
  93301. * Get an externaly attached data from its key, create it using a factory if it's not already present
  93302. * @param key the unique key that identifies the data
  93303. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  93304. * @return the associated data, can be null if the factory returned null.
  93305. */
  93306. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  93307. /**
  93308. * Remove an externaly attached data from the Engine instance
  93309. * @param key the unique key that identifies the data
  93310. * @return true if the data was successfully removed, false if it doesn't exist
  93311. */
  93312. removeExternalData(key: string): boolean;
  93313. private _evaluateSubMesh;
  93314. /**
  93315. * Clear the processed materials smart array preventing retention point in material dispose.
  93316. */
  93317. freeProcessedMaterials(): void;
  93318. private _preventFreeActiveMeshesAndRenderingGroups;
  93319. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  93320. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  93321. * when disposing several meshes in a row or a hierarchy of meshes.
  93322. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  93323. */
  93324. blockfreeActiveMeshesAndRenderingGroups: boolean;
  93325. /**
  93326. * Clear the active meshes smart array preventing retention point in mesh dispose.
  93327. */
  93328. freeActiveMeshes(): void;
  93329. /**
  93330. * Clear the info related to rendering groups preventing retention points during dispose.
  93331. */
  93332. freeRenderingGroups(): void;
  93333. /** @hidden */
  93334. _isInIntermediateRendering(): boolean;
  93335. /**
  93336. * Lambda returning the list of potentially active meshes.
  93337. */
  93338. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  93339. /**
  93340. * Lambda returning the list of potentially active sub meshes.
  93341. */
  93342. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  93343. /**
  93344. * Lambda returning the list of potentially intersecting sub meshes.
  93345. */
  93346. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  93347. /**
  93348. * Lambda returning the list of potentially colliding sub meshes.
  93349. */
  93350. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  93351. private _activeMeshesFrozen;
  93352. /**
  93353. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  93354. * @returns the current scene
  93355. */
  93356. freezeActiveMeshes(): Scene;
  93357. /**
  93358. * Use this function to restart evaluating active meshes on every frame
  93359. * @returns the current scene
  93360. */
  93361. unfreezeActiveMeshes(): Scene;
  93362. private _evaluateActiveMeshes;
  93363. private _activeMesh;
  93364. /**
  93365. * Update the transform matrix to update from the current active camera
  93366. * @param force defines a boolean used to force the update even if cache is up to date
  93367. */
  93368. updateTransformMatrix(force?: boolean): void;
  93369. private _bindFrameBuffer;
  93370. /** @hidden */
  93371. _allowPostProcessClearColor: boolean;
  93372. /** @hidden */
  93373. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  93374. private _processSubCameras;
  93375. private _checkIntersections;
  93376. /** @hidden */
  93377. _advancePhysicsEngineStep(step: number): void;
  93378. /**
  93379. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  93380. */
  93381. getDeterministicFrameTime: () => number;
  93382. /** @hidden */
  93383. _animate(): void;
  93384. /** Execute all animations (for a frame) */
  93385. animate(): void;
  93386. /**
  93387. * Render the scene
  93388. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  93389. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  93390. */
  93391. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  93392. /**
  93393. * Freeze all materials
  93394. * A frozen material will not be updatable but should be faster to render
  93395. */
  93396. freezeMaterials(): void;
  93397. /**
  93398. * Unfreeze all materials
  93399. * A frozen material will not be updatable but should be faster to render
  93400. */
  93401. unfreezeMaterials(): void;
  93402. /**
  93403. * Releases all held ressources
  93404. */
  93405. dispose(): void;
  93406. /**
  93407. * Gets if the scene is already disposed
  93408. */
  93409. readonly isDisposed: boolean;
  93410. /**
  93411. * Call this function to reduce memory footprint of the scene.
  93412. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  93413. */
  93414. clearCachedVertexData(): void;
  93415. /**
  93416. * This function will remove the local cached buffer data from texture.
  93417. * It will save memory but will prevent the texture from being rebuilt
  93418. */
  93419. cleanCachedTextureBuffer(): void;
  93420. /**
  93421. * Get the world extend vectors with an optional filter
  93422. *
  93423. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  93424. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  93425. */
  93426. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  93427. min: Vector3;
  93428. max: Vector3;
  93429. };
  93430. /**
  93431. * Creates a ray that can be used to pick in the scene
  93432. * @param x defines the x coordinate of the origin (on-screen)
  93433. * @param y defines the y coordinate of the origin (on-screen)
  93434. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93435. * @param camera defines the camera to use for the picking
  93436. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93437. * @returns a Ray
  93438. */
  93439. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  93440. /**
  93441. * Creates a ray that can be used to pick in the scene
  93442. * @param x defines the x coordinate of the origin (on-screen)
  93443. * @param y defines the y coordinate of the origin (on-screen)
  93444. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93445. * @param result defines the ray where to store the picking ray
  93446. * @param camera defines the camera to use for the picking
  93447. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93448. * @returns the current scene
  93449. */
  93450. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  93451. /**
  93452. * Creates a ray that can be used to pick in the scene
  93453. * @param x defines the x coordinate of the origin (on-screen)
  93454. * @param y defines the y coordinate of the origin (on-screen)
  93455. * @param camera defines the camera to use for the picking
  93456. * @returns a Ray
  93457. */
  93458. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  93459. /**
  93460. * Creates a ray that can be used to pick in the scene
  93461. * @param x defines the x coordinate of the origin (on-screen)
  93462. * @param y defines the y coordinate of the origin (on-screen)
  93463. * @param result defines the ray where to store the picking ray
  93464. * @param camera defines the camera to use for the picking
  93465. * @returns the current scene
  93466. */
  93467. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  93468. /** Launch a ray to try to pick a mesh in the scene
  93469. * @param x position on screen
  93470. * @param y position on screen
  93471. * @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
  93472. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  93473. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93474. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93475. * @returns a PickingInfo
  93476. */
  93477. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  93478. /** Use the given ray to pick a mesh in the scene
  93479. * @param ray The ray to use to pick meshes
  93480. * @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
  93481. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  93482. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93483. * @returns a PickingInfo
  93484. */
  93485. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  93486. /**
  93487. * Launch a ray to try to pick a mesh in the scene
  93488. * @param x X position on screen
  93489. * @param y Y position on screen
  93490. * @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
  93491. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93492. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93493. * @returns an array of PickingInfo
  93494. */
  93495. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93496. /**
  93497. * Launch a ray to try to pick a mesh in the scene
  93498. * @param ray Ray to use
  93499. * @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
  93500. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93501. * @returns an array of PickingInfo
  93502. */
  93503. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93504. /**
  93505. * Force the value of meshUnderPointer
  93506. * @param mesh defines the mesh to use
  93507. */
  93508. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93509. /**
  93510. * Gets the mesh under the pointer
  93511. * @returns a Mesh or null if no mesh is under the pointer
  93512. */
  93513. getPointerOverMesh(): Nullable<AbstractMesh>;
  93514. /** @hidden */
  93515. _rebuildGeometries(): void;
  93516. /** @hidden */
  93517. _rebuildTextures(): void;
  93518. private _getByTags;
  93519. /**
  93520. * Get a list of meshes by tags
  93521. * @param tagsQuery defines the tags query to use
  93522. * @param forEach defines a predicate used to filter results
  93523. * @returns an array of Mesh
  93524. */
  93525. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93526. /**
  93527. * Get a list of cameras by tags
  93528. * @param tagsQuery defines the tags query to use
  93529. * @param forEach defines a predicate used to filter results
  93530. * @returns an array of Camera
  93531. */
  93532. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93533. /**
  93534. * Get a list of lights by tags
  93535. * @param tagsQuery defines the tags query to use
  93536. * @param forEach defines a predicate used to filter results
  93537. * @returns an array of Light
  93538. */
  93539. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93540. /**
  93541. * Get a list of materials by tags
  93542. * @param tagsQuery defines the tags query to use
  93543. * @param forEach defines a predicate used to filter results
  93544. * @returns an array of Material
  93545. */
  93546. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93547. /**
  93548. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93549. * This allowed control for front to back rendering or reversly depending of the special needs.
  93550. *
  93551. * @param renderingGroupId The rendering group id corresponding to its index
  93552. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93553. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93554. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93555. */
  93556. 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;
  93557. /**
  93558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93559. *
  93560. * @param renderingGroupId The rendering group id corresponding to its index
  93561. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93562. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93563. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93564. */
  93565. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93566. /**
  93567. * Gets the current auto clear configuration for one rendering group of the rendering
  93568. * manager.
  93569. * @param index the rendering group index to get the information for
  93570. * @returns The auto clear setup for the requested rendering group
  93571. */
  93572. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93573. private _blockMaterialDirtyMechanism;
  93574. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93575. blockMaterialDirtyMechanism: boolean;
  93576. /**
  93577. * Will flag all materials as dirty to trigger new shader compilation
  93578. * @param flag defines the flag used to specify which material part must be marked as dirty
  93579. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93580. */
  93581. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93582. /** @hidden */
  93583. _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;
  93584. /** @hidden */
  93585. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93586. }
  93587. }
  93588. declare module BABYLON {
  93589. /**
  93590. * Set of assets to keep when moving a scene into an asset container.
  93591. */
  93592. export class KeepAssets extends AbstractScene {
  93593. }
  93594. /**
  93595. * Container with a set of assets that can be added or removed from a scene.
  93596. */
  93597. export class AssetContainer extends AbstractScene {
  93598. /**
  93599. * The scene the AssetContainer belongs to.
  93600. */
  93601. scene: Scene;
  93602. /**
  93603. * Instantiates an AssetContainer.
  93604. * @param scene The scene the AssetContainer belongs to.
  93605. */
  93606. constructor(scene: Scene);
  93607. /**
  93608. * Adds all the assets from the container to the scene.
  93609. */
  93610. addAllToScene(): void;
  93611. /**
  93612. * Removes all the assets in the container from the scene
  93613. */
  93614. removeAllFromScene(): void;
  93615. /**
  93616. * Disposes all the assets in the container
  93617. */
  93618. dispose(): void;
  93619. private _moveAssets;
  93620. /**
  93621. * Removes all the assets contained in the scene and adds them to the container.
  93622. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93623. */
  93624. moveAllFromScene(keepAssets?: KeepAssets): void;
  93625. /**
  93626. * 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.
  93627. * @returns the root mesh
  93628. */
  93629. createRootMesh(): Mesh;
  93630. }
  93631. }
  93632. declare module BABYLON {
  93633. /**
  93634. * Defines how the parser contract is defined.
  93635. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93636. */
  93637. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93638. /**
  93639. * Defines how the individual parser contract is defined.
  93640. * These parser can parse an individual asset
  93641. */
  93642. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93643. /**
  93644. * Base class of the scene acting as a container for the different elements composing a scene.
  93645. * This class is dynamically extended by the different components of the scene increasing
  93646. * flexibility and reducing coupling
  93647. */
  93648. export abstract class AbstractScene {
  93649. /**
  93650. * Stores the list of available parsers in the application.
  93651. */
  93652. private static _BabylonFileParsers;
  93653. /**
  93654. * Stores the list of available individual parsers in the application.
  93655. */
  93656. private static _IndividualBabylonFileParsers;
  93657. /**
  93658. * Adds a parser in the list of available ones
  93659. * @param name Defines the name of the parser
  93660. * @param parser Defines the parser to add
  93661. */
  93662. static AddParser(name: string, parser: BabylonFileParser): void;
  93663. /**
  93664. * Gets a general parser from the list of avaialble ones
  93665. * @param name Defines the name of the parser
  93666. * @returns the requested parser or null
  93667. */
  93668. static GetParser(name: string): Nullable<BabylonFileParser>;
  93669. /**
  93670. * Adds n individual parser in the list of available ones
  93671. * @param name Defines the name of the parser
  93672. * @param parser Defines the parser to add
  93673. */
  93674. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93675. /**
  93676. * Gets an individual parser from the list of avaialble ones
  93677. * @param name Defines the name of the parser
  93678. * @returns the requested parser or null
  93679. */
  93680. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93681. /**
  93682. * Parser json data and populate both a scene and its associated container object
  93683. * @param jsonData Defines the data to parse
  93684. * @param scene Defines the scene to parse the data for
  93685. * @param container Defines the container attached to the parsing sequence
  93686. * @param rootUrl Defines the root url of the data
  93687. */
  93688. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93689. /**
  93690. * Gets the list of root nodes (ie. nodes with no parent)
  93691. */
  93692. rootNodes: Node[];
  93693. /** All of the cameras added to this scene
  93694. * @see http://doc.babylonjs.com/babylon101/cameras
  93695. */
  93696. cameras: Camera[];
  93697. /**
  93698. * All of the lights added to this scene
  93699. * @see http://doc.babylonjs.com/babylon101/lights
  93700. */
  93701. lights: Light[];
  93702. /**
  93703. * All of the (abstract) meshes added to this scene
  93704. */
  93705. meshes: AbstractMesh[];
  93706. /**
  93707. * The list of skeletons added to the scene
  93708. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93709. */
  93710. skeletons: Skeleton[];
  93711. /**
  93712. * All of the particle systems added to this scene
  93713. * @see http://doc.babylonjs.com/babylon101/particles
  93714. */
  93715. particleSystems: IParticleSystem[];
  93716. /**
  93717. * Gets a list of Animations associated with the scene
  93718. */
  93719. animations: Animation[];
  93720. /**
  93721. * All of the animation groups added to this scene
  93722. * @see http://doc.babylonjs.com/how_to/group
  93723. */
  93724. animationGroups: AnimationGroup[];
  93725. /**
  93726. * All of the multi-materials added to this scene
  93727. * @see http://doc.babylonjs.com/how_to/multi_materials
  93728. */
  93729. multiMaterials: MultiMaterial[];
  93730. /**
  93731. * All of the materials added to this scene
  93732. * In the context of a Scene, it is not supposed to be modified manually.
  93733. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93734. * Note also that the order of the Material wihin the array is not significant and might change.
  93735. * @see http://doc.babylonjs.com/babylon101/materials
  93736. */
  93737. materials: Material[];
  93738. /**
  93739. * The list of morph target managers added to the scene
  93740. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93741. */
  93742. morphTargetManagers: MorphTargetManager[];
  93743. /**
  93744. * The list of geometries used in the scene.
  93745. */
  93746. geometries: Geometry[];
  93747. /**
  93748. * All of the tranform nodes added to this scene
  93749. * In the context of a Scene, it is not supposed to be modified manually.
  93750. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93751. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93752. * @see http://doc.babylonjs.com/how_to/transformnode
  93753. */
  93754. transformNodes: TransformNode[];
  93755. /**
  93756. * ActionManagers available on the scene.
  93757. */
  93758. actionManagers: AbstractActionManager[];
  93759. /**
  93760. * Textures to keep.
  93761. */
  93762. textures: BaseTexture[];
  93763. /**
  93764. * Environment texture for the scene
  93765. */
  93766. environmentTexture: Nullable<BaseTexture>;
  93767. }
  93768. }
  93769. declare module BABYLON {
  93770. /**
  93771. * Defines a sound that can be played in the application.
  93772. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93774. */
  93775. export class Sound {
  93776. /**
  93777. * The name of the sound in the scene.
  93778. */
  93779. name: string;
  93780. /**
  93781. * Does the sound autoplay once loaded.
  93782. */
  93783. autoplay: boolean;
  93784. /**
  93785. * Does the sound loop after it finishes playing once.
  93786. */
  93787. loop: boolean;
  93788. /**
  93789. * Does the sound use a custom attenuation curve to simulate the falloff
  93790. * happening when the source gets further away from the camera.
  93791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93792. */
  93793. useCustomAttenuation: boolean;
  93794. /**
  93795. * The sound track id this sound belongs to.
  93796. */
  93797. soundTrackId: number;
  93798. /**
  93799. * Is this sound currently played.
  93800. */
  93801. isPlaying: boolean;
  93802. /**
  93803. * Is this sound currently paused.
  93804. */
  93805. isPaused: boolean;
  93806. /**
  93807. * Does this sound enables spatial sound.
  93808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93809. */
  93810. spatialSound: boolean;
  93811. /**
  93812. * Define the reference distance the sound should be heard perfectly.
  93813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93814. */
  93815. refDistance: number;
  93816. /**
  93817. * Define the roll off factor of spatial sounds.
  93818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93819. */
  93820. rolloffFactor: number;
  93821. /**
  93822. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93824. */
  93825. maxDistance: number;
  93826. /**
  93827. * Define the distance attenuation model the sound will follow.
  93828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93829. */
  93830. distanceModel: string;
  93831. /**
  93832. * @hidden
  93833. * Back Compat
  93834. **/
  93835. onended: () => any;
  93836. /**
  93837. * Observable event when the current playing sound finishes.
  93838. */
  93839. onEndedObservable: Observable<Sound>;
  93840. private _panningModel;
  93841. private _playbackRate;
  93842. private _streaming;
  93843. private _startTime;
  93844. private _startOffset;
  93845. private _position;
  93846. /** @hidden */
  93847. _positionInEmitterSpace: boolean;
  93848. private _localDirection;
  93849. private _volume;
  93850. private _isReadyToPlay;
  93851. private _isDirectional;
  93852. private _readyToPlayCallback;
  93853. private _audioBuffer;
  93854. private _soundSource;
  93855. private _streamingSource;
  93856. private _soundPanner;
  93857. private _soundGain;
  93858. private _inputAudioNode;
  93859. private _outputAudioNode;
  93860. private _coneInnerAngle;
  93861. private _coneOuterAngle;
  93862. private _coneOuterGain;
  93863. private _scene;
  93864. private _connectedTransformNode;
  93865. private _customAttenuationFunction;
  93866. private _registerFunc;
  93867. private _isOutputConnected;
  93868. private _htmlAudioElement;
  93869. private _urlType;
  93870. /** @hidden */
  93871. static _SceneComponentInitialization: (scene: Scene) => void;
  93872. /**
  93873. * Create a sound and attach it to a scene
  93874. * @param name Name of your sound
  93875. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93876. * @param scene defines the scene the sound belongs to
  93877. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93878. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93879. */
  93880. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93881. /**
  93882. * Release the sound and its associated resources
  93883. */
  93884. dispose(): void;
  93885. /**
  93886. * Gets if the sounds is ready to be played or not.
  93887. * @returns true if ready, otherwise false
  93888. */
  93889. isReady(): boolean;
  93890. private _soundLoaded;
  93891. /**
  93892. * Sets the data of the sound from an audiobuffer
  93893. * @param audioBuffer The audioBuffer containing the data
  93894. */
  93895. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93896. /**
  93897. * Updates the current sounds options such as maxdistance, loop...
  93898. * @param options A JSON object containing values named as the object properties
  93899. */
  93900. updateOptions(options: any): void;
  93901. private _createSpatialParameters;
  93902. private _updateSpatialParameters;
  93903. /**
  93904. * Switch the panning model to HRTF:
  93905. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93907. */
  93908. switchPanningModelToHRTF(): void;
  93909. /**
  93910. * Switch the panning model to Equal Power:
  93911. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93912. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93913. */
  93914. switchPanningModelToEqualPower(): void;
  93915. private _switchPanningModel;
  93916. /**
  93917. * Connect this sound to a sound track audio node like gain...
  93918. * @param soundTrackAudioNode the sound track audio node to connect to
  93919. */
  93920. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93921. /**
  93922. * Transform this sound into a directional source
  93923. * @param coneInnerAngle Size of the inner cone in degree
  93924. * @param coneOuterAngle Size of the outer cone in degree
  93925. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93926. */
  93927. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93928. /**
  93929. * Gets or sets the inner angle for the directional cone.
  93930. */
  93931. /**
  93932. * Gets or sets the inner angle for the directional cone.
  93933. */
  93934. directionalConeInnerAngle: number;
  93935. /**
  93936. * Gets or sets the outer angle for the directional cone.
  93937. */
  93938. /**
  93939. * Gets or sets the outer angle for the directional cone.
  93940. */
  93941. directionalConeOuterAngle: number;
  93942. /**
  93943. * Sets the position of the emitter if spatial sound is enabled
  93944. * @param newPosition Defines the new posisiton
  93945. */
  93946. setPosition(newPosition: Vector3): void;
  93947. /**
  93948. * Sets the local direction of the emitter if spatial sound is enabled
  93949. * @param newLocalDirection Defines the new local direction
  93950. */
  93951. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93952. private _updateDirection;
  93953. /** @hidden */
  93954. updateDistanceFromListener(): void;
  93955. /**
  93956. * Sets a new custom attenuation function for the sound.
  93957. * @param callback Defines the function used for the attenuation
  93958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93959. */
  93960. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93961. /**
  93962. * Play the sound
  93963. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93964. * @param offset (optional) Start the sound setting it at a specific time
  93965. */
  93966. play(time?: number, offset?: number): void;
  93967. private _onended;
  93968. /**
  93969. * Stop the sound
  93970. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93971. */
  93972. stop(time?: number): void;
  93973. /**
  93974. * Put the sound in pause
  93975. */
  93976. pause(): void;
  93977. /**
  93978. * Sets a dedicated volume for this sounds
  93979. * @param newVolume Define the new volume of the sound
  93980. * @param time Define in how long the sound should be at this value
  93981. */
  93982. setVolume(newVolume: number, time?: number): void;
  93983. /**
  93984. * Set the sound play back rate
  93985. * @param newPlaybackRate Define the playback rate the sound should be played at
  93986. */
  93987. setPlaybackRate(newPlaybackRate: number): void;
  93988. /**
  93989. * Gets the volume of the sound.
  93990. * @returns the volume of the sound
  93991. */
  93992. getVolume(): number;
  93993. /**
  93994. * Attach the sound to a dedicated mesh
  93995. * @param transformNode The transform node to connect the sound with
  93996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93997. */
  93998. attachToMesh(transformNode: TransformNode): void;
  93999. /**
  94000. * Detach the sound from the previously attached mesh
  94001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94002. */
  94003. detachFromMesh(): void;
  94004. private _onRegisterAfterWorldMatrixUpdate;
  94005. /**
  94006. * Clone the current sound in the scene.
  94007. * @returns the new sound clone
  94008. */
  94009. clone(): Nullable<Sound>;
  94010. /**
  94011. * Gets the current underlying audio buffer containing the data
  94012. * @returns the audio buffer
  94013. */
  94014. getAudioBuffer(): Nullable<AudioBuffer>;
  94015. /**
  94016. * Serializes the Sound in a JSON representation
  94017. * @returns the JSON representation of the sound
  94018. */
  94019. serialize(): any;
  94020. /**
  94021. * Parse a JSON representation of a sound to innstantiate in a given scene
  94022. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  94023. * @param scene Define the scene the new parsed sound should be created in
  94024. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  94025. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  94026. * @returns the newly parsed sound
  94027. */
  94028. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  94029. }
  94030. }
  94031. declare module BABYLON {
  94032. /**
  94033. * This defines an action helpful to play a defined sound on a triggered action.
  94034. */
  94035. export class PlaySoundAction extends Action {
  94036. private _sound;
  94037. /**
  94038. * Instantiate the action
  94039. * @param triggerOptions defines the trigger options
  94040. * @param sound defines the sound to play
  94041. * @param condition defines the trigger related conditions
  94042. */
  94043. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94044. /** @hidden */
  94045. _prepare(): void;
  94046. /**
  94047. * Execute the action and play the sound.
  94048. */
  94049. execute(): void;
  94050. /**
  94051. * Serializes the actions and its related information.
  94052. * @param parent defines the object to serialize in
  94053. * @returns the serialized object
  94054. */
  94055. serialize(parent: any): any;
  94056. }
  94057. /**
  94058. * This defines an action helpful to stop a defined sound on a triggered action.
  94059. */
  94060. export class StopSoundAction extends Action {
  94061. private _sound;
  94062. /**
  94063. * Instantiate the action
  94064. * @param triggerOptions defines the trigger options
  94065. * @param sound defines the sound to stop
  94066. * @param condition defines the trigger related conditions
  94067. */
  94068. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94069. /** @hidden */
  94070. _prepare(): void;
  94071. /**
  94072. * Execute the action and stop the sound.
  94073. */
  94074. execute(): void;
  94075. /**
  94076. * Serializes the actions and its related information.
  94077. * @param parent defines the object to serialize in
  94078. * @returns the serialized object
  94079. */
  94080. serialize(parent: any): any;
  94081. }
  94082. }
  94083. declare module BABYLON {
  94084. /**
  94085. * This defines an action responsible to change the value of a property
  94086. * by interpolating between its current value and the newly set one once triggered.
  94087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94088. */
  94089. export class InterpolateValueAction extends Action {
  94090. /**
  94091. * Defines the path of the property where the value should be interpolated
  94092. */
  94093. propertyPath: string;
  94094. /**
  94095. * Defines the target value at the end of the interpolation.
  94096. */
  94097. value: any;
  94098. /**
  94099. * Defines the time it will take for the property to interpolate to the value.
  94100. */
  94101. duration: number;
  94102. /**
  94103. * Defines if the other scene animations should be stopped when the action has been triggered
  94104. */
  94105. stopOtherAnimations?: boolean;
  94106. /**
  94107. * Defines a callback raised once the interpolation animation has been done.
  94108. */
  94109. onInterpolationDone?: () => void;
  94110. /**
  94111. * Observable triggered once the interpolation animation has been done.
  94112. */
  94113. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  94114. private _target;
  94115. private _effectiveTarget;
  94116. private _property;
  94117. /**
  94118. * Instantiate the action
  94119. * @param triggerOptions defines the trigger options
  94120. * @param target defines the object containing the value to interpolate
  94121. * @param propertyPath defines the path to the property in the target object
  94122. * @param value defines the target value at the end of the interpolation
  94123. * @param duration deines the time it will take for the property to interpolate to the value.
  94124. * @param condition defines the trigger related conditions
  94125. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  94126. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  94127. */
  94128. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  94129. /** @hidden */
  94130. _prepare(): void;
  94131. /**
  94132. * Execute the action starts the value interpolation.
  94133. */
  94134. execute(): void;
  94135. /**
  94136. * Serializes the actions and its related information.
  94137. * @param parent defines the object to serialize in
  94138. * @returns the serialized object
  94139. */
  94140. serialize(parent: any): any;
  94141. }
  94142. }
  94143. declare module BABYLON {
  94144. /**
  94145. * Options allowed during the creation of a sound track.
  94146. */
  94147. export interface ISoundTrackOptions {
  94148. /**
  94149. * The volume the sound track should take during creation
  94150. */
  94151. volume?: number;
  94152. /**
  94153. * Define if the sound track is the main sound track of the scene
  94154. */
  94155. mainTrack?: boolean;
  94156. }
  94157. /**
  94158. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  94159. * It will be also used in a future release to apply effects on a specific track.
  94160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94161. */
  94162. export class SoundTrack {
  94163. /**
  94164. * The unique identifier of the sound track in the scene.
  94165. */
  94166. id: number;
  94167. /**
  94168. * The list of sounds included in the sound track.
  94169. */
  94170. soundCollection: Array<Sound>;
  94171. private _outputAudioNode;
  94172. private _scene;
  94173. private _isMainTrack;
  94174. private _connectedAnalyser;
  94175. private _options;
  94176. private _isInitialized;
  94177. /**
  94178. * Creates a new sound track.
  94179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94180. * @param scene Define the scene the sound track belongs to
  94181. * @param options
  94182. */
  94183. constructor(scene: Scene, options?: ISoundTrackOptions);
  94184. private _initializeSoundTrackAudioGraph;
  94185. /**
  94186. * Release the sound track and its associated resources
  94187. */
  94188. dispose(): void;
  94189. /**
  94190. * Adds a sound to this sound track
  94191. * @param sound define the cound to add
  94192. * @ignoreNaming
  94193. */
  94194. AddSound(sound: Sound): void;
  94195. /**
  94196. * Removes a sound to this sound track
  94197. * @param sound define the cound to remove
  94198. * @ignoreNaming
  94199. */
  94200. RemoveSound(sound: Sound): void;
  94201. /**
  94202. * Set a global volume for the full sound track.
  94203. * @param newVolume Define the new volume of the sound track
  94204. */
  94205. setVolume(newVolume: number): void;
  94206. /**
  94207. * Switch the panning model to HRTF:
  94208. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94210. */
  94211. switchPanningModelToHRTF(): void;
  94212. /**
  94213. * Switch the panning model to Equal Power:
  94214. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94216. */
  94217. switchPanningModelToEqualPower(): void;
  94218. /**
  94219. * Connect the sound track to an audio analyser allowing some amazing
  94220. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94222. * @param analyser The analyser to connect to the engine
  94223. */
  94224. connectToAnalyser(analyser: Analyser): void;
  94225. }
  94226. }
  94227. declare module BABYLON {
  94228. interface AbstractScene {
  94229. /**
  94230. * The list of sounds used in the scene.
  94231. */
  94232. sounds: Nullable<Array<Sound>>;
  94233. }
  94234. interface Scene {
  94235. /**
  94236. * @hidden
  94237. * Backing field
  94238. */
  94239. _mainSoundTrack: SoundTrack;
  94240. /**
  94241. * The main sound track played by the scene.
  94242. * It cotains your primary collection of sounds.
  94243. */
  94244. mainSoundTrack: SoundTrack;
  94245. /**
  94246. * The list of sound tracks added to the scene
  94247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94248. */
  94249. soundTracks: Nullable<Array<SoundTrack>>;
  94250. /**
  94251. * Gets a sound using a given name
  94252. * @param name defines the name to search for
  94253. * @return the found sound or null if not found at all.
  94254. */
  94255. getSoundByName(name: string): Nullable<Sound>;
  94256. /**
  94257. * Gets or sets if audio support is enabled
  94258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94259. */
  94260. audioEnabled: boolean;
  94261. /**
  94262. * Gets or sets if audio will be output to headphones
  94263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94264. */
  94265. headphone: boolean;
  94266. }
  94267. /**
  94268. * Defines the sound scene component responsible to manage any sounds
  94269. * in a given scene.
  94270. */
  94271. export class AudioSceneComponent implements ISceneSerializableComponent {
  94272. /**
  94273. * The component name helpfull to identify the component in the list of scene components.
  94274. */
  94275. readonly name: string;
  94276. /**
  94277. * The scene the component belongs to.
  94278. */
  94279. scene: Scene;
  94280. private _audioEnabled;
  94281. /**
  94282. * Gets whether audio is enabled or not.
  94283. * Please use related enable/disable method to switch state.
  94284. */
  94285. readonly audioEnabled: boolean;
  94286. private _headphone;
  94287. /**
  94288. * Gets whether audio is outputing to headphone or not.
  94289. * Please use the according Switch methods to change output.
  94290. */
  94291. readonly headphone: boolean;
  94292. /**
  94293. * Creates a new instance of the component for the given scene
  94294. * @param scene Defines the scene to register the component in
  94295. */
  94296. constructor(scene: Scene);
  94297. /**
  94298. * Registers the component in a given scene
  94299. */
  94300. register(): void;
  94301. /**
  94302. * Rebuilds the elements related to this component in case of
  94303. * context lost for instance.
  94304. */
  94305. rebuild(): void;
  94306. /**
  94307. * Serializes the component data to the specified json object
  94308. * @param serializationObject The object to serialize to
  94309. */
  94310. serialize(serializationObject: any): void;
  94311. /**
  94312. * Adds all the element from the container to the scene
  94313. * @param container the container holding the elements
  94314. */
  94315. addFromContainer(container: AbstractScene): void;
  94316. /**
  94317. * Removes all the elements in the container from the scene
  94318. * @param container contains the elements to remove
  94319. * @param dispose if the removed element should be disposed (default: false)
  94320. */
  94321. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  94322. /**
  94323. * Disposes the component and the associated ressources.
  94324. */
  94325. dispose(): void;
  94326. /**
  94327. * Disables audio in the associated scene.
  94328. */
  94329. disableAudio(): void;
  94330. /**
  94331. * Enables audio in the associated scene.
  94332. */
  94333. enableAudio(): void;
  94334. /**
  94335. * Switch audio to headphone output.
  94336. */
  94337. switchAudioModeForHeadphones(): void;
  94338. /**
  94339. * Switch audio to normal speakers.
  94340. */
  94341. switchAudioModeForNormalSpeakers(): void;
  94342. private _afterRender;
  94343. }
  94344. }
  94345. declare module BABYLON {
  94346. /**
  94347. * Wraps one or more Sound objects and selects one with random weight for playback.
  94348. */
  94349. export class WeightedSound {
  94350. /** When true a Sound will be selected and played when the current playing Sound completes. */
  94351. loop: boolean;
  94352. private _coneInnerAngle;
  94353. private _coneOuterAngle;
  94354. private _volume;
  94355. /** A Sound is currently playing. */
  94356. isPlaying: boolean;
  94357. /** A Sound is currently paused. */
  94358. isPaused: boolean;
  94359. private _sounds;
  94360. private _weights;
  94361. private _currentIndex?;
  94362. /**
  94363. * Creates a new WeightedSound from the list of sounds given.
  94364. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  94365. * @param sounds Array of Sounds that will be selected from.
  94366. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  94367. */
  94368. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  94369. /**
  94370. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  94371. */
  94372. /**
  94373. * The size of cone in degress for a directional sound in which there will be no attenuation.
  94374. */
  94375. directionalConeInnerAngle: number;
  94376. /**
  94377. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94378. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94379. */
  94380. /**
  94381. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94382. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94383. */
  94384. directionalConeOuterAngle: number;
  94385. /**
  94386. * Playback volume.
  94387. */
  94388. /**
  94389. * Playback volume.
  94390. */
  94391. volume: number;
  94392. private _onended;
  94393. /**
  94394. * Suspend playback
  94395. */
  94396. pause(): void;
  94397. /**
  94398. * Stop playback
  94399. */
  94400. stop(): void;
  94401. /**
  94402. * Start playback.
  94403. * @param startOffset Position the clip head at a specific time in seconds.
  94404. */
  94405. play(startOffset?: number): void;
  94406. }
  94407. }
  94408. declare module BABYLON {
  94409. /**
  94410. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  94411. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94412. */
  94413. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  94414. /**
  94415. * Gets the name of the behavior.
  94416. */
  94417. readonly name: string;
  94418. /**
  94419. * The easing function used by animations
  94420. */
  94421. static EasingFunction: BackEase;
  94422. /**
  94423. * The easing mode used by animations
  94424. */
  94425. static EasingMode: number;
  94426. /**
  94427. * The duration of the animation, in milliseconds
  94428. */
  94429. transitionDuration: number;
  94430. /**
  94431. * Length of the distance animated by the transition when lower radius is reached
  94432. */
  94433. lowerRadiusTransitionRange: number;
  94434. /**
  94435. * Length of the distance animated by the transition when upper radius is reached
  94436. */
  94437. upperRadiusTransitionRange: number;
  94438. private _autoTransitionRange;
  94439. /**
  94440. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94441. */
  94442. /**
  94443. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94444. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  94445. */
  94446. autoTransitionRange: boolean;
  94447. private _attachedCamera;
  94448. private _onAfterCheckInputsObserver;
  94449. private _onMeshTargetChangedObserver;
  94450. /**
  94451. * Initializes the behavior.
  94452. */
  94453. init(): void;
  94454. /**
  94455. * Attaches the behavior to its arc rotate camera.
  94456. * @param camera Defines the camera to attach the behavior to
  94457. */
  94458. attach(camera: ArcRotateCamera): void;
  94459. /**
  94460. * Detaches the behavior from its current arc rotate camera.
  94461. */
  94462. detach(): void;
  94463. private _radiusIsAnimating;
  94464. private _radiusBounceTransition;
  94465. private _animatables;
  94466. private _cachedWheelPrecision;
  94467. /**
  94468. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  94469. * @param radiusLimit The limit to check against.
  94470. * @return Bool to indicate if at limit.
  94471. */
  94472. private _isRadiusAtLimit;
  94473. /**
  94474. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  94475. * @param radiusDelta The delta by which to animate to. Can be negative.
  94476. */
  94477. private _applyBoundRadiusAnimation;
  94478. /**
  94479. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  94480. */
  94481. protected _clearAnimationLocks(): void;
  94482. /**
  94483. * Stops and removes all animations that have been applied to the camera
  94484. */
  94485. stopAllAnimations(): void;
  94486. }
  94487. }
  94488. declare module BABYLON {
  94489. /**
  94490. * 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.
  94491. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94492. */
  94493. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  94494. /**
  94495. * Gets the name of the behavior.
  94496. */
  94497. readonly name: string;
  94498. private _mode;
  94499. private _radiusScale;
  94500. private _positionScale;
  94501. private _defaultElevation;
  94502. private _elevationReturnTime;
  94503. private _elevationReturnWaitTime;
  94504. private _zoomStopsAnimation;
  94505. private _framingTime;
  94506. /**
  94507. * The easing function used by animations
  94508. */
  94509. static EasingFunction: ExponentialEase;
  94510. /**
  94511. * The easing mode used by animations
  94512. */
  94513. static EasingMode: number;
  94514. /**
  94515. * Sets the current mode used by the behavior
  94516. */
  94517. /**
  94518. * Gets current mode used by the behavior.
  94519. */
  94520. mode: number;
  94521. /**
  94522. * Sets the scale applied to the radius (1 by default)
  94523. */
  94524. /**
  94525. * Gets the scale applied to the radius
  94526. */
  94527. radiusScale: number;
  94528. /**
  94529. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94530. */
  94531. /**
  94532. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94533. */
  94534. positionScale: number;
  94535. /**
  94536. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94537. * behaviour is triggered, in radians.
  94538. */
  94539. /**
  94540. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94541. * behaviour is triggered, in radians.
  94542. */
  94543. defaultElevation: number;
  94544. /**
  94545. * Sets the time (in milliseconds) taken to return to the default beta position.
  94546. * Negative value indicates camera should not return to default.
  94547. */
  94548. /**
  94549. * Gets the time (in milliseconds) taken to return to the default beta position.
  94550. * Negative value indicates camera should not return to default.
  94551. */
  94552. elevationReturnTime: number;
  94553. /**
  94554. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94555. */
  94556. /**
  94557. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94558. */
  94559. elevationReturnWaitTime: number;
  94560. /**
  94561. * Sets the flag that indicates if user zooming should stop animation.
  94562. */
  94563. /**
  94564. * Gets the flag that indicates if user zooming should stop animation.
  94565. */
  94566. zoomStopsAnimation: boolean;
  94567. /**
  94568. * Sets the transition time when framing the mesh, in milliseconds
  94569. */
  94570. /**
  94571. * Gets the transition time when framing the mesh, in milliseconds
  94572. */
  94573. framingTime: number;
  94574. /**
  94575. * Define if the behavior should automatically change the configured
  94576. * camera limits and sensibilities.
  94577. */
  94578. autoCorrectCameraLimitsAndSensibility: boolean;
  94579. private _onPrePointerObservableObserver;
  94580. private _onAfterCheckInputsObserver;
  94581. private _onMeshTargetChangedObserver;
  94582. private _attachedCamera;
  94583. private _isPointerDown;
  94584. private _lastInteractionTime;
  94585. /**
  94586. * Initializes the behavior.
  94587. */
  94588. init(): void;
  94589. /**
  94590. * Attaches the behavior to its arc rotate camera.
  94591. * @param camera Defines the camera to attach the behavior to
  94592. */
  94593. attach(camera: ArcRotateCamera): void;
  94594. /**
  94595. * Detaches the behavior from its current arc rotate camera.
  94596. */
  94597. detach(): void;
  94598. private _animatables;
  94599. private _betaIsAnimating;
  94600. private _betaTransition;
  94601. private _radiusTransition;
  94602. private _vectorTransition;
  94603. /**
  94604. * Targets the given mesh and updates zoom level accordingly.
  94605. * @param mesh The mesh to target.
  94606. * @param radius Optional. If a cached radius position already exists, overrides default.
  94607. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94608. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94609. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94610. */
  94611. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94612. /**
  94613. * Targets the given mesh with its children and updates zoom level accordingly.
  94614. * @param mesh The mesh to target.
  94615. * @param radius Optional. If a cached radius position already exists, overrides default.
  94616. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94617. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94618. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94619. */
  94620. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94621. /**
  94622. * Targets the given meshes with their children and updates zoom level accordingly.
  94623. * @param meshes The mesh to target.
  94624. * @param radius Optional. If a cached radius position already exists, overrides default.
  94625. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94626. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94627. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94628. */
  94629. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94630. /**
  94631. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94632. * @param minimumWorld Determines the smaller position of the bounding box extend
  94633. * @param maximumWorld Determines the bigger position of the bounding box extend
  94634. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94635. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94636. */
  94637. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94638. /**
  94639. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94640. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94641. * frustum width.
  94642. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94643. * to fully enclose the mesh in the viewing frustum.
  94644. */
  94645. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94646. /**
  94647. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94648. * is automatically returned to its default position (expected to be above ground plane).
  94649. */
  94650. private _maintainCameraAboveGround;
  94651. /**
  94652. * Returns the frustum slope based on the canvas ratio and camera FOV
  94653. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94654. */
  94655. private _getFrustumSlope;
  94656. /**
  94657. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94658. */
  94659. private _clearAnimationLocks;
  94660. /**
  94661. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94662. */
  94663. private _applyUserInteraction;
  94664. /**
  94665. * Stops and removes all animations that have been applied to the camera
  94666. */
  94667. stopAllAnimations(): void;
  94668. /**
  94669. * Gets a value indicating if the user is moving the camera
  94670. */
  94671. readonly isUserIsMoving: boolean;
  94672. /**
  94673. * The camera can move all the way towards the mesh.
  94674. */
  94675. static IgnoreBoundsSizeMode: number;
  94676. /**
  94677. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94678. */
  94679. static FitFrustumSidesMode: number;
  94680. }
  94681. }
  94682. declare module BABYLON {
  94683. /**
  94684. * Base class for Camera Pointer Inputs.
  94685. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94686. * for example usage.
  94687. */
  94688. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94689. /**
  94690. * Defines the camera the input is attached to.
  94691. */
  94692. abstract camera: Camera;
  94693. /**
  94694. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94695. */
  94696. protected _altKey: boolean;
  94697. protected _ctrlKey: boolean;
  94698. protected _metaKey: boolean;
  94699. protected _shiftKey: boolean;
  94700. /**
  94701. * Which mouse buttons were pressed at time of last mouse event.
  94702. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94703. */
  94704. protected _buttonsPressed: number;
  94705. /**
  94706. * Defines the buttons associated with the input to handle camera move.
  94707. */
  94708. buttons: number[];
  94709. /**
  94710. * Attach the input controls to a specific dom element to get the input from.
  94711. * @param element Defines the element the controls should be listened from
  94712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94713. */
  94714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94715. /**
  94716. * Detach the current controls from the specified dom element.
  94717. * @param element Defines the element to stop listening the inputs from
  94718. */
  94719. detachControl(element: Nullable<HTMLElement>): void;
  94720. /**
  94721. * Gets the class name of the current input.
  94722. * @returns the class name
  94723. */
  94724. getClassName(): string;
  94725. /**
  94726. * Get the friendly name associated with the input class.
  94727. * @returns the input friendly name
  94728. */
  94729. getSimpleName(): string;
  94730. /**
  94731. * Called on pointer POINTERDOUBLETAP event.
  94732. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94733. */
  94734. protected onDoubleTap(type: string): void;
  94735. /**
  94736. * Called on pointer POINTERMOVE event if only a single touch is active.
  94737. * Override this method to provide functionality.
  94738. */
  94739. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94740. /**
  94741. * Called on pointer POINTERMOVE event if multiple touches are active.
  94742. * Override this method to provide functionality.
  94743. */
  94744. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94745. /**
  94746. * Called on JS contextmenu event.
  94747. * Override this method to provide functionality.
  94748. */
  94749. protected onContextMenu(evt: PointerEvent): void;
  94750. /**
  94751. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94752. * press.
  94753. * Override this method to provide functionality.
  94754. */
  94755. protected onButtonDown(evt: PointerEvent): void;
  94756. /**
  94757. * Called each time a new POINTERUP event occurs. Ie, for each button
  94758. * release.
  94759. * Override this method to provide functionality.
  94760. */
  94761. protected onButtonUp(evt: PointerEvent): void;
  94762. /**
  94763. * Called when window becomes inactive.
  94764. * Override this method to provide functionality.
  94765. */
  94766. protected onLostFocus(): void;
  94767. private _pointerInput;
  94768. private _observer;
  94769. private _onLostFocus;
  94770. private pointA;
  94771. private pointB;
  94772. }
  94773. }
  94774. declare module BABYLON {
  94775. /**
  94776. * Manage the pointers inputs to control an arc rotate camera.
  94777. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94778. */
  94779. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94780. /**
  94781. * Defines the camera the input is attached to.
  94782. */
  94783. camera: ArcRotateCamera;
  94784. /**
  94785. * Gets the class name of the current input.
  94786. * @returns the class name
  94787. */
  94788. getClassName(): string;
  94789. /**
  94790. * Defines the buttons associated with the input to handle camera move.
  94791. */
  94792. buttons: number[];
  94793. /**
  94794. * Defines the pointer angular sensibility along the X axis or how fast is
  94795. * the camera rotating.
  94796. */
  94797. angularSensibilityX: number;
  94798. /**
  94799. * Defines the pointer angular sensibility along the Y axis or how fast is
  94800. * the camera rotating.
  94801. */
  94802. angularSensibilityY: number;
  94803. /**
  94804. * Defines the pointer pinch precision or how fast is the camera zooming.
  94805. */
  94806. pinchPrecision: number;
  94807. /**
  94808. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94809. * from 0.
  94810. * It defines the percentage of current camera.radius to use as delta when
  94811. * pinch zoom is used.
  94812. */
  94813. pinchDeltaPercentage: number;
  94814. /**
  94815. * Defines the pointer panning sensibility or how fast is the camera moving.
  94816. */
  94817. panningSensibility: number;
  94818. /**
  94819. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94820. */
  94821. multiTouchPanning: boolean;
  94822. /**
  94823. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94824. * zoom (pinch) through multitouch.
  94825. */
  94826. multiTouchPanAndZoom: boolean;
  94827. /**
  94828. * Revers pinch action direction.
  94829. */
  94830. pinchInwards: boolean;
  94831. private _isPanClick;
  94832. private _twoFingerActivityCount;
  94833. private _isPinching;
  94834. /**
  94835. * Called on pointer POINTERMOVE event if only a single touch is active.
  94836. */
  94837. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94838. /**
  94839. * Called on pointer POINTERDOUBLETAP event.
  94840. */
  94841. protected onDoubleTap(type: string): void;
  94842. /**
  94843. * Called on pointer POINTERMOVE event if multiple touches are active.
  94844. */
  94845. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94846. /**
  94847. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94848. * press.
  94849. */
  94850. protected onButtonDown(evt: PointerEvent): void;
  94851. /**
  94852. * Called each time a new POINTERUP event occurs. Ie, for each button
  94853. * release.
  94854. */
  94855. protected onButtonUp(evt: PointerEvent): void;
  94856. /**
  94857. * Called when window becomes inactive.
  94858. */
  94859. protected onLostFocus(): void;
  94860. }
  94861. }
  94862. declare module BABYLON {
  94863. /**
  94864. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94866. */
  94867. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94868. /**
  94869. * Defines the camera the input is attached to.
  94870. */
  94871. camera: ArcRotateCamera;
  94872. /**
  94873. * Defines the list of key codes associated with the up action (increase alpha)
  94874. */
  94875. keysUp: number[];
  94876. /**
  94877. * Defines the list of key codes associated with the down action (decrease alpha)
  94878. */
  94879. keysDown: number[];
  94880. /**
  94881. * Defines the list of key codes associated with the left action (increase beta)
  94882. */
  94883. keysLeft: number[];
  94884. /**
  94885. * Defines the list of key codes associated with the right action (decrease beta)
  94886. */
  94887. keysRight: number[];
  94888. /**
  94889. * Defines the list of key codes associated with the reset action.
  94890. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94891. */
  94892. keysReset: number[];
  94893. /**
  94894. * Defines the panning sensibility of the inputs.
  94895. * (How fast is the camera paning)
  94896. */
  94897. panningSensibility: number;
  94898. /**
  94899. * Defines the zooming sensibility of the inputs.
  94900. * (How fast is the camera zooming)
  94901. */
  94902. zoomingSensibility: number;
  94903. /**
  94904. * Defines wether maintaining the alt key down switch the movement mode from
  94905. * orientation to zoom.
  94906. */
  94907. useAltToZoom: boolean;
  94908. /**
  94909. * Rotation speed of the camera
  94910. */
  94911. angularSpeed: number;
  94912. private _keys;
  94913. private _ctrlPressed;
  94914. private _altPressed;
  94915. private _onCanvasBlurObserver;
  94916. private _onKeyboardObserver;
  94917. private _engine;
  94918. private _scene;
  94919. /**
  94920. * Attach the input controls to a specific dom element to get the input from.
  94921. * @param element Defines the element the controls should be listened from
  94922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94923. */
  94924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94925. /**
  94926. * Detach the current controls from the specified dom element.
  94927. * @param element Defines the element to stop listening the inputs from
  94928. */
  94929. detachControl(element: Nullable<HTMLElement>): void;
  94930. /**
  94931. * Update the current camera state depending on the inputs that have been used this frame.
  94932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94933. */
  94934. checkInputs(): void;
  94935. /**
  94936. * Gets the class name of the current intput.
  94937. * @returns the class name
  94938. */
  94939. getClassName(): string;
  94940. /**
  94941. * Get the friendly name associated with the input class.
  94942. * @returns the input friendly name
  94943. */
  94944. getSimpleName(): string;
  94945. }
  94946. }
  94947. declare module BABYLON {
  94948. /**
  94949. * Manage the mouse wheel inputs to control an arc rotate camera.
  94950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94951. */
  94952. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94953. /**
  94954. * Defines the camera the input is attached to.
  94955. */
  94956. camera: ArcRotateCamera;
  94957. /**
  94958. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94959. */
  94960. wheelPrecision: number;
  94961. /**
  94962. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94963. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94964. */
  94965. wheelDeltaPercentage: number;
  94966. private _wheel;
  94967. private _observer;
  94968. /**
  94969. * Attach the input controls to a specific dom element to get the input from.
  94970. * @param element Defines the element the controls should be listened from
  94971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94972. */
  94973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94974. /**
  94975. * Detach the current controls from the specified dom element.
  94976. * @param element Defines the element to stop listening the inputs from
  94977. */
  94978. detachControl(element: Nullable<HTMLElement>): void;
  94979. /**
  94980. * Gets the class name of the current intput.
  94981. * @returns the class name
  94982. */
  94983. getClassName(): string;
  94984. /**
  94985. * Get the friendly name associated with the input class.
  94986. * @returns the input friendly name
  94987. */
  94988. getSimpleName(): string;
  94989. }
  94990. }
  94991. declare module BABYLON {
  94992. /**
  94993. * Default Inputs manager for the ArcRotateCamera.
  94994. * It groups all the default supported inputs for ease of use.
  94995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94996. */
  94997. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  94998. /**
  94999. * Instantiates a new ArcRotateCameraInputsManager.
  95000. * @param camera Defines the camera the inputs belong to
  95001. */
  95002. constructor(camera: ArcRotateCamera);
  95003. /**
  95004. * Add mouse wheel input support to the input manager.
  95005. * @returns the current input manager
  95006. */
  95007. addMouseWheel(): ArcRotateCameraInputsManager;
  95008. /**
  95009. * Add pointers input support to the input manager.
  95010. * @returns the current input manager
  95011. */
  95012. addPointers(): ArcRotateCameraInputsManager;
  95013. /**
  95014. * Add keyboard input support to the input manager.
  95015. * @returns the current input manager
  95016. */
  95017. addKeyboard(): ArcRotateCameraInputsManager;
  95018. }
  95019. }
  95020. declare module BABYLON {
  95021. /**
  95022. * This represents an orbital type of camera.
  95023. *
  95024. * 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.
  95025. * 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.
  95026. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  95027. */
  95028. export class ArcRotateCamera extends TargetCamera {
  95029. /**
  95030. * Defines the rotation angle of the camera along the longitudinal axis.
  95031. */
  95032. alpha: number;
  95033. /**
  95034. * Defines the rotation angle of the camera along the latitudinal axis.
  95035. */
  95036. beta: number;
  95037. /**
  95038. * Defines the radius of the camera from it s target point.
  95039. */
  95040. radius: number;
  95041. protected _target: Vector3;
  95042. protected _targetHost: Nullable<AbstractMesh>;
  95043. /**
  95044. * Defines the target point of the camera.
  95045. * The camera looks towards it form the radius distance.
  95046. */
  95047. target: Vector3;
  95048. /**
  95049. * Define the current local position of the camera in the scene
  95050. */
  95051. position: Vector3;
  95052. protected _upVector: Vector3;
  95053. protected _upToYMatrix: Matrix;
  95054. protected _YToUpMatrix: Matrix;
  95055. /**
  95056. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  95057. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  95058. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  95059. */
  95060. upVector: Vector3;
  95061. /**
  95062. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  95063. */
  95064. setMatUp(): void;
  95065. /**
  95066. * Current inertia value on the longitudinal axis.
  95067. * The bigger this number the longer it will take for the camera to stop.
  95068. */
  95069. inertialAlphaOffset: number;
  95070. /**
  95071. * Current inertia value on the latitudinal axis.
  95072. * The bigger this number the longer it will take for the camera to stop.
  95073. */
  95074. inertialBetaOffset: number;
  95075. /**
  95076. * Current inertia value on the radius axis.
  95077. * The bigger this number the longer it will take for the camera to stop.
  95078. */
  95079. inertialRadiusOffset: number;
  95080. /**
  95081. * Minimum allowed angle on the longitudinal axis.
  95082. * This can help limiting how the Camera is able to move in the scene.
  95083. */
  95084. lowerAlphaLimit: Nullable<number>;
  95085. /**
  95086. * Maximum allowed angle on the longitudinal axis.
  95087. * This can help limiting how the Camera is able to move in the scene.
  95088. */
  95089. upperAlphaLimit: Nullable<number>;
  95090. /**
  95091. * Minimum allowed angle on the latitudinal axis.
  95092. * This can help limiting how the Camera is able to move in the scene.
  95093. */
  95094. lowerBetaLimit: number;
  95095. /**
  95096. * Maximum allowed angle on the latitudinal axis.
  95097. * This can help limiting how the Camera is able to move in the scene.
  95098. */
  95099. upperBetaLimit: number;
  95100. /**
  95101. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  95102. * This can help limiting how the Camera is able to move in the scene.
  95103. */
  95104. lowerRadiusLimit: Nullable<number>;
  95105. /**
  95106. * Maximum allowed distance of the camera to the target (The camera can not get further).
  95107. * This can help limiting how the Camera is able to move in the scene.
  95108. */
  95109. upperRadiusLimit: Nullable<number>;
  95110. /**
  95111. * Defines the current inertia value used during panning of the camera along the X axis.
  95112. */
  95113. inertialPanningX: number;
  95114. /**
  95115. * Defines the current inertia value used during panning of the camera along the Y axis.
  95116. */
  95117. inertialPanningY: number;
  95118. /**
  95119. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  95120. * Basically if your fingers moves away from more than this distance you will be considered
  95121. * in pinch mode.
  95122. */
  95123. pinchToPanMaxDistance: number;
  95124. /**
  95125. * Defines the maximum distance the camera can pan.
  95126. * This could help keeping the cammera always in your scene.
  95127. */
  95128. panningDistanceLimit: Nullable<number>;
  95129. /**
  95130. * Defines the target of the camera before paning.
  95131. */
  95132. panningOriginTarget: Vector3;
  95133. /**
  95134. * Defines the value of the inertia used during panning.
  95135. * 0 would mean stop inertia and one would mean no decelleration at all.
  95136. */
  95137. panningInertia: number;
  95138. /**
  95139. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  95140. */
  95141. angularSensibilityX: number;
  95142. /**
  95143. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  95144. */
  95145. angularSensibilityY: number;
  95146. /**
  95147. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  95148. */
  95149. pinchPrecision: number;
  95150. /**
  95151. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  95152. * It will be used instead of pinchDeltaPrecision if different from 0.
  95153. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95154. */
  95155. pinchDeltaPercentage: number;
  95156. /**
  95157. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  95158. */
  95159. panningSensibility: number;
  95160. /**
  95161. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  95162. */
  95163. keysUp: number[];
  95164. /**
  95165. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  95166. */
  95167. keysDown: number[];
  95168. /**
  95169. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  95170. */
  95171. keysLeft: number[];
  95172. /**
  95173. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  95174. */
  95175. keysRight: number[];
  95176. /**
  95177. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95178. */
  95179. wheelPrecision: number;
  95180. /**
  95181. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  95182. * It will be used instead of pinchDeltaPrecision if different from 0.
  95183. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95184. */
  95185. wheelDeltaPercentage: number;
  95186. /**
  95187. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  95188. */
  95189. zoomOnFactor: number;
  95190. /**
  95191. * Defines a screen offset for the camera position.
  95192. */
  95193. targetScreenOffset: Vector2;
  95194. /**
  95195. * Allows the camera to be completely reversed.
  95196. * If false the camera can not arrive upside down.
  95197. */
  95198. allowUpsideDown: boolean;
  95199. /**
  95200. * Define if double tap/click is used to restore the previously saved state of the camera.
  95201. */
  95202. useInputToRestoreState: boolean;
  95203. /** @hidden */
  95204. _viewMatrix: Matrix;
  95205. /** @hidden */
  95206. _useCtrlForPanning: boolean;
  95207. /** @hidden */
  95208. _panningMouseButton: number;
  95209. /**
  95210. * Defines the input associated to the camera.
  95211. */
  95212. inputs: ArcRotateCameraInputsManager;
  95213. /** @hidden */
  95214. _reset: () => void;
  95215. /**
  95216. * Defines the allowed panning axis.
  95217. */
  95218. panningAxis: Vector3;
  95219. protected _localDirection: Vector3;
  95220. protected _transformedDirection: Vector3;
  95221. private _bouncingBehavior;
  95222. /**
  95223. * Gets the bouncing behavior of the camera if it has been enabled.
  95224. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95225. */
  95226. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  95227. /**
  95228. * Defines if the bouncing behavior of the camera is enabled on the camera.
  95229. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95230. */
  95231. useBouncingBehavior: boolean;
  95232. private _framingBehavior;
  95233. /**
  95234. * Gets the framing behavior of the camera if it has been enabled.
  95235. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95236. */
  95237. readonly framingBehavior: Nullable<FramingBehavior>;
  95238. /**
  95239. * Defines if the framing behavior of the camera is enabled on the camera.
  95240. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95241. */
  95242. useFramingBehavior: boolean;
  95243. private _autoRotationBehavior;
  95244. /**
  95245. * Gets the auto rotation behavior of the camera if it has been enabled.
  95246. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95247. */
  95248. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  95249. /**
  95250. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  95251. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95252. */
  95253. useAutoRotationBehavior: boolean;
  95254. /**
  95255. * Observable triggered when the mesh target has been changed on the camera.
  95256. */
  95257. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  95258. /**
  95259. * Event raised when the camera is colliding with a mesh.
  95260. */
  95261. onCollide: (collidedMesh: AbstractMesh) => void;
  95262. /**
  95263. * Defines whether the camera should check collision with the objects oh the scene.
  95264. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  95265. */
  95266. checkCollisions: boolean;
  95267. /**
  95268. * Defines the collision radius of the camera.
  95269. * This simulates a sphere around the camera.
  95270. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95271. */
  95272. collisionRadius: Vector3;
  95273. protected _collider: Collider;
  95274. protected _previousPosition: Vector3;
  95275. protected _collisionVelocity: Vector3;
  95276. protected _newPosition: Vector3;
  95277. protected _previousAlpha: number;
  95278. protected _previousBeta: number;
  95279. protected _previousRadius: number;
  95280. protected _collisionTriggered: boolean;
  95281. protected _targetBoundingCenter: Nullable<Vector3>;
  95282. private _computationVector;
  95283. /**
  95284. * Instantiates a new ArcRotateCamera in a given scene
  95285. * @param name Defines the name of the camera
  95286. * @param alpha Defines the camera rotation along the logitudinal axis
  95287. * @param beta Defines the camera rotation along the latitudinal axis
  95288. * @param radius Defines the camera distance from its target
  95289. * @param target Defines the camera target
  95290. * @param scene Defines the scene the camera belongs to
  95291. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95292. */
  95293. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95294. /** @hidden */
  95295. _initCache(): void;
  95296. /** @hidden */
  95297. _updateCache(ignoreParentClass?: boolean): void;
  95298. protected _getTargetPosition(): Vector3;
  95299. private _storedAlpha;
  95300. private _storedBeta;
  95301. private _storedRadius;
  95302. private _storedTarget;
  95303. /**
  95304. * Stores the current state of the camera (alpha, beta, radius and target)
  95305. * @returns the camera itself
  95306. */
  95307. storeState(): Camera;
  95308. /**
  95309. * @hidden
  95310. * Restored camera state. You must call storeState() first
  95311. */
  95312. _restoreStateValues(): boolean;
  95313. /** @hidden */
  95314. _isSynchronizedViewMatrix(): boolean;
  95315. /**
  95316. * Attached controls to the current camera.
  95317. * @param element Defines the element the controls should be listened from
  95318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95319. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  95320. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  95321. */
  95322. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  95323. /**
  95324. * Detach the current controls from the camera.
  95325. * The camera will stop reacting to inputs.
  95326. * @param element Defines the element to stop listening the inputs from
  95327. */
  95328. detachControl(element: HTMLElement): void;
  95329. /** @hidden */
  95330. _checkInputs(): void;
  95331. protected _checkLimits(): void;
  95332. /**
  95333. * Rebuilds angles (alpha, beta) and radius from the give position and target
  95334. */
  95335. rebuildAnglesAndRadius(): void;
  95336. /**
  95337. * Use a position to define the current camera related information like aplha, beta and radius
  95338. * @param position Defines the position to set the camera at
  95339. */
  95340. setPosition(position: Vector3): void;
  95341. /**
  95342. * Defines the target the camera should look at.
  95343. * This will automatically adapt alpha beta and radius to fit within the new target.
  95344. * @param target Defines the new target as a Vector or a mesh
  95345. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  95346. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  95347. */
  95348. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  95349. /** @hidden */
  95350. _getViewMatrix(): Matrix;
  95351. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  95352. /**
  95353. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  95354. * @param meshes Defines the mesh to zoom on
  95355. * @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)
  95356. */
  95357. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  95358. /**
  95359. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  95360. * The target will be changed but the radius
  95361. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  95362. * @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)
  95363. */
  95364. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  95365. min: Vector3;
  95366. max: Vector3;
  95367. distance: number;
  95368. }, doNotUpdateMaxZ?: boolean): void;
  95369. /**
  95370. * @override
  95371. * Override Camera.createRigCamera
  95372. */
  95373. createRigCamera(name: string, cameraIndex: number): Camera;
  95374. /**
  95375. * @hidden
  95376. * @override
  95377. * Override Camera._updateRigCameras
  95378. */
  95379. _updateRigCameras(): void;
  95380. /**
  95381. * Destroy the camera and release the current resources hold by it.
  95382. */
  95383. dispose(): void;
  95384. /**
  95385. * Gets the current object class name.
  95386. * @return the class name
  95387. */
  95388. getClassName(): string;
  95389. }
  95390. }
  95391. declare module BABYLON {
  95392. /**
  95393. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  95394. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95395. */
  95396. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  95397. /**
  95398. * Gets the name of the behavior.
  95399. */
  95400. readonly name: string;
  95401. private _zoomStopsAnimation;
  95402. private _idleRotationSpeed;
  95403. private _idleRotationWaitTime;
  95404. private _idleRotationSpinupTime;
  95405. /**
  95406. * Sets the flag that indicates if user zooming should stop animation.
  95407. */
  95408. /**
  95409. * Gets the flag that indicates if user zooming should stop animation.
  95410. */
  95411. zoomStopsAnimation: boolean;
  95412. /**
  95413. * Sets the default speed at which the camera rotates around the model.
  95414. */
  95415. /**
  95416. * Gets the default speed at which the camera rotates around the model.
  95417. */
  95418. idleRotationSpeed: number;
  95419. /**
  95420. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  95421. */
  95422. /**
  95423. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  95424. */
  95425. idleRotationWaitTime: number;
  95426. /**
  95427. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95428. */
  95429. /**
  95430. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95431. */
  95432. idleRotationSpinupTime: number;
  95433. /**
  95434. * Gets a value indicating if the camera is currently rotating because of this behavior
  95435. */
  95436. readonly rotationInProgress: boolean;
  95437. private _onPrePointerObservableObserver;
  95438. private _onAfterCheckInputsObserver;
  95439. private _attachedCamera;
  95440. private _isPointerDown;
  95441. private _lastFrameTime;
  95442. private _lastInteractionTime;
  95443. private _cameraRotationSpeed;
  95444. /**
  95445. * Initializes the behavior.
  95446. */
  95447. init(): void;
  95448. /**
  95449. * Attaches the behavior to its arc rotate camera.
  95450. * @param camera Defines the camera to attach the behavior to
  95451. */
  95452. attach(camera: ArcRotateCamera): void;
  95453. /**
  95454. * Detaches the behavior from its current arc rotate camera.
  95455. */
  95456. detach(): void;
  95457. /**
  95458. * Returns true if user is scrolling.
  95459. * @return true if user is scrolling.
  95460. */
  95461. private _userIsZooming;
  95462. private _lastFrameRadius;
  95463. private _shouldAnimationStopForInteraction;
  95464. /**
  95465. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  95466. */
  95467. private _applyUserInteraction;
  95468. private _userIsMoving;
  95469. }
  95470. }
  95471. declare module BABYLON {
  95472. /**
  95473. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  95474. */
  95475. export class AttachToBoxBehavior implements Behavior<Mesh> {
  95476. private ui;
  95477. /**
  95478. * The name of the behavior
  95479. */
  95480. name: string;
  95481. /**
  95482. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  95483. */
  95484. distanceAwayFromFace: number;
  95485. /**
  95486. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  95487. */
  95488. distanceAwayFromBottomOfFace: number;
  95489. private _faceVectors;
  95490. private _target;
  95491. private _scene;
  95492. private _onRenderObserver;
  95493. private _tmpMatrix;
  95494. private _tmpVector;
  95495. /**
  95496. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  95497. * @param ui The transform node that should be attched to the mesh
  95498. */
  95499. constructor(ui: TransformNode);
  95500. /**
  95501. * Initializes the behavior
  95502. */
  95503. init(): void;
  95504. private _closestFace;
  95505. private _zeroVector;
  95506. private _lookAtTmpMatrix;
  95507. private _lookAtToRef;
  95508. /**
  95509. * Attaches the AttachToBoxBehavior to the passed in mesh
  95510. * @param target The mesh that the specified node will be attached to
  95511. */
  95512. attach(target: Mesh): void;
  95513. /**
  95514. * Detaches the behavior from the mesh
  95515. */
  95516. detach(): void;
  95517. }
  95518. }
  95519. declare module BABYLON {
  95520. /**
  95521. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95522. */
  95523. export class FadeInOutBehavior implements Behavior<Mesh> {
  95524. /**
  95525. * Time in milliseconds to delay before fading in (Default: 0)
  95526. */
  95527. delay: number;
  95528. /**
  95529. * Time in milliseconds for the mesh to fade in (Default: 300)
  95530. */
  95531. fadeInTime: number;
  95532. private _millisecondsPerFrame;
  95533. private _hovered;
  95534. private _hoverValue;
  95535. private _ownerNode;
  95536. /**
  95537. * Instatiates the FadeInOutBehavior
  95538. */
  95539. constructor();
  95540. /**
  95541. * The name of the behavior
  95542. */
  95543. readonly name: string;
  95544. /**
  95545. * Initializes the behavior
  95546. */
  95547. init(): void;
  95548. /**
  95549. * Attaches the fade behavior on the passed in mesh
  95550. * @param ownerNode The mesh that will be faded in/out once attached
  95551. */
  95552. attach(ownerNode: Mesh): void;
  95553. /**
  95554. * Detaches the behavior from the mesh
  95555. */
  95556. detach(): void;
  95557. /**
  95558. * Triggers the mesh to begin fading in or out
  95559. * @param value if the object should fade in or out (true to fade in)
  95560. */
  95561. fadeIn(value: boolean): void;
  95562. private _update;
  95563. private _setAllVisibility;
  95564. }
  95565. }
  95566. declare module BABYLON {
  95567. /**
  95568. * Class containing a set of static utilities functions for managing Pivots
  95569. * @hidden
  95570. */
  95571. export class PivotTools {
  95572. private static _PivotCached;
  95573. private static _OldPivotPoint;
  95574. private static _PivotTranslation;
  95575. private static _PivotTmpVector;
  95576. /** @hidden */
  95577. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95578. /** @hidden */
  95579. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95580. }
  95581. }
  95582. declare module BABYLON {
  95583. /**
  95584. * Class containing static functions to help procedurally build meshes
  95585. */
  95586. export class PlaneBuilder {
  95587. /**
  95588. * Creates a plane mesh
  95589. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95590. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95591. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95595. * @param name defines the name of the mesh
  95596. * @param options defines the options used to create the mesh
  95597. * @param scene defines the hosting scene
  95598. * @returns the plane mesh
  95599. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95600. */
  95601. static CreatePlane(name: string, options: {
  95602. size?: number;
  95603. width?: number;
  95604. height?: number;
  95605. sideOrientation?: number;
  95606. frontUVs?: Vector4;
  95607. backUVs?: Vector4;
  95608. updatable?: boolean;
  95609. sourcePlane?: Plane;
  95610. }, scene?: Nullable<Scene>): Mesh;
  95611. }
  95612. }
  95613. declare module BABYLON {
  95614. /**
  95615. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95616. */
  95617. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95618. private static _AnyMouseID;
  95619. private _attachedNode;
  95620. private _dragPlane;
  95621. private _scene;
  95622. private _pointerObserver;
  95623. private _beforeRenderObserver;
  95624. private static _planeScene;
  95625. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95626. /**
  95627. * 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)
  95628. */
  95629. maxDragAngle: number;
  95630. /**
  95631. * @hidden
  95632. */
  95633. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95634. /**
  95635. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95636. */
  95637. currentDraggingPointerID: number;
  95638. /**
  95639. * The last position where the pointer hit the drag plane in world space
  95640. */
  95641. lastDragPosition: Vector3;
  95642. /**
  95643. * If the behavior is currently in a dragging state
  95644. */
  95645. dragging: boolean;
  95646. /**
  95647. * 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)
  95648. */
  95649. dragDeltaRatio: number;
  95650. /**
  95651. * If the drag plane orientation should be updated during the dragging (Default: true)
  95652. */
  95653. updateDragPlane: boolean;
  95654. private _debugMode;
  95655. private _moving;
  95656. /**
  95657. * Fires each time the attached mesh is dragged with the pointer
  95658. * * delta between last drag position and current drag position in world space
  95659. * * dragDistance along the drag axis
  95660. * * dragPlaneNormal normal of the current drag plane used during the drag
  95661. * * dragPlanePoint in world space where the drag intersects the drag plane
  95662. */
  95663. onDragObservable: Observable<{
  95664. delta: Vector3;
  95665. dragPlanePoint: Vector3;
  95666. dragPlaneNormal: Vector3;
  95667. dragDistance: number;
  95668. pointerId: number;
  95669. }>;
  95670. /**
  95671. * Fires each time a drag begins (eg. mouse down on mesh)
  95672. */
  95673. onDragStartObservable: Observable<{
  95674. dragPlanePoint: Vector3;
  95675. pointerId: number;
  95676. }>;
  95677. /**
  95678. * Fires each time a drag ends (eg. mouse release after drag)
  95679. */
  95680. onDragEndObservable: Observable<{
  95681. dragPlanePoint: Vector3;
  95682. pointerId: number;
  95683. }>;
  95684. /**
  95685. * If the attached mesh should be moved when dragged
  95686. */
  95687. moveAttached: boolean;
  95688. /**
  95689. * If the drag behavior will react to drag events (Default: true)
  95690. */
  95691. enabled: boolean;
  95692. /**
  95693. * If camera controls should be detached during the drag
  95694. */
  95695. detachCameraControls: boolean;
  95696. /**
  95697. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95698. */
  95699. useObjectOrienationForDragging: boolean;
  95700. private _options;
  95701. /**
  95702. * Creates a pointer drag behavior that can be attached to a mesh
  95703. * @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)
  95704. */
  95705. constructor(options?: {
  95706. dragAxis?: Vector3;
  95707. dragPlaneNormal?: Vector3;
  95708. });
  95709. /**
  95710. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95711. */
  95712. validateDrag: (targetPosition: Vector3) => boolean;
  95713. /**
  95714. * The name of the behavior
  95715. */
  95716. readonly name: string;
  95717. /**
  95718. * Initializes the behavior
  95719. */
  95720. init(): void;
  95721. private _tmpVector;
  95722. private _alternatePickedPoint;
  95723. private _worldDragAxis;
  95724. private _targetPosition;
  95725. private _attachedElement;
  95726. /**
  95727. * Attaches the drag behavior the passed in mesh
  95728. * @param ownerNode The mesh that will be dragged around once attached
  95729. */
  95730. attach(ownerNode: AbstractMesh): void;
  95731. /**
  95732. * Force relase the drag action by code.
  95733. */
  95734. releaseDrag(): void;
  95735. private _startDragRay;
  95736. private _lastPointerRay;
  95737. /**
  95738. * Simulates the start of a pointer drag event on the behavior
  95739. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95740. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95741. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95742. */
  95743. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95744. private _startDrag;
  95745. private _dragDelta;
  95746. private _moveDrag;
  95747. private _pickWithRayOnDragPlane;
  95748. private _pointA;
  95749. private _pointB;
  95750. private _pointC;
  95751. private _lineA;
  95752. private _lineB;
  95753. private _localAxis;
  95754. private _lookAt;
  95755. private _updateDragPlanePosition;
  95756. /**
  95757. * Detaches the behavior from the mesh
  95758. */
  95759. detach(): void;
  95760. }
  95761. }
  95762. declare module BABYLON {
  95763. /**
  95764. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95765. */
  95766. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95767. private _dragBehaviorA;
  95768. private _dragBehaviorB;
  95769. private _startDistance;
  95770. private _initialScale;
  95771. private _targetScale;
  95772. private _ownerNode;
  95773. private _sceneRenderObserver;
  95774. /**
  95775. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95776. */
  95777. constructor();
  95778. /**
  95779. * The name of the behavior
  95780. */
  95781. readonly name: string;
  95782. /**
  95783. * Initializes the behavior
  95784. */
  95785. init(): void;
  95786. private _getCurrentDistance;
  95787. /**
  95788. * Attaches the scale behavior the passed in mesh
  95789. * @param ownerNode The mesh that will be scaled around once attached
  95790. */
  95791. attach(ownerNode: Mesh): void;
  95792. /**
  95793. * Detaches the behavior from the mesh
  95794. */
  95795. detach(): void;
  95796. }
  95797. }
  95798. declare module BABYLON {
  95799. /**
  95800. * 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
  95801. */
  95802. export class SixDofDragBehavior implements Behavior<Mesh> {
  95803. private static _virtualScene;
  95804. private _ownerNode;
  95805. private _sceneRenderObserver;
  95806. private _scene;
  95807. private _targetPosition;
  95808. private _virtualOriginMesh;
  95809. private _virtualDragMesh;
  95810. private _pointerObserver;
  95811. private _moving;
  95812. private _startingOrientation;
  95813. /**
  95814. * 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)
  95815. */
  95816. private zDragFactor;
  95817. /**
  95818. * If the object should rotate to face the drag origin
  95819. */
  95820. rotateDraggedObject: boolean;
  95821. /**
  95822. * If the behavior is currently in a dragging state
  95823. */
  95824. dragging: boolean;
  95825. /**
  95826. * 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)
  95827. */
  95828. dragDeltaRatio: number;
  95829. /**
  95830. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95831. */
  95832. currentDraggingPointerID: number;
  95833. /**
  95834. * If camera controls should be detached during the drag
  95835. */
  95836. detachCameraControls: boolean;
  95837. /**
  95838. * Fires each time a drag starts
  95839. */
  95840. onDragStartObservable: Observable<{}>;
  95841. /**
  95842. * Fires each time a drag ends (eg. mouse release after drag)
  95843. */
  95844. onDragEndObservable: Observable<{}>;
  95845. /**
  95846. * 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
  95847. */
  95848. constructor();
  95849. /**
  95850. * The name of the behavior
  95851. */
  95852. readonly name: string;
  95853. /**
  95854. * Initializes the behavior
  95855. */
  95856. init(): void;
  95857. /**
  95858. * Attaches the scale behavior the passed in mesh
  95859. * @param ownerNode The mesh that will be scaled around once attached
  95860. */
  95861. attach(ownerNode: Mesh): void;
  95862. /**
  95863. * Detaches the behavior from the mesh
  95864. */
  95865. detach(): void;
  95866. }
  95867. }
  95868. declare module BABYLON {
  95869. /**
  95870. * Class used to apply inverse kinematics to bones
  95871. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95872. */
  95873. export class BoneIKController {
  95874. private static _tmpVecs;
  95875. private static _tmpQuat;
  95876. private static _tmpMats;
  95877. /**
  95878. * Gets or sets the target mesh
  95879. */
  95880. targetMesh: AbstractMesh;
  95881. /** Gets or sets the mesh used as pole */
  95882. poleTargetMesh: AbstractMesh;
  95883. /**
  95884. * Gets or sets the bone used as pole
  95885. */
  95886. poleTargetBone: Nullable<Bone>;
  95887. /**
  95888. * Gets or sets the target position
  95889. */
  95890. targetPosition: Vector3;
  95891. /**
  95892. * Gets or sets the pole target position
  95893. */
  95894. poleTargetPosition: Vector3;
  95895. /**
  95896. * Gets or sets the pole target local offset
  95897. */
  95898. poleTargetLocalOffset: Vector3;
  95899. /**
  95900. * Gets or sets the pole angle
  95901. */
  95902. poleAngle: number;
  95903. /**
  95904. * Gets or sets the mesh associated with the controller
  95905. */
  95906. mesh: AbstractMesh;
  95907. /**
  95908. * 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)
  95909. */
  95910. slerpAmount: number;
  95911. private _bone1Quat;
  95912. private _bone1Mat;
  95913. private _bone2Ang;
  95914. private _bone1;
  95915. private _bone2;
  95916. private _bone1Length;
  95917. private _bone2Length;
  95918. private _maxAngle;
  95919. private _maxReach;
  95920. private _rightHandedSystem;
  95921. private _bendAxis;
  95922. private _slerping;
  95923. private _adjustRoll;
  95924. /**
  95925. * Gets or sets maximum allowed angle
  95926. */
  95927. maxAngle: number;
  95928. /**
  95929. * Creates a new BoneIKController
  95930. * @param mesh defines the mesh to control
  95931. * @param bone defines the bone to control
  95932. * @param options defines options to set up the controller
  95933. */
  95934. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95935. targetMesh?: AbstractMesh;
  95936. poleTargetMesh?: AbstractMesh;
  95937. poleTargetBone?: Bone;
  95938. poleTargetLocalOffset?: Vector3;
  95939. poleAngle?: number;
  95940. bendAxis?: Vector3;
  95941. maxAngle?: number;
  95942. slerpAmount?: number;
  95943. });
  95944. private _setMaxAngle;
  95945. /**
  95946. * Force the controller to update the bones
  95947. */
  95948. update(): void;
  95949. }
  95950. }
  95951. declare module BABYLON {
  95952. /**
  95953. * Class used to make a bone look toward a point in space
  95954. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95955. */
  95956. export class BoneLookController {
  95957. private static _tmpVecs;
  95958. private static _tmpQuat;
  95959. private static _tmpMats;
  95960. /**
  95961. * The target Vector3 that the bone will look at
  95962. */
  95963. target: Vector3;
  95964. /**
  95965. * The mesh that the bone is attached to
  95966. */
  95967. mesh: AbstractMesh;
  95968. /**
  95969. * The bone that will be looking to the target
  95970. */
  95971. bone: Bone;
  95972. /**
  95973. * The up axis of the coordinate system that is used when the bone is rotated
  95974. */
  95975. upAxis: Vector3;
  95976. /**
  95977. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95978. */
  95979. upAxisSpace: Space;
  95980. /**
  95981. * Used to make an adjustment to the yaw of the bone
  95982. */
  95983. adjustYaw: number;
  95984. /**
  95985. * Used to make an adjustment to the pitch of the bone
  95986. */
  95987. adjustPitch: number;
  95988. /**
  95989. * Used to make an adjustment to the roll of the bone
  95990. */
  95991. adjustRoll: number;
  95992. /**
  95993. * 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)
  95994. */
  95995. slerpAmount: number;
  95996. private _minYaw;
  95997. private _maxYaw;
  95998. private _minPitch;
  95999. private _maxPitch;
  96000. private _minYawSin;
  96001. private _minYawCos;
  96002. private _maxYawSin;
  96003. private _maxYawCos;
  96004. private _midYawConstraint;
  96005. private _minPitchTan;
  96006. private _maxPitchTan;
  96007. private _boneQuat;
  96008. private _slerping;
  96009. private _transformYawPitch;
  96010. private _transformYawPitchInv;
  96011. private _firstFrameSkipped;
  96012. private _yawRange;
  96013. private _fowardAxis;
  96014. /**
  96015. * Gets or sets the minimum yaw angle that the bone can look to
  96016. */
  96017. minYaw: number;
  96018. /**
  96019. * Gets or sets the maximum yaw angle that the bone can look to
  96020. */
  96021. maxYaw: number;
  96022. /**
  96023. * Gets or sets the minimum pitch angle that the bone can look to
  96024. */
  96025. minPitch: number;
  96026. /**
  96027. * Gets or sets the maximum pitch angle that the bone can look to
  96028. */
  96029. maxPitch: number;
  96030. /**
  96031. * Create a BoneLookController
  96032. * @param mesh the mesh that the bone belongs to
  96033. * @param bone the bone that will be looking to the target
  96034. * @param target the target Vector3 to look at
  96035. * @param options optional settings:
  96036. * * maxYaw: the maximum angle the bone will yaw to
  96037. * * minYaw: the minimum angle the bone will yaw to
  96038. * * maxPitch: the maximum angle the bone will pitch to
  96039. * * minPitch: the minimum angle the bone will yaw to
  96040. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  96041. * * upAxis: the up axis of the coordinate system
  96042. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  96043. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  96044. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  96045. * * adjustYaw: used to make an adjustment to the yaw of the bone
  96046. * * adjustPitch: used to make an adjustment to the pitch of the bone
  96047. * * adjustRoll: used to make an adjustment to the roll of the bone
  96048. **/
  96049. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  96050. maxYaw?: number;
  96051. minYaw?: number;
  96052. maxPitch?: number;
  96053. minPitch?: number;
  96054. slerpAmount?: number;
  96055. upAxis?: Vector3;
  96056. upAxisSpace?: Space;
  96057. yawAxis?: Vector3;
  96058. pitchAxis?: Vector3;
  96059. adjustYaw?: number;
  96060. adjustPitch?: number;
  96061. adjustRoll?: number;
  96062. });
  96063. /**
  96064. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  96065. */
  96066. update(): void;
  96067. private _getAngleDiff;
  96068. private _getAngleBetween;
  96069. private _isAngleBetween;
  96070. }
  96071. }
  96072. declare module BABYLON {
  96073. /**
  96074. * Manage the gamepad inputs to control an arc rotate camera.
  96075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96076. */
  96077. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  96078. /**
  96079. * Defines the camera the input is attached to.
  96080. */
  96081. camera: ArcRotateCamera;
  96082. /**
  96083. * Defines the gamepad the input is gathering event from.
  96084. */
  96085. gamepad: Nullable<Gamepad>;
  96086. /**
  96087. * Defines the gamepad rotation sensiblity.
  96088. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96089. */
  96090. gamepadRotationSensibility: number;
  96091. /**
  96092. * Defines the gamepad move sensiblity.
  96093. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96094. */
  96095. gamepadMoveSensibility: number;
  96096. private _onGamepadConnectedObserver;
  96097. private _onGamepadDisconnectedObserver;
  96098. /**
  96099. * Attach the input controls to a specific dom element to get the input from.
  96100. * @param element Defines the element the controls should be listened from
  96101. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96102. */
  96103. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96104. /**
  96105. * Detach the current controls from the specified dom element.
  96106. * @param element Defines the element to stop listening the inputs from
  96107. */
  96108. detachControl(element: Nullable<HTMLElement>): void;
  96109. /**
  96110. * Update the current camera state depending on the inputs that have been used this frame.
  96111. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96112. */
  96113. checkInputs(): void;
  96114. /**
  96115. * Gets the class name of the current intput.
  96116. * @returns the class name
  96117. */
  96118. getClassName(): string;
  96119. /**
  96120. * Get the friendly name associated with the input class.
  96121. * @returns the input friendly name
  96122. */
  96123. getSimpleName(): string;
  96124. }
  96125. }
  96126. declare module BABYLON {
  96127. interface ArcRotateCameraInputsManager {
  96128. /**
  96129. * Add orientation input support to the input manager.
  96130. * @returns the current input manager
  96131. */
  96132. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  96133. }
  96134. /**
  96135. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  96136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96137. */
  96138. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  96139. /**
  96140. * Defines the camera the input is attached to.
  96141. */
  96142. camera: ArcRotateCamera;
  96143. /**
  96144. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  96145. */
  96146. alphaCorrection: number;
  96147. /**
  96148. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  96149. */
  96150. gammaCorrection: number;
  96151. private _alpha;
  96152. private _gamma;
  96153. private _dirty;
  96154. private _deviceOrientationHandler;
  96155. /**
  96156. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  96157. */
  96158. constructor();
  96159. /**
  96160. * Attach the input controls to a specific dom element to get the input from.
  96161. * @param element Defines the element the controls should be listened from
  96162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96163. */
  96164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96165. /** @hidden */
  96166. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  96167. /**
  96168. * Update the current camera state depending on the inputs that have been used this frame.
  96169. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96170. */
  96171. checkInputs(): void;
  96172. /**
  96173. * Detach the current controls from the specified dom element.
  96174. * @param element Defines the element to stop listening the inputs from
  96175. */
  96176. detachControl(element: Nullable<HTMLElement>): void;
  96177. /**
  96178. * Gets the class name of the current intput.
  96179. * @returns the class name
  96180. */
  96181. getClassName(): string;
  96182. /**
  96183. * Get the friendly name associated with the input class.
  96184. * @returns the input friendly name
  96185. */
  96186. getSimpleName(): string;
  96187. }
  96188. }
  96189. declare module BABYLON {
  96190. /**
  96191. * Listen to mouse events to control the camera.
  96192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96193. */
  96194. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  96195. /**
  96196. * Defines the camera the input is attached to.
  96197. */
  96198. camera: FlyCamera;
  96199. /**
  96200. * Defines if touch is enabled. (Default is true.)
  96201. */
  96202. touchEnabled: boolean;
  96203. /**
  96204. * Defines the buttons associated with the input to handle camera rotation.
  96205. */
  96206. buttons: number[];
  96207. /**
  96208. * Assign buttons for Yaw control.
  96209. */
  96210. buttonsYaw: number[];
  96211. /**
  96212. * Assign buttons for Pitch control.
  96213. */
  96214. buttonsPitch: number[];
  96215. /**
  96216. * Assign buttons for Roll control.
  96217. */
  96218. buttonsRoll: number[];
  96219. /**
  96220. * Detect if any button is being pressed while mouse is moved.
  96221. * -1 = Mouse locked.
  96222. * 0 = Left button.
  96223. * 1 = Middle Button.
  96224. * 2 = Right Button.
  96225. */
  96226. activeButton: number;
  96227. /**
  96228. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  96229. * Higher values reduce its sensitivity.
  96230. */
  96231. angularSensibility: number;
  96232. private _mousemoveCallback;
  96233. private _observer;
  96234. private _rollObserver;
  96235. private previousPosition;
  96236. private noPreventDefault;
  96237. private element;
  96238. /**
  96239. * Listen to mouse events to control the camera.
  96240. * @param touchEnabled Define if touch is enabled. (Default is true.)
  96241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96242. */
  96243. constructor(touchEnabled?: boolean);
  96244. /**
  96245. * Attach the mouse control to the HTML DOM element.
  96246. * @param element Defines the element that listens to the input events.
  96247. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  96248. */
  96249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96250. /**
  96251. * Detach the current controls from the specified dom element.
  96252. * @param element Defines the element to stop listening the inputs from
  96253. */
  96254. detachControl(element: Nullable<HTMLElement>): void;
  96255. /**
  96256. * Gets the class name of the current input.
  96257. * @returns the class name.
  96258. */
  96259. getClassName(): string;
  96260. /**
  96261. * Get the friendly name associated with the input class.
  96262. * @returns the input's friendly name.
  96263. */
  96264. getSimpleName(): string;
  96265. private _pointerInput;
  96266. private _onMouseMove;
  96267. /**
  96268. * Rotate camera by mouse offset.
  96269. */
  96270. private rotateCamera;
  96271. }
  96272. }
  96273. declare module BABYLON {
  96274. /**
  96275. * Default Inputs manager for the FlyCamera.
  96276. * It groups all the default supported inputs for ease of use.
  96277. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96278. */
  96279. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  96280. /**
  96281. * Instantiates a new FlyCameraInputsManager.
  96282. * @param camera Defines the camera the inputs belong to.
  96283. */
  96284. constructor(camera: FlyCamera);
  96285. /**
  96286. * Add keyboard input support to the input manager.
  96287. * @returns the new FlyCameraKeyboardMoveInput().
  96288. */
  96289. addKeyboard(): FlyCameraInputsManager;
  96290. /**
  96291. * Add mouse input support to the input manager.
  96292. * @param touchEnabled Enable touch screen support.
  96293. * @returns the new FlyCameraMouseInput().
  96294. */
  96295. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  96296. }
  96297. }
  96298. declare module BABYLON {
  96299. /**
  96300. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96301. * such as in a 3D Space Shooter or a Flight Simulator.
  96302. */
  96303. export class FlyCamera extends TargetCamera {
  96304. /**
  96305. * Define the collision ellipsoid of the camera.
  96306. * This is helpful for simulating a camera body, like a player's body.
  96307. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96308. */
  96309. ellipsoid: Vector3;
  96310. /**
  96311. * Define an offset for the position of the ellipsoid around the camera.
  96312. * This can be helpful if the camera is attached away from the player's body center,
  96313. * such as at its head.
  96314. */
  96315. ellipsoidOffset: Vector3;
  96316. /**
  96317. * Enable or disable collisions of the camera with the rest of the scene objects.
  96318. */
  96319. checkCollisions: boolean;
  96320. /**
  96321. * Enable or disable gravity on the camera.
  96322. */
  96323. applyGravity: boolean;
  96324. /**
  96325. * Define the current direction the camera is moving to.
  96326. */
  96327. cameraDirection: Vector3;
  96328. /**
  96329. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  96330. * This overrides and empties cameraRotation.
  96331. */
  96332. rotationQuaternion: Quaternion;
  96333. /**
  96334. * Track Roll to maintain the wanted Rolling when looking around.
  96335. */
  96336. _trackRoll: number;
  96337. /**
  96338. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  96339. */
  96340. rollCorrect: number;
  96341. /**
  96342. * Mimic a banked turn, Rolling the camera when Yawing.
  96343. * It's recommended to use rollCorrect = 10 for faster banking correction.
  96344. */
  96345. bankedTurn: boolean;
  96346. /**
  96347. * Limit in radians for how much Roll banking will add. (Default: 90°)
  96348. */
  96349. bankedTurnLimit: number;
  96350. /**
  96351. * Value of 0 disables the banked Roll.
  96352. * Value of 1 is equal to the Yaw angle in radians.
  96353. */
  96354. bankedTurnMultiplier: number;
  96355. /**
  96356. * The inputs manager loads all the input sources, such as keyboard and mouse.
  96357. */
  96358. inputs: FlyCameraInputsManager;
  96359. /**
  96360. * Gets the input sensibility for mouse input.
  96361. * Higher values reduce sensitivity.
  96362. */
  96363. /**
  96364. * Sets the input sensibility for a mouse input.
  96365. * Higher values reduce sensitivity.
  96366. */
  96367. angularSensibility: number;
  96368. /**
  96369. * Get the keys for camera movement forward.
  96370. */
  96371. /**
  96372. * Set the keys for camera movement forward.
  96373. */
  96374. keysForward: number[];
  96375. /**
  96376. * Get the keys for camera movement backward.
  96377. */
  96378. keysBackward: number[];
  96379. /**
  96380. * Get the keys for camera movement up.
  96381. */
  96382. /**
  96383. * Set the keys for camera movement up.
  96384. */
  96385. keysUp: number[];
  96386. /**
  96387. * Get the keys for camera movement down.
  96388. */
  96389. /**
  96390. * Set the keys for camera movement down.
  96391. */
  96392. keysDown: number[];
  96393. /**
  96394. * Get the keys for camera movement left.
  96395. */
  96396. /**
  96397. * Set the keys for camera movement left.
  96398. */
  96399. keysLeft: number[];
  96400. /**
  96401. * Set the keys for camera movement right.
  96402. */
  96403. /**
  96404. * Set the keys for camera movement right.
  96405. */
  96406. keysRight: number[];
  96407. /**
  96408. * Event raised when the camera collides with a mesh in the scene.
  96409. */
  96410. onCollide: (collidedMesh: AbstractMesh) => void;
  96411. private _collider;
  96412. private _needMoveForGravity;
  96413. private _oldPosition;
  96414. private _diffPosition;
  96415. private _newPosition;
  96416. /** @hidden */
  96417. _localDirection: Vector3;
  96418. /** @hidden */
  96419. _transformedDirection: Vector3;
  96420. /**
  96421. * Instantiates a FlyCamera.
  96422. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96423. * such as in a 3D Space Shooter or a Flight Simulator.
  96424. * @param name Define the name of the camera in the scene.
  96425. * @param position Define the starting position of the camera in the scene.
  96426. * @param scene Define the scene the camera belongs to.
  96427. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  96428. */
  96429. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96430. /**
  96431. * Attach a control to the HTML DOM element.
  96432. * @param element Defines the element that listens to the input events.
  96433. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  96434. */
  96435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96436. /**
  96437. * Detach a control from the HTML DOM element.
  96438. * The camera will stop reacting to that input.
  96439. * @param element Defines the element that listens to the input events.
  96440. */
  96441. detachControl(element: HTMLElement): void;
  96442. private _collisionMask;
  96443. /**
  96444. * Get the mask that the camera ignores in collision events.
  96445. */
  96446. /**
  96447. * Set the mask that the camera ignores in collision events.
  96448. */
  96449. collisionMask: number;
  96450. /** @hidden */
  96451. _collideWithWorld(displacement: Vector3): void;
  96452. /** @hidden */
  96453. private _onCollisionPositionChange;
  96454. /** @hidden */
  96455. _checkInputs(): void;
  96456. /** @hidden */
  96457. _decideIfNeedsToMove(): boolean;
  96458. /** @hidden */
  96459. _updatePosition(): void;
  96460. /**
  96461. * Restore the Roll to its target value at the rate specified.
  96462. * @param rate - Higher means slower restoring.
  96463. * @hidden
  96464. */
  96465. restoreRoll(rate: number): void;
  96466. /**
  96467. * Destroy the camera and release the current resources held by it.
  96468. */
  96469. dispose(): void;
  96470. /**
  96471. * Get the current object class name.
  96472. * @returns the class name.
  96473. */
  96474. getClassName(): string;
  96475. }
  96476. }
  96477. declare module BABYLON {
  96478. /**
  96479. * Listen to keyboard events to control the camera.
  96480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96481. */
  96482. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  96483. /**
  96484. * Defines the camera the input is attached to.
  96485. */
  96486. camera: FlyCamera;
  96487. /**
  96488. * The list of keyboard keys used to control the forward move of the camera.
  96489. */
  96490. keysForward: number[];
  96491. /**
  96492. * The list of keyboard keys used to control the backward move of the camera.
  96493. */
  96494. keysBackward: number[];
  96495. /**
  96496. * The list of keyboard keys used to control the forward move of the camera.
  96497. */
  96498. keysUp: number[];
  96499. /**
  96500. * The list of keyboard keys used to control the backward move of the camera.
  96501. */
  96502. keysDown: number[];
  96503. /**
  96504. * The list of keyboard keys used to control the right strafe move of the camera.
  96505. */
  96506. keysRight: number[];
  96507. /**
  96508. * The list of keyboard keys used to control the left strafe move of the camera.
  96509. */
  96510. keysLeft: number[];
  96511. private _keys;
  96512. private _onCanvasBlurObserver;
  96513. private _onKeyboardObserver;
  96514. private _engine;
  96515. private _scene;
  96516. /**
  96517. * Attach the input controls to a specific dom element to get the input from.
  96518. * @param element Defines the element the controls should be listened from
  96519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96520. */
  96521. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96522. /**
  96523. * Detach the current controls from the specified dom element.
  96524. * @param element Defines the element to stop listening the inputs from
  96525. */
  96526. detachControl(element: Nullable<HTMLElement>): void;
  96527. /**
  96528. * Gets the class name of the current intput.
  96529. * @returns the class name
  96530. */
  96531. getClassName(): string;
  96532. /** @hidden */
  96533. _onLostFocus(e: FocusEvent): void;
  96534. /**
  96535. * Get the friendly name associated with the input class.
  96536. * @returns the input friendly name
  96537. */
  96538. getSimpleName(): string;
  96539. /**
  96540. * Update the current camera state depending on the inputs that have been used this frame.
  96541. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96542. */
  96543. checkInputs(): void;
  96544. }
  96545. }
  96546. declare module BABYLON {
  96547. /**
  96548. * Manage the mouse wheel inputs to control a follow camera.
  96549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96550. */
  96551. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96552. /**
  96553. * Defines the camera the input is attached to.
  96554. */
  96555. camera: FollowCamera;
  96556. /**
  96557. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96558. */
  96559. axisControlRadius: boolean;
  96560. /**
  96561. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96562. */
  96563. axisControlHeight: boolean;
  96564. /**
  96565. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96566. */
  96567. axisControlRotation: boolean;
  96568. /**
  96569. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96570. * relation to mouseWheel events.
  96571. */
  96572. wheelPrecision: number;
  96573. /**
  96574. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96575. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96576. */
  96577. wheelDeltaPercentage: number;
  96578. private _wheel;
  96579. private _observer;
  96580. /**
  96581. * Attach the input controls to a specific dom element to get the input from.
  96582. * @param element Defines the element the controls should be listened from
  96583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96584. */
  96585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96586. /**
  96587. * Detach the current controls from the specified dom element.
  96588. * @param element Defines the element to stop listening the inputs from
  96589. */
  96590. detachControl(element: Nullable<HTMLElement>): void;
  96591. /**
  96592. * Gets the class name of the current intput.
  96593. * @returns the class name
  96594. */
  96595. getClassName(): string;
  96596. /**
  96597. * Get the friendly name associated with the input class.
  96598. * @returns the input friendly name
  96599. */
  96600. getSimpleName(): string;
  96601. }
  96602. }
  96603. declare module BABYLON {
  96604. /**
  96605. * Manage the pointers inputs to control an follow camera.
  96606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96607. */
  96608. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96609. /**
  96610. * Defines the camera the input is attached to.
  96611. */
  96612. camera: FollowCamera;
  96613. /**
  96614. * Gets the class name of the current input.
  96615. * @returns the class name
  96616. */
  96617. getClassName(): string;
  96618. /**
  96619. * Defines the pointer angular sensibility along the X axis or how fast is
  96620. * the camera rotating.
  96621. * A negative number will reverse the axis direction.
  96622. */
  96623. angularSensibilityX: number;
  96624. /**
  96625. * Defines the pointer angular sensibility along the Y axis or how fast is
  96626. * the camera rotating.
  96627. * A negative number will reverse the axis direction.
  96628. */
  96629. angularSensibilityY: number;
  96630. /**
  96631. * Defines the pointer pinch precision or how fast is the camera zooming.
  96632. * A negative number will reverse the axis direction.
  96633. */
  96634. pinchPrecision: number;
  96635. /**
  96636. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96637. * from 0.
  96638. * It defines the percentage of current camera.radius to use as delta when
  96639. * pinch zoom is used.
  96640. */
  96641. pinchDeltaPercentage: number;
  96642. /**
  96643. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96644. */
  96645. axisXControlRadius: boolean;
  96646. /**
  96647. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96648. */
  96649. axisXControlHeight: boolean;
  96650. /**
  96651. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96652. */
  96653. axisXControlRotation: boolean;
  96654. /**
  96655. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96656. */
  96657. axisYControlRadius: boolean;
  96658. /**
  96659. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96660. */
  96661. axisYControlHeight: boolean;
  96662. /**
  96663. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96664. */
  96665. axisYControlRotation: boolean;
  96666. /**
  96667. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96668. */
  96669. axisPinchControlRadius: boolean;
  96670. /**
  96671. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96672. */
  96673. axisPinchControlHeight: boolean;
  96674. /**
  96675. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96676. */
  96677. axisPinchControlRotation: boolean;
  96678. /**
  96679. * Log error messages if basic misconfiguration has occurred.
  96680. */
  96681. warningEnable: boolean;
  96682. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96683. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96684. private _warningCounter;
  96685. private _warning;
  96686. }
  96687. }
  96688. declare module BABYLON {
  96689. /**
  96690. * Default Inputs manager for the FollowCamera.
  96691. * It groups all the default supported inputs for ease of use.
  96692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96693. */
  96694. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96695. /**
  96696. * Instantiates a new FollowCameraInputsManager.
  96697. * @param camera Defines the camera the inputs belong to
  96698. */
  96699. constructor(camera: FollowCamera);
  96700. /**
  96701. * Add keyboard input support to the input manager.
  96702. * @returns the current input manager
  96703. */
  96704. addKeyboard(): FollowCameraInputsManager;
  96705. /**
  96706. * Add mouse wheel input support to the input manager.
  96707. * @returns the current input manager
  96708. */
  96709. addMouseWheel(): FollowCameraInputsManager;
  96710. /**
  96711. * Add pointers input support to the input manager.
  96712. * @returns the current input manager
  96713. */
  96714. addPointers(): FollowCameraInputsManager;
  96715. /**
  96716. * Add orientation input support to the input manager.
  96717. * @returns the current input manager
  96718. */
  96719. addVRDeviceOrientation(): FollowCameraInputsManager;
  96720. }
  96721. }
  96722. declare module BABYLON {
  96723. /**
  96724. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96725. * an arc rotate version arcFollowCamera are available.
  96726. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96727. */
  96728. export class FollowCamera extends TargetCamera {
  96729. /**
  96730. * Distance the follow camera should follow an object at
  96731. */
  96732. radius: number;
  96733. /**
  96734. * Minimum allowed distance of the camera to the axis of rotation
  96735. * (The camera can not get closer).
  96736. * This can help limiting how the Camera is able to move in the scene.
  96737. */
  96738. lowerRadiusLimit: Nullable<number>;
  96739. /**
  96740. * Maximum allowed distance of the camera to the axis of rotation
  96741. * (The camera can not get further).
  96742. * This can help limiting how the Camera is able to move in the scene.
  96743. */
  96744. upperRadiusLimit: Nullable<number>;
  96745. /**
  96746. * Define a rotation offset between the camera and the object it follows
  96747. */
  96748. rotationOffset: number;
  96749. /**
  96750. * Minimum allowed angle to camera position relative to target object.
  96751. * This can help limiting how the Camera is able to move in the scene.
  96752. */
  96753. lowerRotationOffsetLimit: Nullable<number>;
  96754. /**
  96755. * Maximum allowed angle to camera position relative to target object.
  96756. * This can help limiting how the Camera is able to move in the scene.
  96757. */
  96758. upperRotationOffsetLimit: Nullable<number>;
  96759. /**
  96760. * Define a height offset between the camera and the object it follows.
  96761. * It can help following an object from the top (like a car chaing a plane)
  96762. */
  96763. heightOffset: number;
  96764. /**
  96765. * Minimum allowed height of camera position relative to target object.
  96766. * This can help limiting how the Camera is able to move in the scene.
  96767. */
  96768. lowerHeightOffsetLimit: Nullable<number>;
  96769. /**
  96770. * Maximum allowed height of camera position relative to target object.
  96771. * This can help limiting how the Camera is able to move in the scene.
  96772. */
  96773. upperHeightOffsetLimit: Nullable<number>;
  96774. /**
  96775. * Define how fast the camera can accelerate to follow it s target.
  96776. */
  96777. cameraAcceleration: number;
  96778. /**
  96779. * Define the speed limit of the camera following an object.
  96780. */
  96781. maxCameraSpeed: number;
  96782. /**
  96783. * Define the target of the camera.
  96784. */
  96785. lockedTarget: Nullable<AbstractMesh>;
  96786. /**
  96787. * Defines the input associated with the camera.
  96788. */
  96789. inputs: FollowCameraInputsManager;
  96790. /**
  96791. * Instantiates the follow camera.
  96792. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96793. * @param name Define the name of the camera in the scene
  96794. * @param position Define the position of the camera
  96795. * @param scene Define the scene the camera belong to
  96796. * @param lockedTarget Define the target of the camera
  96797. */
  96798. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96799. private _follow;
  96800. /**
  96801. * Attached controls to the current camera.
  96802. * @param element Defines the element the controls should be listened from
  96803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96804. */
  96805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96806. /**
  96807. * Detach the current controls from the camera.
  96808. * The camera will stop reacting to inputs.
  96809. * @param element Defines the element to stop listening the inputs from
  96810. */
  96811. detachControl(element: HTMLElement): void;
  96812. /** @hidden */
  96813. _checkInputs(): void;
  96814. private _checkLimits;
  96815. /**
  96816. * Gets the camera class name.
  96817. * @returns the class name
  96818. */
  96819. getClassName(): string;
  96820. }
  96821. /**
  96822. * Arc Rotate version of the follow camera.
  96823. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96824. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96825. */
  96826. export class ArcFollowCamera extends TargetCamera {
  96827. /** The longitudinal angle of the camera */
  96828. alpha: number;
  96829. /** The latitudinal angle of the camera */
  96830. beta: number;
  96831. /** The radius of the camera from its target */
  96832. radius: number;
  96833. /** Define the camera target (the messh it should follow) */
  96834. target: Nullable<AbstractMesh>;
  96835. private _cartesianCoordinates;
  96836. /**
  96837. * Instantiates a new ArcFollowCamera
  96838. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96839. * @param name Define the name of the camera
  96840. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96841. * @param beta Define the rotation angle of the camera around the elevation axis
  96842. * @param radius Define the radius of the camera from its target point
  96843. * @param target Define the target of the camera
  96844. * @param scene Define the scene the camera belongs to
  96845. */
  96846. constructor(name: string,
  96847. /** The longitudinal angle of the camera */
  96848. alpha: number,
  96849. /** The latitudinal angle of the camera */
  96850. beta: number,
  96851. /** The radius of the camera from its target */
  96852. radius: number,
  96853. /** Define the camera target (the messh it should follow) */
  96854. target: Nullable<AbstractMesh>, scene: Scene);
  96855. private _follow;
  96856. /** @hidden */
  96857. _checkInputs(): void;
  96858. /**
  96859. * Returns the class name of the object.
  96860. * It is mostly used internally for serialization purposes.
  96861. */
  96862. getClassName(): string;
  96863. }
  96864. }
  96865. declare module BABYLON {
  96866. /**
  96867. * Manage the keyboard inputs to control the movement of a follow camera.
  96868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96869. */
  96870. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96871. /**
  96872. * Defines the camera the input is attached to.
  96873. */
  96874. camera: FollowCamera;
  96875. /**
  96876. * Defines the list of key codes associated with the up action (increase heightOffset)
  96877. */
  96878. keysHeightOffsetIncr: number[];
  96879. /**
  96880. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96881. */
  96882. keysHeightOffsetDecr: number[];
  96883. /**
  96884. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96885. */
  96886. keysHeightOffsetModifierAlt: boolean;
  96887. /**
  96888. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96889. */
  96890. keysHeightOffsetModifierCtrl: boolean;
  96891. /**
  96892. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96893. */
  96894. keysHeightOffsetModifierShift: boolean;
  96895. /**
  96896. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96897. */
  96898. keysRotationOffsetIncr: number[];
  96899. /**
  96900. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96901. */
  96902. keysRotationOffsetDecr: number[];
  96903. /**
  96904. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96905. */
  96906. keysRotationOffsetModifierAlt: boolean;
  96907. /**
  96908. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96909. */
  96910. keysRotationOffsetModifierCtrl: boolean;
  96911. /**
  96912. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96913. */
  96914. keysRotationOffsetModifierShift: boolean;
  96915. /**
  96916. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96917. */
  96918. keysRadiusIncr: number[];
  96919. /**
  96920. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96921. */
  96922. keysRadiusDecr: number[];
  96923. /**
  96924. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96925. */
  96926. keysRadiusModifierAlt: boolean;
  96927. /**
  96928. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96929. */
  96930. keysRadiusModifierCtrl: boolean;
  96931. /**
  96932. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96933. */
  96934. keysRadiusModifierShift: boolean;
  96935. /**
  96936. * Defines the rate of change of heightOffset.
  96937. */
  96938. heightSensibility: number;
  96939. /**
  96940. * Defines the rate of change of rotationOffset.
  96941. */
  96942. rotationSensibility: number;
  96943. /**
  96944. * Defines the rate of change of radius.
  96945. */
  96946. radiusSensibility: number;
  96947. private _keys;
  96948. private _ctrlPressed;
  96949. private _altPressed;
  96950. private _shiftPressed;
  96951. private _onCanvasBlurObserver;
  96952. private _onKeyboardObserver;
  96953. private _engine;
  96954. private _scene;
  96955. /**
  96956. * Attach the input controls to a specific dom element to get the input from.
  96957. * @param element Defines the element the controls should be listened from
  96958. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96959. */
  96960. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96961. /**
  96962. * Detach the current controls from the specified dom element.
  96963. * @param element Defines the element to stop listening the inputs from
  96964. */
  96965. detachControl(element: Nullable<HTMLElement>): void;
  96966. /**
  96967. * Update the current camera state depending on the inputs that have been used this frame.
  96968. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96969. */
  96970. checkInputs(): void;
  96971. /**
  96972. * Gets the class name of the current input.
  96973. * @returns the class name
  96974. */
  96975. getClassName(): string;
  96976. /**
  96977. * Get the friendly name associated with the input class.
  96978. * @returns the input friendly name
  96979. */
  96980. getSimpleName(): string;
  96981. /**
  96982. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96983. * allow modification of the heightOffset value.
  96984. */
  96985. private _modifierHeightOffset;
  96986. /**
  96987. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96988. * allow modification of the rotationOffset value.
  96989. */
  96990. private _modifierRotationOffset;
  96991. /**
  96992. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96993. * allow modification of the radius value.
  96994. */
  96995. private _modifierRadius;
  96996. }
  96997. }
  96998. declare module BABYLON {
  96999. interface FreeCameraInputsManager {
  97000. /**
  97001. * @hidden
  97002. */
  97003. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  97004. /**
  97005. * Add orientation input support to the input manager.
  97006. * @returns the current input manager
  97007. */
  97008. addDeviceOrientation(): FreeCameraInputsManager;
  97009. }
  97010. /**
  97011. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  97012. * Screen rotation is taken into account.
  97013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97014. */
  97015. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  97016. private _camera;
  97017. private _screenOrientationAngle;
  97018. private _constantTranform;
  97019. private _screenQuaternion;
  97020. private _alpha;
  97021. private _beta;
  97022. private _gamma;
  97023. /**
  97024. * @hidden
  97025. */
  97026. _onDeviceOrientationChangedObservable: Observable<void>;
  97027. /**
  97028. * Instantiates a new input
  97029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97030. */
  97031. constructor();
  97032. /**
  97033. * Define the camera controlled by the input.
  97034. */
  97035. camera: FreeCamera;
  97036. /**
  97037. * Attach the input controls to a specific dom element to get the input from.
  97038. * @param element Defines the element the controls should be listened from
  97039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97040. */
  97041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97042. private _orientationChanged;
  97043. private _deviceOrientation;
  97044. /**
  97045. * Detach the current controls from the specified dom element.
  97046. * @param element Defines the element to stop listening the inputs from
  97047. */
  97048. detachControl(element: Nullable<HTMLElement>): void;
  97049. /**
  97050. * Update the current camera state depending on the inputs that have been used this frame.
  97051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97052. */
  97053. checkInputs(): void;
  97054. /**
  97055. * Gets the class name of the current intput.
  97056. * @returns the class name
  97057. */
  97058. getClassName(): string;
  97059. /**
  97060. * Get the friendly name associated with the input class.
  97061. * @returns the input friendly name
  97062. */
  97063. getSimpleName(): string;
  97064. }
  97065. }
  97066. declare module BABYLON {
  97067. /**
  97068. * Manage the gamepad inputs to control a free camera.
  97069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97070. */
  97071. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  97072. /**
  97073. * Define the camera the input is attached to.
  97074. */
  97075. camera: FreeCamera;
  97076. /**
  97077. * Define the Gamepad controlling the input
  97078. */
  97079. gamepad: Nullable<Gamepad>;
  97080. /**
  97081. * Defines the gamepad rotation sensiblity.
  97082. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97083. */
  97084. gamepadAngularSensibility: number;
  97085. /**
  97086. * Defines the gamepad move sensiblity.
  97087. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97088. */
  97089. gamepadMoveSensibility: number;
  97090. private _onGamepadConnectedObserver;
  97091. private _onGamepadDisconnectedObserver;
  97092. private _cameraTransform;
  97093. private _deltaTransform;
  97094. private _vector3;
  97095. private _vector2;
  97096. /**
  97097. * Attach the input controls to a specific dom element to get the input from.
  97098. * @param element Defines the element the controls should be listened from
  97099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97100. */
  97101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97102. /**
  97103. * Detach the current controls from the specified dom element.
  97104. * @param element Defines the element to stop listening the inputs from
  97105. */
  97106. detachControl(element: Nullable<HTMLElement>): void;
  97107. /**
  97108. * Update the current camera state depending on the inputs that have been used this frame.
  97109. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97110. */
  97111. checkInputs(): void;
  97112. /**
  97113. * Gets the class name of the current intput.
  97114. * @returns the class name
  97115. */
  97116. getClassName(): string;
  97117. /**
  97118. * Get the friendly name associated with the input class.
  97119. * @returns the input friendly name
  97120. */
  97121. getSimpleName(): string;
  97122. }
  97123. }
  97124. declare module BABYLON {
  97125. /**
  97126. * Defines the potential axis of a Joystick
  97127. */
  97128. export enum JoystickAxis {
  97129. /** X axis */
  97130. X = 0,
  97131. /** Y axis */
  97132. Y = 1,
  97133. /** Z axis */
  97134. Z = 2
  97135. }
  97136. /**
  97137. * Class used to define virtual joystick (used in touch mode)
  97138. */
  97139. export class VirtualJoystick {
  97140. /**
  97141. * Gets or sets a boolean indicating that left and right values must be inverted
  97142. */
  97143. reverseLeftRight: boolean;
  97144. /**
  97145. * Gets or sets a boolean indicating that up and down values must be inverted
  97146. */
  97147. reverseUpDown: boolean;
  97148. /**
  97149. * Gets the offset value for the position (ie. the change of the position value)
  97150. */
  97151. deltaPosition: Vector3;
  97152. /**
  97153. * Gets a boolean indicating if the virtual joystick was pressed
  97154. */
  97155. pressed: boolean;
  97156. /**
  97157. * Canvas the virtual joystick will render onto, default z-index of this is 5
  97158. */
  97159. static Canvas: Nullable<HTMLCanvasElement>;
  97160. private static _globalJoystickIndex;
  97161. private static vjCanvasContext;
  97162. private static vjCanvasWidth;
  97163. private static vjCanvasHeight;
  97164. private static halfWidth;
  97165. private _action;
  97166. private _axisTargetedByLeftAndRight;
  97167. private _axisTargetedByUpAndDown;
  97168. private _joystickSensibility;
  97169. private _inversedSensibility;
  97170. private _joystickPointerID;
  97171. private _joystickColor;
  97172. private _joystickPointerPos;
  97173. private _joystickPreviousPointerPos;
  97174. private _joystickPointerStartPos;
  97175. private _deltaJoystickVector;
  97176. private _leftJoystick;
  97177. private _touches;
  97178. private _onPointerDownHandlerRef;
  97179. private _onPointerMoveHandlerRef;
  97180. private _onPointerUpHandlerRef;
  97181. private _onResize;
  97182. /**
  97183. * Creates a new virtual joystick
  97184. * @param leftJoystick defines that the joystick is for left hand (false by default)
  97185. */
  97186. constructor(leftJoystick?: boolean);
  97187. /**
  97188. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  97189. * @param newJoystickSensibility defines the new sensibility
  97190. */
  97191. setJoystickSensibility(newJoystickSensibility: number): void;
  97192. private _onPointerDown;
  97193. private _onPointerMove;
  97194. private _onPointerUp;
  97195. /**
  97196. * Change the color of the virtual joystick
  97197. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  97198. */
  97199. setJoystickColor(newColor: string): void;
  97200. /**
  97201. * Defines a callback to call when the joystick is touched
  97202. * @param action defines the callback
  97203. */
  97204. setActionOnTouch(action: () => any): void;
  97205. /**
  97206. * Defines which axis you'd like to control for left & right
  97207. * @param axis defines the axis to use
  97208. */
  97209. setAxisForLeftRight(axis: JoystickAxis): void;
  97210. /**
  97211. * Defines which axis you'd like to control for up & down
  97212. * @param axis defines the axis to use
  97213. */
  97214. setAxisForUpDown(axis: JoystickAxis): void;
  97215. private _drawVirtualJoystick;
  97216. /**
  97217. * Release internal HTML canvas
  97218. */
  97219. releaseCanvas(): void;
  97220. }
  97221. }
  97222. declare module BABYLON {
  97223. interface FreeCameraInputsManager {
  97224. /**
  97225. * Add virtual joystick input support to the input manager.
  97226. * @returns the current input manager
  97227. */
  97228. addVirtualJoystick(): FreeCameraInputsManager;
  97229. }
  97230. /**
  97231. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  97232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97233. */
  97234. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  97235. /**
  97236. * Defines the camera the input is attached to.
  97237. */
  97238. camera: FreeCamera;
  97239. private _leftjoystick;
  97240. private _rightjoystick;
  97241. /**
  97242. * Gets the left stick of the virtual joystick.
  97243. * @returns The virtual Joystick
  97244. */
  97245. getLeftJoystick(): VirtualJoystick;
  97246. /**
  97247. * Gets the right stick of the virtual joystick.
  97248. * @returns The virtual Joystick
  97249. */
  97250. getRightJoystick(): VirtualJoystick;
  97251. /**
  97252. * Update the current camera state depending on the inputs that have been used this frame.
  97253. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97254. */
  97255. checkInputs(): void;
  97256. /**
  97257. * Attach the input controls to a specific dom element to get the input from.
  97258. * @param element Defines the element the controls should be listened from
  97259. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97260. */
  97261. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97262. /**
  97263. * Detach the current controls from the specified dom element.
  97264. * @param element Defines the element to stop listening the inputs from
  97265. */
  97266. detachControl(element: Nullable<HTMLElement>): void;
  97267. /**
  97268. * Gets the class name of the current intput.
  97269. * @returns the class name
  97270. */
  97271. getClassName(): string;
  97272. /**
  97273. * Get the friendly name associated with the input class.
  97274. * @returns the input friendly name
  97275. */
  97276. getSimpleName(): string;
  97277. }
  97278. }
  97279. declare module BABYLON {
  97280. /**
  97281. * This represents a FPS type of camera controlled by touch.
  97282. * This is like a universal camera minus the Gamepad controls.
  97283. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97284. */
  97285. export class TouchCamera extends FreeCamera {
  97286. /**
  97287. * Defines the touch sensibility for rotation.
  97288. * The higher the faster.
  97289. */
  97290. touchAngularSensibility: number;
  97291. /**
  97292. * Defines the touch sensibility for move.
  97293. * The higher the faster.
  97294. */
  97295. touchMoveSensibility: number;
  97296. /**
  97297. * Instantiates a new touch camera.
  97298. * This represents a FPS type of camera controlled by touch.
  97299. * This is like a universal camera minus the Gamepad controls.
  97300. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97301. * @param name Define the name of the camera in the scene
  97302. * @param position Define the start position of the camera in the scene
  97303. * @param scene Define the scene the camera belongs to
  97304. */
  97305. constructor(name: string, position: Vector3, scene: Scene);
  97306. /**
  97307. * Gets the current object class name.
  97308. * @return the class name
  97309. */
  97310. getClassName(): string;
  97311. /** @hidden */
  97312. _setupInputs(): void;
  97313. }
  97314. }
  97315. declare module BABYLON {
  97316. /**
  97317. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  97318. * being tilted forward or back and left or right.
  97319. */
  97320. export class DeviceOrientationCamera extends FreeCamera {
  97321. private _initialQuaternion;
  97322. private _quaternionCache;
  97323. private _tmpDragQuaternion;
  97324. /**
  97325. * Creates a new device orientation camera
  97326. * @param name The name of the camera
  97327. * @param position The start position camera
  97328. * @param scene The scene the camera belongs to
  97329. */
  97330. constructor(name: string, position: Vector3, scene: Scene);
  97331. /**
  97332. * @hidden
  97333. * Disabled pointer input on first orientation sensor update (Default: true)
  97334. */
  97335. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  97336. private _dragFactor;
  97337. /**
  97338. * Enabled turning on the y axis when the orientation sensor is active
  97339. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  97340. */
  97341. enableHorizontalDragging(dragFactor?: number): void;
  97342. /**
  97343. * Gets the current instance class name ("DeviceOrientationCamera").
  97344. * This helps avoiding instanceof at run time.
  97345. * @returns the class name
  97346. */
  97347. getClassName(): string;
  97348. /**
  97349. * @hidden
  97350. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  97351. */
  97352. _checkInputs(): void;
  97353. /**
  97354. * Reset the camera to its default orientation on the specified axis only.
  97355. * @param axis The axis to reset
  97356. */
  97357. resetToCurrentRotation(axis?: Axis): void;
  97358. }
  97359. }
  97360. declare module BABYLON {
  97361. /**
  97362. * 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,
  97363. * which still works and will still be found in many Playgrounds.
  97364. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97365. */
  97366. export class UniversalCamera extends TouchCamera {
  97367. /**
  97368. * Defines the gamepad rotation sensiblity.
  97369. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97370. */
  97371. gamepadAngularSensibility: number;
  97372. /**
  97373. * Defines the gamepad move sensiblity.
  97374. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97375. */
  97376. gamepadMoveSensibility: number;
  97377. /**
  97378. * 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,
  97379. * which still works and will still be found in many Playgrounds.
  97380. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97381. * @param name Define the name of the camera in the scene
  97382. * @param position Define the start position of the camera in the scene
  97383. * @param scene Define the scene the camera belongs to
  97384. */
  97385. constructor(name: string, position: Vector3, scene: Scene);
  97386. /**
  97387. * Gets the current object class name.
  97388. * @return the class name
  97389. */
  97390. getClassName(): string;
  97391. }
  97392. }
  97393. declare module BABYLON {
  97394. /**
  97395. * This represents a FPS type of camera. This is only here for back compat purpose.
  97396. * Please use the UniversalCamera instead as both are identical.
  97397. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97398. */
  97399. export class GamepadCamera extends UniversalCamera {
  97400. /**
  97401. * Instantiates a new Gamepad Camera
  97402. * This represents a FPS type of camera. This is only here for back compat purpose.
  97403. * Please use the UniversalCamera instead as both are identical.
  97404. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97405. * @param name Define the name of the camera in the scene
  97406. * @param position Define the start position of the camera in the scene
  97407. * @param scene Define the scene the camera belongs to
  97408. */
  97409. constructor(name: string, position: Vector3, scene: Scene);
  97410. /**
  97411. * Gets the current object class name.
  97412. * @return the class name
  97413. */
  97414. getClassName(): string;
  97415. }
  97416. }
  97417. declare module BABYLON {
  97418. /** @hidden */
  97419. export var passPixelShader: {
  97420. name: string;
  97421. shader: string;
  97422. };
  97423. }
  97424. declare module BABYLON {
  97425. /** @hidden */
  97426. export var passCubePixelShader: {
  97427. name: string;
  97428. shader: string;
  97429. };
  97430. }
  97431. declare module BABYLON {
  97432. /**
  97433. * PassPostProcess which produces an output the same as it's input
  97434. */
  97435. export class PassPostProcess extends PostProcess {
  97436. /**
  97437. * Creates the PassPostProcess
  97438. * @param name The name of the effect.
  97439. * @param options The required width/height ratio to downsize to before computing the render pass.
  97440. * @param camera The camera to apply the render pass to.
  97441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97442. * @param engine The engine which the post process will be applied. (default: current engine)
  97443. * @param reusable If the post process can be reused on the same frame. (default: false)
  97444. * @param textureType The type of texture to be used when performing the post processing.
  97445. * @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)
  97446. */
  97447. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97448. }
  97449. /**
  97450. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  97451. */
  97452. export class PassCubePostProcess extends PostProcess {
  97453. private _face;
  97454. /**
  97455. * Gets or sets the cube face to display.
  97456. * * 0 is +X
  97457. * * 1 is -X
  97458. * * 2 is +Y
  97459. * * 3 is -Y
  97460. * * 4 is +Z
  97461. * * 5 is -Z
  97462. */
  97463. face: number;
  97464. /**
  97465. * Creates the PassCubePostProcess
  97466. * @param name The name of the effect.
  97467. * @param options The required width/height ratio to downsize to before computing the render pass.
  97468. * @param camera The camera to apply the render pass to.
  97469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97470. * @param engine The engine which the post process will be applied. (default: current engine)
  97471. * @param reusable If the post process can be reused on the same frame. (default: false)
  97472. * @param textureType The type of texture to be used when performing the post processing.
  97473. * @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)
  97474. */
  97475. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97476. }
  97477. }
  97478. declare module BABYLON {
  97479. /** @hidden */
  97480. export var anaglyphPixelShader: {
  97481. name: string;
  97482. shader: string;
  97483. };
  97484. }
  97485. declare module BABYLON {
  97486. /**
  97487. * Postprocess used to generate anaglyphic rendering
  97488. */
  97489. export class AnaglyphPostProcess extends PostProcess {
  97490. private _passedProcess;
  97491. /**
  97492. * Creates a new AnaglyphPostProcess
  97493. * @param name defines postprocess name
  97494. * @param options defines creation options or target ratio scale
  97495. * @param rigCameras defines cameras using this postprocess
  97496. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  97497. * @param engine defines hosting engine
  97498. * @param reusable defines if the postprocess will be reused multiple times per frame
  97499. */
  97500. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  97501. }
  97502. }
  97503. declare module BABYLON {
  97504. /**
  97505. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  97506. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97507. */
  97508. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  97509. /**
  97510. * Creates a new AnaglyphArcRotateCamera
  97511. * @param name defines camera name
  97512. * @param alpha defines alpha angle (in radians)
  97513. * @param beta defines beta angle (in radians)
  97514. * @param radius defines radius
  97515. * @param target defines camera target
  97516. * @param interaxialDistance defines distance between each color axis
  97517. * @param scene defines the hosting scene
  97518. */
  97519. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  97520. /**
  97521. * Gets camera class name
  97522. * @returns AnaglyphArcRotateCamera
  97523. */
  97524. getClassName(): string;
  97525. }
  97526. }
  97527. declare module BABYLON {
  97528. /**
  97529. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  97530. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97531. */
  97532. export class AnaglyphFreeCamera extends FreeCamera {
  97533. /**
  97534. * Creates a new AnaglyphFreeCamera
  97535. * @param name defines camera name
  97536. * @param position defines initial position
  97537. * @param interaxialDistance defines distance between each color axis
  97538. * @param scene defines the hosting scene
  97539. */
  97540. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97541. /**
  97542. * Gets camera class name
  97543. * @returns AnaglyphFreeCamera
  97544. */
  97545. getClassName(): string;
  97546. }
  97547. }
  97548. declare module BABYLON {
  97549. /**
  97550. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  97551. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97552. */
  97553. export class AnaglyphGamepadCamera extends GamepadCamera {
  97554. /**
  97555. * Creates a new AnaglyphGamepadCamera
  97556. * @param name defines camera name
  97557. * @param position defines initial position
  97558. * @param interaxialDistance defines distance between each color axis
  97559. * @param scene defines the hosting scene
  97560. */
  97561. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97562. /**
  97563. * Gets camera class name
  97564. * @returns AnaglyphGamepadCamera
  97565. */
  97566. getClassName(): string;
  97567. }
  97568. }
  97569. declare module BABYLON {
  97570. /**
  97571. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  97572. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97573. */
  97574. export class AnaglyphUniversalCamera extends UniversalCamera {
  97575. /**
  97576. * Creates a new AnaglyphUniversalCamera
  97577. * @param name defines camera name
  97578. * @param position defines initial position
  97579. * @param interaxialDistance defines distance between each color axis
  97580. * @param scene defines the hosting scene
  97581. */
  97582. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97583. /**
  97584. * Gets camera class name
  97585. * @returns AnaglyphUniversalCamera
  97586. */
  97587. getClassName(): string;
  97588. }
  97589. }
  97590. declare module BABYLON {
  97591. /** @hidden */
  97592. export var stereoscopicInterlacePixelShader: {
  97593. name: string;
  97594. shader: string;
  97595. };
  97596. }
  97597. declare module BABYLON {
  97598. /**
  97599. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  97600. */
  97601. export class StereoscopicInterlacePostProcess extends PostProcess {
  97602. private _stepSize;
  97603. private _passedProcess;
  97604. /**
  97605. * Initializes a StereoscopicInterlacePostProcess
  97606. * @param name The name of the effect.
  97607. * @param rigCameras The rig cameras to be appled to the post process
  97608. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  97609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97610. * @param engine The engine which the post process will be applied. (default: current engine)
  97611. * @param reusable If the post process can be reused on the same frame. (default: false)
  97612. */
  97613. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  97614. }
  97615. }
  97616. declare module BABYLON {
  97617. /**
  97618. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  97619. * @see http://doc.babylonjs.com/features/cameras
  97620. */
  97621. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  97622. /**
  97623. * Creates a new StereoscopicArcRotateCamera
  97624. * @param name defines camera name
  97625. * @param alpha defines alpha angle (in radians)
  97626. * @param beta defines beta angle (in radians)
  97627. * @param radius defines radius
  97628. * @param target defines camera target
  97629. * @param interaxialDistance defines distance between each color axis
  97630. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97631. * @param scene defines the hosting scene
  97632. */
  97633. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97634. /**
  97635. * Gets camera class name
  97636. * @returns StereoscopicArcRotateCamera
  97637. */
  97638. getClassName(): string;
  97639. }
  97640. }
  97641. declare module BABYLON {
  97642. /**
  97643. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  97644. * @see http://doc.babylonjs.com/features/cameras
  97645. */
  97646. export class StereoscopicFreeCamera extends FreeCamera {
  97647. /**
  97648. * Creates a new StereoscopicFreeCamera
  97649. * @param name defines camera name
  97650. * @param position defines initial position
  97651. * @param interaxialDistance defines distance between each color axis
  97652. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97653. * @param scene defines the hosting scene
  97654. */
  97655. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97656. /**
  97657. * Gets camera class name
  97658. * @returns StereoscopicFreeCamera
  97659. */
  97660. getClassName(): string;
  97661. }
  97662. }
  97663. declare module BABYLON {
  97664. /**
  97665. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  97666. * @see http://doc.babylonjs.com/features/cameras
  97667. */
  97668. export class StereoscopicGamepadCamera extends GamepadCamera {
  97669. /**
  97670. * Creates a new StereoscopicGamepadCamera
  97671. * @param name defines camera name
  97672. * @param position defines initial position
  97673. * @param interaxialDistance defines distance between each color axis
  97674. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97675. * @param scene defines the hosting scene
  97676. */
  97677. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97678. /**
  97679. * Gets camera class name
  97680. * @returns StereoscopicGamepadCamera
  97681. */
  97682. getClassName(): string;
  97683. }
  97684. }
  97685. declare module BABYLON {
  97686. /**
  97687. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  97688. * @see http://doc.babylonjs.com/features/cameras
  97689. */
  97690. export class StereoscopicUniversalCamera extends UniversalCamera {
  97691. /**
  97692. * Creates a new StereoscopicUniversalCamera
  97693. * @param name defines camera name
  97694. * @param position defines initial position
  97695. * @param interaxialDistance defines distance between each color axis
  97696. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97697. * @param scene defines the hosting scene
  97698. */
  97699. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97700. /**
  97701. * Gets camera class name
  97702. * @returns StereoscopicUniversalCamera
  97703. */
  97704. getClassName(): string;
  97705. }
  97706. }
  97707. declare module BABYLON {
  97708. /**
  97709. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97710. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97711. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97712. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97713. */
  97714. export class VirtualJoysticksCamera extends FreeCamera {
  97715. /**
  97716. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  97717. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97718. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97719. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97720. * @param name Define the name of the camera in the scene
  97721. * @param position Define the start position of the camera in the scene
  97722. * @param scene Define the scene the camera belongs to
  97723. */
  97724. constructor(name: string, position: Vector3, scene: Scene);
  97725. /**
  97726. * Gets the current object class name.
  97727. * @return the class name
  97728. */
  97729. getClassName(): string;
  97730. }
  97731. }
  97732. declare module BABYLON {
  97733. /**
  97734. * This represents all the required metrics to create a VR camera.
  97735. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97736. */
  97737. export class VRCameraMetrics {
  97738. /**
  97739. * Define the horizontal resolution off the screen.
  97740. */
  97741. hResolution: number;
  97742. /**
  97743. * Define the vertical resolution off the screen.
  97744. */
  97745. vResolution: number;
  97746. /**
  97747. * Define the horizontal screen size.
  97748. */
  97749. hScreenSize: number;
  97750. /**
  97751. * Define the vertical screen size.
  97752. */
  97753. vScreenSize: number;
  97754. /**
  97755. * Define the vertical screen center position.
  97756. */
  97757. vScreenCenter: number;
  97758. /**
  97759. * Define the distance of the eyes to the screen.
  97760. */
  97761. eyeToScreenDistance: number;
  97762. /**
  97763. * Define the distance between both lenses
  97764. */
  97765. lensSeparationDistance: number;
  97766. /**
  97767. * Define the distance between both viewer's eyes.
  97768. */
  97769. interpupillaryDistance: number;
  97770. /**
  97771. * Define the distortion factor of the VR postprocess.
  97772. * Please, touch with care.
  97773. */
  97774. distortionK: number[];
  97775. /**
  97776. * Define the chromatic aberration correction factors for the VR post process.
  97777. */
  97778. chromaAbCorrection: number[];
  97779. /**
  97780. * Define the scale factor of the post process.
  97781. * The smaller the better but the slower.
  97782. */
  97783. postProcessScaleFactor: number;
  97784. /**
  97785. * Define an offset for the lens center.
  97786. */
  97787. lensCenterOffset: number;
  97788. /**
  97789. * Define if the current vr camera should compensate the distortion of the lense or not.
  97790. */
  97791. compensateDistortion: boolean;
  97792. /**
  97793. * Defines if multiview should be enabled when rendering (Default: false)
  97794. */
  97795. multiviewEnabled: boolean;
  97796. /**
  97797. * Gets the rendering aspect ratio based on the provided resolutions.
  97798. */
  97799. readonly aspectRatio: number;
  97800. /**
  97801. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97802. */
  97803. readonly aspectRatioFov: number;
  97804. /**
  97805. * @hidden
  97806. */
  97807. readonly leftHMatrix: Matrix;
  97808. /**
  97809. * @hidden
  97810. */
  97811. readonly rightHMatrix: Matrix;
  97812. /**
  97813. * @hidden
  97814. */
  97815. readonly leftPreViewMatrix: Matrix;
  97816. /**
  97817. * @hidden
  97818. */
  97819. readonly rightPreViewMatrix: Matrix;
  97820. /**
  97821. * Get the default VRMetrics based on the most generic setup.
  97822. * @returns the default vr metrics
  97823. */
  97824. static GetDefault(): VRCameraMetrics;
  97825. }
  97826. }
  97827. declare module BABYLON {
  97828. /** @hidden */
  97829. export var vrDistortionCorrectionPixelShader: {
  97830. name: string;
  97831. shader: string;
  97832. };
  97833. }
  97834. declare module BABYLON {
  97835. /**
  97836. * VRDistortionCorrectionPostProcess used for mobile VR
  97837. */
  97838. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97839. private _isRightEye;
  97840. private _distortionFactors;
  97841. private _postProcessScaleFactor;
  97842. private _lensCenterOffset;
  97843. private _scaleIn;
  97844. private _scaleFactor;
  97845. private _lensCenter;
  97846. /**
  97847. * Initializes the VRDistortionCorrectionPostProcess
  97848. * @param name The name of the effect.
  97849. * @param camera The camera to apply the render pass to.
  97850. * @param isRightEye If this is for the right eye distortion
  97851. * @param vrMetrics All the required metrics for the VR camera
  97852. */
  97853. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97854. }
  97855. }
  97856. declare module BABYLON {
  97857. /**
  97858. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97859. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97860. */
  97861. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97862. /**
  97863. * Creates a new VRDeviceOrientationArcRotateCamera
  97864. * @param name defines camera name
  97865. * @param alpha defines the camera rotation along the logitudinal axis
  97866. * @param beta defines the camera rotation along the latitudinal axis
  97867. * @param radius defines the camera distance from its target
  97868. * @param target defines the camera target
  97869. * @param scene defines the scene the camera belongs to
  97870. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97871. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97872. */
  97873. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97874. /**
  97875. * Gets camera class name
  97876. * @returns VRDeviceOrientationArcRotateCamera
  97877. */
  97878. getClassName(): string;
  97879. }
  97880. }
  97881. declare module BABYLON {
  97882. /**
  97883. * Camera used to simulate VR rendering (based on FreeCamera)
  97884. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97885. */
  97886. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97887. /**
  97888. * Creates a new VRDeviceOrientationFreeCamera
  97889. * @param name defines camera name
  97890. * @param position defines the start position of the camera
  97891. * @param scene defines the scene the camera belongs to
  97892. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97893. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97894. */
  97895. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97896. /**
  97897. * Gets camera class name
  97898. * @returns VRDeviceOrientationFreeCamera
  97899. */
  97900. getClassName(): string;
  97901. }
  97902. }
  97903. declare module BABYLON {
  97904. /**
  97905. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97906. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97907. */
  97908. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97909. /**
  97910. * Creates a new VRDeviceOrientationGamepadCamera
  97911. * @param name defines camera name
  97912. * @param position defines the start position of the camera
  97913. * @param scene defines the scene the camera belongs to
  97914. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97915. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97916. */
  97917. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97918. /**
  97919. * Gets camera class name
  97920. * @returns VRDeviceOrientationGamepadCamera
  97921. */
  97922. getClassName(): string;
  97923. }
  97924. }
  97925. declare module BABYLON {
  97926. /**
  97927. * Defines supported buttons for XBox360 compatible gamepads
  97928. */
  97929. export enum Xbox360Button {
  97930. /** A */
  97931. A = 0,
  97932. /** B */
  97933. B = 1,
  97934. /** X */
  97935. X = 2,
  97936. /** Y */
  97937. Y = 3,
  97938. /** Start */
  97939. Start = 4,
  97940. /** Back */
  97941. Back = 5,
  97942. /** Left button */
  97943. LB = 6,
  97944. /** Right button */
  97945. RB = 7,
  97946. /** Left stick */
  97947. LeftStick = 8,
  97948. /** Right stick */
  97949. RightStick = 9
  97950. }
  97951. /** Defines values for XBox360 DPad */
  97952. export enum Xbox360Dpad {
  97953. /** Up */
  97954. Up = 0,
  97955. /** Down */
  97956. Down = 1,
  97957. /** Left */
  97958. Left = 2,
  97959. /** Right */
  97960. Right = 3
  97961. }
  97962. /**
  97963. * Defines a XBox360 gamepad
  97964. */
  97965. export class Xbox360Pad extends Gamepad {
  97966. private _leftTrigger;
  97967. private _rightTrigger;
  97968. private _onlefttriggerchanged;
  97969. private _onrighttriggerchanged;
  97970. private _onbuttondown;
  97971. private _onbuttonup;
  97972. private _ondpaddown;
  97973. private _ondpadup;
  97974. /** Observable raised when a button is pressed */
  97975. onButtonDownObservable: Observable<Xbox360Button>;
  97976. /** Observable raised when a button is released */
  97977. onButtonUpObservable: Observable<Xbox360Button>;
  97978. /** Observable raised when a pad is pressed */
  97979. onPadDownObservable: Observable<Xbox360Dpad>;
  97980. /** Observable raised when a pad is released */
  97981. onPadUpObservable: Observable<Xbox360Dpad>;
  97982. private _buttonA;
  97983. private _buttonB;
  97984. private _buttonX;
  97985. private _buttonY;
  97986. private _buttonBack;
  97987. private _buttonStart;
  97988. private _buttonLB;
  97989. private _buttonRB;
  97990. private _buttonLeftStick;
  97991. private _buttonRightStick;
  97992. private _dPadUp;
  97993. private _dPadDown;
  97994. private _dPadLeft;
  97995. private _dPadRight;
  97996. private _isXboxOnePad;
  97997. /**
  97998. * Creates a new XBox360 gamepad object
  97999. * @param id defines the id of this gamepad
  98000. * @param index defines its index
  98001. * @param gamepad defines the internal HTML gamepad object
  98002. * @param xboxOne defines if it is a XBox One gamepad
  98003. */
  98004. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  98005. /**
  98006. * Defines the callback to call when left trigger is pressed
  98007. * @param callback defines the callback to use
  98008. */
  98009. onlefttriggerchanged(callback: (value: number) => void): void;
  98010. /**
  98011. * Defines the callback to call when right trigger is pressed
  98012. * @param callback defines the callback to use
  98013. */
  98014. onrighttriggerchanged(callback: (value: number) => void): void;
  98015. /**
  98016. * Gets the left trigger value
  98017. */
  98018. /**
  98019. * Sets the left trigger value
  98020. */
  98021. leftTrigger: number;
  98022. /**
  98023. * Gets the right trigger value
  98024. */
  98025. /**
  98026. * Sets the right trigger value
  98027. */
  98028. rightTrigger: number;
  98029. /**
  98030. * Defines the callback to call when a button is pressed
  98031. * @param callback defines the callback to use
  98032. */
  98033. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  98034. /**
  98035. * Defines the callback to call when a button is released
  98036. * @param callback defines the callback to use
  98037. */
  98038. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  98039. /**
  98040. * Defines the callback to call when a pad is pressed
  98041. * @param callback defines the callback to use
  98042. */
  98043. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  98044. /**
  98045. * Defines the callback to call when a pad is released
  98046. * @param callback defines the callback to use
  98047. */
  98048. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  98049. private _setButtonValue;
  98050. private _setDPadValue;
  98051. /**
  98052. * Gets the value of the `A` button
  98053. */
  98054. /**
  98055. * Sets the value of the `A` button
  98056. */
  98057. buttonA: number;
  98058. /**
  98059. * Gets the value of the `B` button
  98060. */
  98061. /**
  98062. * Sets the value of the `B` button
  98063. */
  98064. buttonB: number;
  98065. /**
  98066. * Gets the value of the `X` button
  98067. */
  98068. /**
  98069. * Sets the value of the `X` button
  98070. */
  98071. buttonX: number;
  98072. /**
  98073. * Gets the value of the `Y` button
  98074. */
  98075. /**
  98076. * Sets the value of the `Y` button
  98077. */
  98078. buttonY: number;
  98079. /**
  98080. * Gets the value of the `Start` button
  98081. */
  98082. /**
  98083. * Sets the value of the `Start` button
  98084. */
  98085. buttonStart: number;
  98086. /**
  98087. * Gets the value of the `Back` button
  98088. */
  98089. /**
  98090. * Sets the value of the `Back` button
  98091. */
  98092. buttonBack: number;
  98093. /**
  98094. * Gets the value of the `Left` button
  98095. */
  98096. /**
  98097. * Sets the value of the `Left` button
  98098. */
  98099. buttonLB: number;
  98100. /**
  98101. * Gets the value of the `Right` button
  98102. */
  98103. /**
  98104. * Sets the value of the `Right` button
  98105. */
  98106. buttonRB: number;
  98107. /**
  98108. * Gets the value of the Left joystick
  98109. */
  98110. /**
  98111. * Sets the value of the Left joystick
  98112. */
  98113. buttonLeftStick: number;
  98114. /**
  98115. * Gets the value of the Right joystick
  98116. */
  98117. /**
  98118. * Sets the value of the Right joystick
  98119. */
  98120. buttonRightStick: number;
  98121. /**
  98122. * Gets the value of D-pad up
  98123. */
  98124. /**
  98125. * Sets the value of D-pad up
  98126. */
  98127. dPadUp: number;
  98128. /**
  98129. * Gets the value of D-pad down
  98130. */
  98131. /**
  98132. * Sets the value of D-pad down
  98133. */
  98134. dPadDown: number;
  98135. /**
  98136. * Gets the value of D-pad left
  98137. */
  98138. /**
  98139. * Sets the value of D-pad left
  98140. */
  98141. dPadLeft: number;
  98142. /**
  98143. * Gets the value of D-pad right
  98144. */
  98145. /**
  98146. * Sets the value of D-pad right
  98147. */
  98148. dPadRight: number;
  98149. /**
  98150. * Force the gamepad to synchronize with device values
  98151. */
  98152. update(): void;
  98153. /**
  98154. * Disposes the gamepad
  98155. */
  98156. dispose(): void;
  98157. }
  98158. }
  98159. declare module BABYLON {
  98160. /**
  98161. * Base class of materials working in push mode in babylon JS
  98162. * @hidden
  98163. */
  98164. export class PushMaterial extends Material {
  98165. protected _activeEffect: Effect;
  98166. protected _normalMatrix: Matrix;
  98167. /**
  98168. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98169. * This means that the material can keep using a previous shader while a new one is being compiled.
  98170. * This is mostly used when shader parallel compilation is supported (true by default)
  98171. */
  98172. allowShaderHotSwapping: boolean;
  98173. constructor(name: string, scene: Scene);
  98174. getEffect(): Effect;
  98175. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98176. /**
  98177. * Binds the given world matrix to the active effect
  98178. *
  98179. * @param world the matrix to bind
  98180. */
  98181. bindOnlyWorldMatrix(world: Matrix): void;
  98182. /**
  98183. * Binds the given normal matrix to the active effect
  98184. *
  98185. * @param normalMatrix the matrix to bind
  98186. */
  98187. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98188. bind(world: Matrix, mesh?: Mesh): void;
  98189. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98190. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98191. }
  98192. }
  98193. declare module BABYLON {
  98194. /**
  98195. * This groups all the flags used to control the materials channel.
  98196. */
  98197. export class MaterialFlags {
  98198. private static _DiffuseTextureEnabled;
  98199. /**
  98200. * Are diffuse textures enabled in the application.
  98201. */
  98202. static DiffuseTextureEnabled: boolean;
  98203. private static _AmbientTextureEnabled;
  98204. /**
  98205. * Are ambient textures enabled in the application.
  98206. */
  98207. static AmbientTextureEnabled: boolean;
  98208. private static _OpacityTextureEnabled;
  98209. /**
  98210. * Are opacity textures enabled in the application.
  98211. */
  98212. static OpacityTextureEnabled: boolean;
  98213. private static _ReflectionTextureEnabled;
  98214. /**
  98215. * Are reflection textures enabled in the application.
  98216. */
  98217. static ReflectionTextureEnabled: boolean;
  98218. private static _EmissiveTextureEnabled;
  98219. /**
  98220. * Are emissive textures enabled in the application.
  98221. */
  98222. static EmissiveTextureEnabled: boolean;
  98223. private static _SpecularTextureEnabled;
  98224. /**
  98225. * Are specular textures enabled in the application.
  98226. */
  98227. static SpecularTextureEnabled: boolean;
  98228. private static _BumpTextureEnabled;
  98229. /**
  98230. * Are bump textures enabled in the application.
  98231. */
  98232. static BumpTextureEnabled: boolean;
  98233. private static _LightmapTextureEnabled;
  98234. /**
  98235. * Are lightmap textures enabled in the application.
  98236. */
  98237. static LightmapTextureEnabled: boolean;
  98238. private static _RefractionTextureEnabled;
  98239. /**
  98240. * Are refraction textures enabled in the application.
  98241. */
  98242. static RefractionTextureEnabled: boolean;
  98243. private static _ColorGradingTextureEnabled;
  98244. /**
  98245. * Are color grading textures enabled in the application.
  98246. */
  98247. static ColorGradingTextureEnabled: boolean;
  98248. private static _FresnelEnabled;
  98249. /**
  98250. * Are fresnels enabled in the application.
  98251. */
  98252. static FresnelEnabled: boolean;
  98253. private static _ClearCoatTextureEnabled;
  98254. /**
  98255. * Are clear coat textures enabled in the application.
  98256. */
  98257. static ClearCoatTextureEnabled: boolean;
  98258. private static _ClearCoatBumpTextureEnabled;
  98259. /**
  98260. * Are clear coat bump textures enabled in the application.
  98261. */
  98262. static ClearCoatBumpTextureEnabled: boolean;
  98263. private static _ClearCoatTintTextureEnabled;
  98264. /**
  98265. * Are clear coat tint textures enabled in the application.
  98266. */
  98267. static ClearCoatTintTextureEnabled: boolean;
  98268. private static _SheenTextureEnabled;
  98269. /**
  98270. * Are sheen textures enabled in the application.
  98271. */
  98272. static SheenTextureEnabled: boolean;
  98273. private static _AnisotropicTextureEnabled;
  98274. /**
  98275. * Are anisotropic textures enabled in the application.
  98276. */
  98277. static AnisotropicTextureEnabled: boolean;
  98278. private static _ThicknessTextureEnabled;
  98279. /**
  98280. * Are thickness textures enabled in the application.
  98281. */
  98282. static ThicknessTextureEnabled: boolean;
  98283. }
  98284. }
  98285. declare module BABYLON {
  98286. /** @hidden */
  98287. export var defaultFragmentDeclaration: {
  98288. name: string;
  98289. shader: string;
  98290. };
  98291. }
  98292. declare module BABYLON {
  98293. /** @hidden */
  98294. export var defaultUboDeclaration: {
  98295. name: string;
  98296. shader: string;
  98297. };
  98298. }
  98299. declare module BABYLON {
  98300. /** @hidden */
  98301. export var lightFragmentDeclaration: {
  98302. name: string;
  98303. shader: string;
  98304. };
  98305. }
  98306. declare module BABYLON {
  98307. /** @hidden */
  98308. export var lightUboDeclaration: {
  98309. name: string;
  98310. shader: string;
  98311. };
  98312. }
  98313. declare module BABYLON {
  98314. /** @hidden */
  98315. export var lightsFragmentFunctions: {
  98316. name: string;
  98317. shader: string;
  98318. };
  98319. }
  98320. declare module BABYLON {
  98321. /** @hidden */
  98322. export var shadowsFragmentFunctions: {
  98323. name: string;
  98324. shader: string;
  98325. };
  98326. }
  98327. declare module BABYLON {
  98328. /** @hidden */
  98329. export var fresnelFunction: {
  98330. name: string;
  98331. shader: string;
  98332. };
  98333. }
  98334. declare module BABYLON {
  98335. /** @hidden */
  98336. export var reflectionFunction: {
  98337. name: string;
  98338. shader: string;
  98339. };
  98340. }
  98341. declare module BABYLON {
  98342. /** @hidden */
  98343. export var bumpFragmentFunctions: {
  98344. name: string;
  98345. shader: string;
  98346. };
  98347. }
  98348. declare module BABYLON {
  98349. /** @hidden */
  98350. export var logDepthDeclaration: {
  98351. name: string;
  98352. shader: string;
  98353. };
  98354. }
  98355. declare module BABYLON {
  98356. /** @hidden */
  98357. export var bumpFragment: {
  98358. name: string;
  98359. shader: string;
  98360. };
  98361. }
  98362. declare module BABYLON {
  98363. /** @hidden */
  98364. export var depthPrePass: {
  98365. name: string;
  98366. shader: string;
  98367. };
  98368. }
  98369. declare module BABYLON {
  98370. /** @hidden */
  98371. export var lightFragment: {
  98372. name: string;
  98373. shader: string;
  98374. };
  98375. }
  98376. declare module BABYLON {
  98377. /** @hidden */
  98378. export var logDepthFragment: {
  98379. name: string;
  98380. shader: string;
  98381. };
  98382. }
  98383. declare module BABYLON {
  98384. /** @hidden */
  98385. export var defaultPixelShader: {
  98386. name: string;
  98387. shader: string;
  98388. };
  98389. }
  98390. declare module BABYLON {
  98391. /** @hidden */
  98392. export var defaultVertexDeclaration: {
  98393. name: string;
  98394. shader: string;
  98395. };
  98396. }
  98397. declare module BABYLON {
  98398. /** @hidden */
  98399. export var bumpVertexDeclaration: {
  98400. name: string;
  98401. shader: string;
  98402. };
  98403. }
  98404. declare module BABYLON {
  98405. /** @hidden */
  98406. export var bumpVertex: {
  98407. name: string;
  98408. shader: string;
  98409. };
  98410. }
  98411. declare module BABYLON {
  98412. /** @hidden */
  98413. export var fogVertex: {
  98414. name: string;
  98415. shader: string;
  98416. };
  98417. }
  98418. declare module BABYLON {
  98419. /** @hidden */
  98420. export var shadowsVertex: {
  98421. name: string;
  98422. shader: string;
  98423. };
  98424. }
  98425. declare module BABYLON {
  98426. /** @hidden */
  98427. export var pointCloudVertex: {
  98428. name: string;
  98429. shader: string;
  98430. };
  98431. }
  98432. declare module BABYLON {
  98433. /** @hidden */
  98434. export var logDepthVertex: {
  98435. name: string;
  98436. shader: string;
  98437. };
  98438. }
  98439. declare module BABYLON {
  98440. /** @hidden */
  98441. export var defaultVertexShader: {
  98442. name: string;
  98443. shader: string;
  98444. };
  98445. }
  98446. declare module BABYLON {
  98447. /** @hidden */
  98448. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98449. MAINUV1: boolean;
  98450. MAINUV2: boolean;
  98451. DIFFUSE: boolean;
  98452. DIFFUSEDIRECTUV: number;
  98453. AMBIENT: boolean;
  98454. AMBIENTDIRECTUV: number;
  98455. OPACITY: boolean;
  98456. OPACITYDIRECTUV: number;
  98457. OPACITYRGB: boolean;
  98458. REFLECTION: boolean;
  98459. EMISSIVE: boolean;
  98460. EMISSIVEDIRECTUV: number;
  98461. SPECULAR: boolean;
  98462. SPECULARDIRECTUV: number;
  98463. BUMP: boolean;
  98464. BUMPDIRECTUV: number;
  98465. PARALLAX: boolean;
  98466. PARALLAXOCCLUSION: boolean;
  98467. SPECULAROVERALPHA: boolean;
  98468. CLIPPLANE: boolean;
  98469. CLIPPLANE2: boolean;
  98470. CLIPPLANE3: boolean;
  98471. CLIPPLANE4: boolean;
  98472. ALPHATEST: boolean;
  98473. DEPTHPREPASS: boolean;
  98474. ALPHAFROMDIFFUSE: boolean;
  98475. POINTSIZE: boolean;
  98476. FOG: boolean;
  98477. SPECULARTERM: boolean;
  98478. DIFFUSEFRESNEL: boolean;
  98479. OPACITYFRESNEL: boolean;
  98480. REFLECTIONFRESNEL: boolean;
  98481. REFRACTIONFRESNEL: boolean;
  98482. EMISSIVEFRESNEL: boolean;
  98483. FRESNEL: boolean;
  98484. NORMAL: boolean;
  98485. UV1: boolean;
  98486. UV2: boolean;
  98487. VERTEXCOLOR: boolean;
  98488. VERTEXALPHA: boolean;
  98489. NUM_BONE_INFLUENCERS: number;
  98490. BonesPerMesh: number;
  98491. BONETEXTURE: boolean;
  98492. INSTANCES: boolean;
  98493. GLOSSINESS: boolean;
  98494. ROUGHNESS: boolean;
  98495. EMISSIVEASILLUMINATION: boolean;
  98496. LINKEMISSIVEWITHDIFFUSE: boolean;
  98497. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98498. LIGHTMAP: boolean;
  98499. LIGHTMAPDIRECTUV: number;
  98500. OBJECTSPACE_NORMALMAP: boolean;
  98501. USELIGHTMAPASSHADOWMAP: boolean;
  98502. REFLECTIONMAP_3D: boolean;
  98503. REFLECTIONMAP_SPHERICAL: boolean;
  98504. REFLECTIONMAP_PLANAR: boolean;
  98505. REFLECTIONMAP_CUBIC: boolean;
  98506. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98507. REFLECTIONMAP_PROJECTION: boolean;
  98508. REFLECTIONMAP_SKYBOX: boolean;
  98509. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98510. REFLECTIONMAP_EXPLICIT: boolean;
  98511. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98512. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98513. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98514. INVERTCUBICMAP: boolean;
  98515. LOGARITHMICDEPTH: boolean;
  98516. REFRACTION: boolean;
  98517. REFRACTIONMAP_3D: boolean;
  98518. REFLECTIONOVERALPHA: boolean;
  98519. TWOSIDEDLIGHTING: boolean;
  98520. SHADOWFLOAT: boolean;
  98521. MORPHTARGETS: boolean;
  98522. MORPHTARGETS_NORMAL: boolean;
  98523. MORPHTARGETS_TANGENT: boolean;
  98524. NUM_MORPH_INFLUENCERS: number;
  98525. NONUNIFORMSCALING: boolean;
  98526. PREMULTIPLYALPHA: boolean;
  98527. IMAGEPROCESSING: boolean;
  98528. VIGNETTE: boolean;
  98529. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98530. VIGNETTEBLENDMODEOPAQUE: boolean;
  98531. TONEMAPPING: boolean;
  98532. TONEMAPPING_ACES: boolean;
  98533. CONTRAST: boolean;
  98534. COLORCURVES: boolean;
  98535. COLORGRADING: boolean;
  98536. COLORGRADING3D: boolean;
  98537. SAMPLER3DGREENDEPTH: boolean;
  98538. SAMPLER3DBGRMAP: boolean;
  98539. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98540. MULTIVIEW: boolean;
  98541. /**
  98542. * If the reflection texture on this material is in linear color space
  98543. * @hidden
  98544. */
  98545. IS_REFLECTION_LINEAR: boolean;
  98546. /**
  98547. * If the refraction texture on this material is in linear color space
  98548. * @hidden
  98549. */
  98550. IS_REFRACTION_LINEAR: boolean;
  98551. EXPOSURE: boolean;
  98552. constructor();
  98553. setReflectionMode(modeToEnable: string): void;
  98554. }
  98555. /**
  98556. * This is the default material used in Babylon. It is the best trade off between quality
  98557. * and performances.
  98558. * @see http://doc.babylonjs.com/babylon101/materials
  98559. */
  98560. export class StandardMaterial extends PushMaterial {
  98561. private _diffuseTexture;
  98562. /**
  98563. * The basic texture of the material as viewed under a light.
  98564. */
  98565. diffuseTexture: Nullable<BaseTexture>;
  98566. private _ambientTexture;
  98567. /**
  98568. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98569. */
  98570. ambientTexture: Nullable<BaseTexture>;
  98571. private _opacityTexture;
  98572. /**
  98573. * Define the transparency of the material from a texture.
  98574. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98575. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98576. */
  98577. opacityTexture: Nullable<BaseTexture>;
  98578. private _reflectionTexture;
  98579. /**
  98580. * Define the texture used to display the reflection.
  98581. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98582. */
  98583. reflectionTexture: Nullable<BaseTexture>;
  98584. private _emissiveTexture;
  98585. /**
  98586. * Define texture of the material as if self lit.
  98587. * This will be mixed in the final result even in the absence of light.
  98588. */
  98589. emissiveTexture: Nullable<BaseTexture>;
  98590. private _specularTexture;
  98591. /**
  98592. * Define how the color and intensity of the highlight given by the light in the material.
  98593. */
  98594. specularTexture: Nullable<BaseTexture>;
  98595. private _bumpTexture;
  98596. /**
  98597. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98598. * 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.
  98599. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98600. */
  98601. bumpTexture: Nullable<BaseTexture>;
  98602. private _lightmapTexture;
  98603. /**
  98604. * Complex lighting can be computationally expensive to compute at runtime.
  98605. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98606. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98607. */
  98608. lightmapTexture: Nullable<BaseTexture>;
  98609. private _refractionTexture;
  98610. /**
  98611. * Define the texture used to display the refraction.
  98612. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98613. */
  98614. refractionTexture: Nullable<BaseTexture>;
  98615. /**
  98616. * The color of the material lit by the environmental background lighting.
  98617. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98618. */
  98619. ambientColor: Color3;
  98620. /**
  98621. * The basic color of the material as viewed under a light.
  98622. */
  98623. diffuseColor: Color3;
  98624. /**
  98625. * Define how the color and intensity of the highlight given by the light in the material.
  98626. */
  98627. specularColor: Color3;
  98628. /**
  98629. * Define the color of the material as if self lit.
  98630. * This will be mixed in the final result even in the absence of light.
  98631. */
  98632. emissiveColor: Color3;
  98633. /**
  98634. * Defines how sharp are the highlights in the material.
  98635. * The bigger the value the sharper giving a more glossy feeling to the result.
  98636. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98637. */
  98638. specularPower: number;
  98639. private _useAlphaFromDiffuseTexture;
  98640. /**
  98641. * Does the transparency come from the diffuse texture alpha channel.
  98642. */
  98643. useAlphaFromDiffuseTexture: boolean;
  98644. private _useEmissiveAsIllumination;
  98645. /**
  98646. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98647. */
  98648. useEmissiveAsIllumination: boolean;
  98649. private _linkEmissiveWithDiffuse;
  98650. /**
  98651. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98652. * the emissive level when the final color is close to one.
  98653. */
  98654. linkEmissiveWithDiffuse: boolean;
  98655. private _useSpecularOverAlpha;
  98656. /**
  98657. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98658. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98659. */
  98660. useSpecularOverAlpha: boolean;
  98661. private _useReflectionOverAlpha;
  98662. /**
  98663. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98664. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98665. */
  98666. useReflectionOverAlpha: boolean;
  98667. private _disableLighting;
  98668. /**
  98669. * Does lights from the scene impacts this material.
  98670. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98671. */
  98672. disableLighting: boolean;
  98673. private _useObjectSpaceNormalMap;
  98674. /**
  98675. * Allows using an object space normal map (instead of tangent space).
  98676. */
  98677. useObjectSpaceNormalMap: boolean;
  98678. private _useParallax;
  98679. /**
  98680. * Is parallax enabled or not.
  98681. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98682. */
  98683. useParallax: boolean;
  98684. private _useParallaxOcclusion;
  98685. /**
  98686. * Is parallax occlusion enabled or not.
  98687. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98688. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98689. */
  98690. useParallaxOcclusion: boolean;
  98691. /**
  98692. * 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.
  98693. */
  98694. parallaxScaleBias: number;
  98695. private _roughness;
  98696. /**
  98697. * Helps to define how blurry the reflections should appears in the material.
  98698. */
  98699. roughness: number;
  98700. /**
  98701. * In case of refraction, define the value of the indice of refraction.
  98702. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98703. */
  98704. indexOfRefraction: number;
  98705. /**
  98706. * Invert the refraction texture alongside the y axis.
  98707. * It can be useful with procedural textures or probe for instance.
  98708. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98709. */
  98710. invertRefractionY: boolean;
  98711. /**
  98712. * Defines the alpha limits in alpha test mode.
  98713. */
  98714. alphaCutOff: number;
  98715. private _useLightmapAsShadowmap;
  98716. /**
  98717. * In case of light mapping, define whether the map contains light or shadow informations.
  98718. */
  98719. useLightmapAsShadowmap: boolean;
  98720. private _diffuseFresnelParameters;
  98721. /**
  98722. * Define the diffuse fresnel parameters of the material.
  98723. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98724. */
  98725. diffuseFresnelParameters: FresnelParameters;
  98726. private _opacityFresnelParameters;
  98727. /**
  98728. * Define the opacity fresnel parameters of the material.
  98729. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98730. */
  98731. opacityFresnelParameters: FresnelParameters;
  98732. private _reflectionFresnelParameters;
  98733. /**
  98734. * Define the reflection fresnel parameters of the material.
  98735. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98736. */
  98737. reflectionFresnelParameters: FresnelParameters;
  98738. private _refractionFresnelParameters;
  98739. /**
  98740. * Define the refraction fresnel parameters of the material.
  98741. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98742. */
  98743. refractionFresnelParameters: FresnelParameters;
  98744. private _emissiveFresnelParameters;
  98745. /**
  98746. * Define the emissive fresnel parameters of the material.
  98747. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98748. */
  98749. emissiveFresnelParameters: FresnelParameters;
  98750. private _useReflectionFresnelFromSpecular;
  98751. /**
  98752. * If true automatically deducts the fresnels values from the material specularity.
  98753. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98754. */
  98755. useReflectionFresnelFromSpecular: boolean;
  98756. private _useGlossinessFromSpecularMapAlpha;
  98757. /**
  98758. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98759. */
  98760. useGlossinessFromSpecularMapAlpha: boolean;
  98761. private _maxSimultaneousLights;
  98762. /**
  98763. * Defines the maximum number of lights that can be used in the material
  98764. */
  98765. maxSimultaneousLights: number;
  98766. private _invertNormalMapX;
  98767. /**
  98768. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98769. */
  98770. invertNormalMapX: boolean;
  98771. private _invertNormalMapY;
  98772. /**
  98773. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98774. */
  98775. invertNormalMapY: boolean;
  98776. private _twoSidedLighting;
  98777. /**
  98778. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98779. */
  98780. twoSidedLighting: boolean;
  98781. /**
  98782. * Default configuration related to image processing available in the standard Material.
  98783. */
  98784. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98785. /**
  98786. * Gets the image processing configuration used either in this material.
  98787. */
  98788. /**
  98789. * Sets the Default image processing configuration used either in the this material.
  98790. *
  98791. * If sets to null, the scene one is in use.
  98792. */
  98793. imageProcessingConfiguration: ImageProcessingConfiguration;
  98794. /**
  98795. * Keep track of the image processing observer to allow dispose and replace.
  98796. */
  98797. private _imageProcessingObserver;
  98798. /**
  98799. * Attaches a new image processing configuration to the Standard Material.
  98800. * @param configuration
  98801. */
  98802. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98803. /**
  98804. * Gets wether the color curves effect is enabled.
  98805. */
  98806. /**
  98807. * Sets wether the color curves effect is enabled.
  98808. */
  98809. cameraColorCurvesEnabled: boolean;
  98810. /**
  98811. * Gets wether the color grading effect is enabled.
  98812. */
  98813. /**
  98814. * Gets wether the color grading effect is enabled.
  98815. */
  98816. cameraColorGradingEnabled: boolean;
  98817. /**
  98818. * Gets wether tonemapping is enabled or not.
  98819. */
  98820. /**
  98821. * Sets wether tonemapping is enabled or not
  98822. */
  98823. cameraToneMappingEnabled: boolean;
  98824. /**
  98825. * The camera exposure used on this material.
  98826. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98827. * This corresponds to a photographic exposure.
  98828. */
  98829. /**
  98830. * The camera exposure used on this material.
  98831. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98832. * This corresponds to a photographic exposure.
  98833. */
  98834. cameraExposure: number;
  98835. /**
  98836. * Gets The camera contrast used on this material.
  98837. */
  98838. /**
  98839. * Sets The camera contrast used on this material.
  98840. */
  98841. cameraContrast: number;
  98842. /**
  98843. * Gets the Color Grading 2D Lookup Texture.
  98844. */
  98845. /**
  98846. * Sets the Color Grading 2D Lookup Texture.
  98847. */
  98848. cameraColorGradingTexture: Nullable<BaseTexture>;
  98849. /**
  98850. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98851. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98852. * 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;
  98853. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98854. */
  98855. /**
  98856. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98857. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98858. * 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;
  98859. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98860. */
  98861. cameraColorCurves: Nullable<ColorCurves>;
  98862. /**
  98863. * Custom callback helping to override the default shader used in the material.
  98864. */
  98865. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98866. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98867. protected _worldViewProjectionMatrix: Matrix;
  98868. protected _globalAmbientColor: Color3;
  98869. protected _useLogarithmicDepth: boolean;
  98870. /**
  98871. * Instantiates a new standard material.
  98872. * This is the default material used in Babylon. It is the best trade off between quality
  98873. * and performances.
  98874. * @see http://doc.babylonjs.com/babylon101/materials
  98875. * @param name Define the name of the material in the scene
  98876. * @param scene Define the scene the material belong to
  98877. */
  98878. constructor(name: string, scene: Scene);
  98879. /**
  98880. * Gets a boolean indicating that current material needs to register RTT
  98881. */
  98882. readonly hasRenderTargetTextures: boolean;
  98883. /**
  98884. * Gets the current class name of the material e.g. "StandardMaterial"
  98885. * Mainly use in serialization.
  98886. * @returns the class name
  98887. */
  98888. getClassName(): string;
  98889. /**
  98890. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98891. * You can try switching to logarithmic depth.
  98892. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98893. */
  98894. useLogarithmicDepth: boolean;
  98895. /**
  98896. * Specifies if the material will require alpha blending
  98897. * @returns a boolean specifying if alpha blending is needed
  98898. */
  98899. needAlphaBlending(): boolean;
  98900. /**
  98901. * Specifies if this material should be rendered in alpha test mode
  98902. * @returns a boolean specifying if an alpha test is needed.
  98903. */
  98904. needAlphaTesting(): boolean;
  98905. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98906. /**
  98907. * Get the texture used for alpha test purpose.
  98908. * @returns the diffuse texture in case of the standard material.
  98909. */
  98910. getAlphaTestTexture(): Nullable<BaseTexture>;
  98911. /**
  98912. * Get if the submesh is ready to be used and all its information available.
  98913. * Child classes can use it to update shaders
  98914. * @param mesh defines the mesh to check
  98915. * @param subMesh defines which submesh to check
  98916. * @param useInstances specifies that instances should be used
  98917. * @returns a boolean indicating that the submesh is ready or not
  98918. */
  98919. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98920. /**
  98921. * Builds the material UBO layouts.
  98922. * Used internally during the effect preparation.
  98923. */
  98924. buildUniformLayout(): void;
  98925. /**
  98926. * Unbinds the material from the mesh
  98927. */
  98928. unbind(): void;
  98929. /**
  98930. * Binds the submesh to this material by preparing the effect and shader to draw
  98931. * @param world defines the world transformation matrix
  98932. * @param mesh defines the mesh containing the submesh
  98933. * @param subMesh defines the submesh to bind the material to
  98934. */
  98935. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98936. /**
  98937. * Get the list of animatables in the material.
  98938. * @returns the list of animatables object used in the material
  98939. */
  98940. getAnimatables(): IAnimatable[];
  98941. /**
  98942. * Gets the active textures from the material
  98943. * @returns an array of textures
  98944. */
  98945. getActiveTextures(): BaseTexture[];
  98946. /**
  98947. * Specifies if the material uses a texture
  98948. * @param texture defines the texture to check against the material
  98949. * @returns a boolean specifying if the material uses the texture
  98950. */
  98951. hasTexture(texture: BaseTexture): boolean;
  98952. /**
  98953. * Disposes the material
  98954. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98955. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98956. */
  98957. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98958. /**
  98959. * Makes a duplicate of the material, and gives it a new name
  98960. * @param name defines the new name for the duplicated material
  98961. * @returns the cloned material
  98962. */
  98963. clone(name: string): StandardMaterial;
  98964. /**
  98965. * Serializes this material in a JSON representation
  98966. * @returns the serialized material object
  98967. */
  98968. serialize(): any;
  98969. /**
  98970. * Creates a standard material from parsed material data
  98971. * @param source defines the JSON representation of the material
  98972. * @param scene defines the hosting scene
  98973. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98974. * @returns a new standard material
  98975. */
  98976. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98977. /**
  98978. * Are diffuse textures enabled in the application.
  98979. */
  98980. static DiffuseTextureEnabled: boolean;
  98981. /**
  98982. * Are ambient textures enabled in the application.
  98983. */
  98984. static AmbientTextureEnabled: boolean;
  98985. /**
  98986. * Are opacity textures enabled in the application.
  98987. */
  98988. static OpacityTextureEnabled: boolean;
  98989. /**
  98990. * Are reflection textures enabled in the application.
  98991. */
  98992. static ReflectionTextureEnabled: boolean;
  98993. /**
  98994. * Are emissive textures enabled in the application.
  98995. */
  98996. static EmissiveTextureEnabled: boolean;
  98997. /**
  98998. * Are specular textures enabled in the application.
  98999. */
  99000. static SpecularTextureEnabled: boolean;
  99001. /**
  99002. * Are bump textures enabled in the application.
  99003. */
  99004. static BumpTextureEnabled: boolean;
  99005. /**
  99006. * Are lightmap textures enabled in the application.
  99007. */
  99008. static LightmapTextureEnabled: boolean;
  99009. /**
  99010. * Are refraction textures enabled in the application.
  99011. */
  99012. static RefractionTextureEnabled: boolean;
  99013. /**
  99014. * Are color grading textures enabled in the application.
  99015. */
  99016. static ColorGradingTextureEnabled: boolean;
  99017. /**
  99018. * Are fresnels enabled in the application.
  99019. */
  99020. static FresnelEnabled: boolean;
  99021. }
  99022. }
  99023. declare module BABYLON {
  99024. /**
  99025. * A class extending Texture allowing drawing on a texture
  99026. * @see http://doc.babylonjs.com/how_to/dynamictexture
  99027. */
  99028. export class DynamicTexture extends Texture {
  99029. private _generateMipMaps;
  99030. private _canvas;
  99031. private _context;
  99032. private _engine;
  99033. /**
  99034. * Creates a DynamicTexture
  99035. * @param name defines the name of the texture
  99036. * @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
  99037. * @param scene defines the scene where you want the texture
  99038. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  99039. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  99040. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  99041. */
  99042. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  99043. /**
  99044. * Get the current class name of the texture useful for serialization or dynamic coding.
  99045. * @returns "DynamicTexture"
  99046. */
  99047. getClassName(): string;
  99048. /**
  99049. * Gets the current state of canRescale
  99050. */
  99051. readonly canRescale: boolean;
  99052. private _recreate;
  99053. /**
  99054. * Scales the texture
  99055. * @param ratio the scale factor to apply to both width and height
  99056. */
  99057. scale(ratio: number): void;
  99058. /**
  99059. * Resizes the texture
  99060. * @param width the new width
  99061. * @param height the new height
  99062. */
  99063. scaleTo(width: number, height: number): void;
  99064. /**
  99065. * Gets the context of the canvas used by the texture
  99066. * @returns the canvas context of the dynamic texture
  99067. */
  99068. getContext(): CanvasRenderingContext2D;
  99069. /**
  99070. * Clears the texture
  99071. */
  99072. clear(): void;
  99073. /**
  99074. * Updates the texture
  99075. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99076. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  99077. */
  99078. update(invertY?: boolean, premulAlpha?: boolean): void;
  99079. /**
  99080. * Draws text onto the texture
  99081. * @param text defines the text to be drawn
  99082. * @param x defines the placement of the text from the left
  99083. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  99084. * @param font defines the font to be used with font-style, font-size, font-name
  99085. * @param color defines the color used for the text
  99086. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  99087. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99088. * @param update defines whether texture is immediately update (default is true)
  99089. */
  99090. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  99091. /**
  99092. * Clones the texture
  99093. * @returns the clone of the texture.
  99094. */
  99095. clone(): DynamicTexture;
  99096. /**
  99097. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  99098. * @returns a serialized dynamic texture object
  99099. */
  99100. serialize(): any;
  99101. /** @hidden */
  99102. _rebuild(): void;
  99103. }
  99104. }
  99105. declare module BABYLON {
  99106. /** @hidden */
  99107. export var imageProcessingPixelShader: {
  99108. name: string;
  99109. shader: string;
  99110. };
  99111. }
  99112. declare module BABYLON {
  99113. /**
  99114. * ImageProcessingPostProcess
  99115. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99116. */
  99117. export class ImageProcessingPostProcess extends PostProcess {
  99118. /**
  99119. * Default configuration related to image processing available in the PBR Material.
  99120. */
  99121. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99122. /**
  99123. * Gets the image processing configuration used either in this material.
  99124. */
  99125. /**
  99126. * Sets the Default image processing configuration used either in the this material.
  99127. *
  99128. * If sets to null, the scene one is in use.
  99129. */
  99130. imageProcessingConfiguration: ImageProcessingConfiguration;
  99131. /**
  99132. * Keep track of the image processing observer to allow dispose and replace.
  99133. */
  99134. private _imageProcessingObserver;
  99135. /**
  99136. * Attaches a new image processing configuration to the PBR Material.
  99137. * @param configuration
  99138. */
  99139. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99140. /**
  99141. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99142. */
  99143. /**
  99144. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99145. */
  99146. colorCurves: Nullable<ColorCurves>;
  99147. /**
  99148. * Gets wether the color curves effect is enabled.
  99149. */
  99150. /**
  99151. * Sets wether the color curves effect is enabled.
  99152. */
  99153. colorCurvesEnabled: boolean;
  99154. /**
  99155. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99156. */
  99157. /**
  99158. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99159. */
  99160. colorGradingTexture: Nullable<BaseTexture>;
  99161. /**
  99162. * Gets wether the color grading effect is enabled.
  99163. */
  99164. /**
  99165. * Gets wether the color grading effect is enabled.
  99166. */
  99167. colorGradingEnabled: boolean;
  99168. /**
  99169. * Gets exposure used in the effect.
  99170. */
  99171. /**
  99172. * Sets exposure used in the effect.
  99173. */
  99174. exposure: number;
  99175. /**
  99176. * Gets wether tonemapping is enabled or not.
  99177. */
  99178. /**
  99179. * Sets wether tonemapping is enabled or not
  99180. */
  99181. toneMappingEnabled: boolean;
  99182. /**
  99183. * Gets the type of tone mapping effect.
  99184. */
  99185. /**
  99186. * Sets the type of tone mapping effect.
  99187. */
  99188. toneMappingType: number;
  99189. /**
  99190. * Gets contrast used in the effect.
  99191. */
  99192. /**
  99193. * Sets contrast used in the effect.
  99194. */
  99195. contrast: number;
  99196. /**
  99197. * Gets Vignette stretch size.
  99198. */
  99199. /**
  99200. * Sets Vignette stretch size.
  99201. */
  99202. vignetteStretch: number;
  99203. /**
  99204. * Gets Vignette centre X Offset.
  99205. */
  99206. /**
  99207. * Sets Vignette centre X Offset.
  99208. */
  99209. vignetteCentreX: number;
  99210. /**
  99211. * Gets Vignette centre Y Offset.
  99212. */
  99213. /**
  99214. * Sets Vignette centre Y Offset.
  99215. */
  99216. vignetteCentreY: number;
  99217. /**
  99218. * Gets Vignette weight or intensity of the vignette effect.
  99219. */
  99220. /**
  99221. * Sets Vignette weight or intensity of the vignette effect.
  99222. */
  99223. vignetteWeight: number;
  99224. /**
  99225. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99226. * if vignetteEnabled is set to true.
  99227. */
  99228. /**
  99229. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99230. * if vignetteEnabled is set to true.
  99231. */
  99232. vignetteColor: Color4;
  99233. /**
  99234. * Gets Camera field of view used by the Vignette effect.
  99235. */
  99236. /**
  99237. * Sets Camera field of view used by the Vignette effect.
  99238. */
  99239. vignetteCameraFov: number;
  99240. /**
  99241. * Gets the vignette blend mode allowing different kind of effect.
  99242. */
  99243. /**
  99244. * Sets the vignette blend mode allowing different kind of effect.
  99245. */
  99246. vignetteBlendMode: number;
  99247. /**
  99248. * Gets wether the vignette effect is enabled.
  99249. */
  99250. /**
  99251. * Sets wether the vignette effect is enabled.
  99252. */
  99253. vignetteEnabled: boolean;
  99254. private _fromLinearSpace;
  99255. /**
  99256. * Gets wether the input of the processing is in Gamma or Linear Space.
  99257. */
  99258. /**
  99259. * Sets wether the input of the processing is in Gamma or Linear Space.
  99260. */
  99261. fromLinearSpace: boolean;
  99262. /**
  99263. * Defines cache preventing GC.
  99264. */
  99265. private _defines;
  99266. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99267. /**
  99268. * "ImageProcessingPostProcess"
  99269. * @returns "ImageProcessingPostProcess"
  99270. */
  99271. getClassName(): string;
  99272. protected _updateParameters(): void;
  99273. dispose(camera?: Camera): void;
  99274. }
  99275. }
  99276. declare module BABYLON {
  99277. /**
  99278. * Class containing static functions to help procedurally build meshes
  99279. */
  99280. export class GroundBuilder {
  99281. /**
  99282. * Creates a ground mesh
  99283. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  99284. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  99285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99286. * @param name defines the name of the mesh
  99287. * @param options defines the options used to create the mesh
  99288. * @param scene defines the hosting scene
  99289. * @returns the ground mesh
  99290. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  99291. */
  99292. static CreateGround(name: string, options: {
  99293. width?: number;
  99294. height?: number;
  99295. subdivisions?: number;
  99296. subdivisionsX?: number;
  99297. subdivisionsY?: number;
  99298. updatable?: boolean;
  99299. }, scene: any): Mesh;
  99300. /**
  99301. * Creates a tiled ground mesh
  99302. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  99303. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  99304. * * 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
  99305. * * 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
  99306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99307. * @param name defines the name of the mesh
  99308. * @param options defines the options used to create the mesh
  99309. * @param scene defines the hosting scene
  99310. * @returns the tiled ground mesh
  99311. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  99312. */
  99313. static CreateTiledGround(name: string, options: {
  99314. xmin: number;
  99315. zmin: number;
  99316. xmax: number;
  99317. zmax: number;
  99318. subdivisions?: {
  99319. w: number;
  99320. h: number;
  99321. };
  99322. precision?: {
  99323. w: number;
  99324. h: number;
  99325. };
  99326. updatable?: boolean;
  99327. }, scene?: Nullable<Scene>): Mesh;
  99328. /**
  99329. * Creates a ground mesh from a height map
  99330. * * The parameter `url` sets the URL of the height map image resource.
  99331. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  99332. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  99333. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  99334. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  99335. * * 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.
  99336. * * 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).
  99337. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99339. * @param name defines the name of the mesh
  99340. * @param url defines the url to the height map
  99341. * @param options defines the options used to create the mesh
  99342. * @param scene defines the hosting scene
  99343. * @returns the ground mesh
  99344. * @see https://doc.babylonjs.com/babylon101/height_map
  99345. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  99346. */
  99347. static CreateGroundFromHeightMap(name: string, url: string, options: {
  99348. width?: number;
  99349. height?: number;
  99350. subdivisions?: number;
  99351. minHeight?: number;
  99352. maxHeight?: number;
  99353. colorFilter?: Color3;
  99354. alphaFilter?: number;
  99355. updatable?: boolean;
  99356. onReady?: (mesh: GroundMesh) => void;
  99357. }, scene?: Nullable<Scene>): GroundMesh;
  99358. }
  99359. }
  99360. declare module BABYLON {
  99361. /**
  99362. * Class containing static functions to help procedurally build meshes
  99363. */
  99364. export class TorusBuilder {
  99365. /**
  99366. * Creates a torus mesh
  99367. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  99368. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  99369. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  99370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99373. * @param name defines the name of the mesh
  99374. * @param options defines the options used to create the mesh
  99375. * @param scene defines the hosting scene
  99376. * @returns the torus mesh
  99377. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  99378. */
  99379. static CreateTorus(name: string, options: {
  99380. diameter?: number;
  99381. thickness?: number;
  99382. tessellation?: number;
  99383. updatable?: boolean;
  99384. sideOrientation?: number;
  99385. frontUVs?: Vector4;
  99386. backUVs?: Vector4;
  99387. }, scene: any): Mesh;
  99388. }
  99389. }
  99390. declare module BABYLON {
  99391. /**
  99392. * Class containing static functions to help procedurally build meshes
  99393. */
  99394. export class CylinderBuilder {
  99395. /**
  99396. * Creates a cylinder or a cone mesh
  99397. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  99398. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  99399. * * 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.
  99400. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  99401. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  99402. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  99403. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  99404. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  99405. * * 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).
  99406. * * 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
  99407. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  99408. * * 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
  99409. * * 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.
  99410. * * If `enclose` is false, a ring surface is one element.
  99411. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  99412. * * 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
  99413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99416. * @param name defines the name of the mesh
  99417. * @param options defines the options used to create the mesh
  99418. * @param scene defines the hosting scene
  99419. * @returns the cylinder mesh
  99420. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  99421. */
  99422. static CreateCylinder(name: string, options: {
  99423. height?: number;
  99424. diameterTop?: number;
  99425. diameterBottom?: number;
  99426. diameter?: number;
  99427. tessellation?: number;
  99428. subdivisions?: number;
  99429. arc?: number;
  99430. faceColors?: Color4[];
  99431. faceUV?: Vector4[];
  99432. updatable?: boolean;
  99433. hasRings?: boolean;
  99434. enclose?: boolean;
  99435. sideOrientation?: number;
  99436. frontUVs?: Vector4;
  99437. backUVs?: Vector4;
  99438. }, scene: any): Mesh;
  99439. }
  99440. }
  99441. declare module BABYLON {
  99442. /**
  99443. * Manager for handling gamepads
  99444. */
  99445. export class GamepadManager {
  99446. private _scene?;
  99447. private _babylonGamepads;
  99448. private _oneGamepadConnected;
  99449. /** @hidden */
  99450. _isMonitoring: boolean;
  99451. private _gamepadEventSupported;
  99452. private _gamepadSupport;
  99453. /**
  99454. * observable to be triggered when the gamepad controller has been connected
  99455. */
  99456. onGamepadConnectedObservable: Observable<Gamepad>;
  99457. /**
  99458. * observable to be triggered when the gamepad controller has been disconnected
  99459. */
  99460. onGamepadDisconnectedObservable: Observable<Gamepad>;
  99461. private _onGamepadConnectedEvent;
  99462. private _onGamepadDisconnectedEvent;
  99463. /**
  99464. * Initializes the gamepad manager
  99465. * @param _scene BabylonJS scene
  99466. */
  99467. constructor(_scene?: Scene | undefined);
  99468. /**
  99469. * The gamepads in the game pad manager
  99470. */
  99471. readonly gamepads: Gamepad[];
  99472. /**
  99473. * Get the gamepad controllers based on type
  99474. * @param type The type of gamepad controller
  99475. * @returns Nullable gamepad
  99476. */
  99477. getGamepadByType(type?: number): Nullable<Gamepad>;
  99478. /**
  99479. * Disposes the gamepad manager
  99480. */
  99481. dispose(): void;
  99482. private _addNewGamepad;
  99483. private _startMonitoringGamepads;
  99484. private _stopMonitoringGamepads;
  99485. /** @hidden */
  99486. _checkGamepadsStatus(): void;
  99487. private _updateGamepadObjects;
  99488. }
  99489. }
  99490. declare module BABYLON {
  99491. interface Scene {
  99492. /** @hidden */
  99493. _gamepadManager: Nullable<GamepadManager>;
  99494. /**
  99495. * Gets the gamepad manager associated with the scene
  99496. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  99497. */
  99498. gamepadManager: GamepadManager;
  99499. }
  99500. /**
  99501. * Interface representing a free camera inputs manager
  99502. */
  99503. interface FreeCameraInputsManager {
  99504. /**
  99505. * Adds gamepad input support to the FreeCameraInputsManager.
  99506. * @returns the FreeCameraInputsManager
  99507. */
  99508. addGamepad(): FreeCameraInputsManager;
  99509. }
  99510. /**
  99511. * Interface representing an arc rotate camera inputs manager
  99512. */
  99513. interface ArcRotateCameraInputsManager {
  99514. /**
  99515. * Adds gamepad input support to the ArcRotateCamera InputManager.
  99516. * @returns the camera inputs manager
  99517. */
  99518. addGamepad(): ArcRotateCameraInputsManager;
  99519. }
  99520. /**
  99521. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  99522. */
  99523. export class GamepadSystemSceneComponent implements ISceneComponent {
  99524. /**
  99525. * The component name helpfull to identify the component in the list of scene components.
  99526. */
  99527. readonly name: string;
  99528. /**
  99529. * The scene the component belongs to.
  99530. */
  99531. scene: Scene;
  99532. /**
  99533. * Creates a new instance of the component for the given scene
  99534. * @param scene Defines the scene to register the component in
  99535. */
  99536. constructor(scene: Scene);
  99537. /**
  99538. * Registers the component in a given scene
  99539. */
  99540. register(): void;
  99541. /**
  99542. * Rebuilds the elements related to this component in case of
  99543. * context lost for instance.
  99544. */
  99545. rebuild(): void;
  99546. /**
  99547. * Disposes the component and the associated ressources
  99548. */
  99549. dispose(): void;
  99550. private _beforeCameraUpdate;
  99551. }
  99552. }
  99553. declare module BABYLON {
  99554. /**
  99555. * Options to modify the vr teleportation behavior.
  99556. */
  99557. export interface VRTeleportationOptions {
  99558. /**
  99559. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99560. */
  99561. floorMeshName?: string;
  99562. /**
  99563. * A list of meshes to be used as the teleportation floor. (default: empty)
  99564. */
  99565. floorMeshes?: Mesh[];
  99566. }
  99567. /**
  99568. * Options to modify the vr experience helper's behavior.
  99569. */
  99570. export interface VRExperienceHelperOptions extends WebVROptions {
  99571. /**
  99572. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99573. */
  99574. createDeviceOrientationCamera?: boolean;
  99575. /**
  99576. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99577. */
  99578. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99579. /**
  99580. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99581. */
  99582. laserToggle?: boolean;
  99583. /**
  99584. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99585. */
  99586. floorMeshes?: Mesh[];
  99587. /**
  99588. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99589. */
  99590. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99591. }
  99592. /**
  99593. * Event containing information after VR has been entered
  99594. */
  99595. export class OnAfterEnteringVRObservableEvent {
  99596. /**
  99597. * If entering vr was successful
  99598. */
  99599. success: boolean;
  99600. }
  99601. /**
  99602. * Helps to quickly add VR support to an existing scene.
  99603. * See http://doc.babylonjs.com/how_to/webvr_helper
  99604. */
  99605. export class VRExperienceHelper {
  99606. /** Options to modify the vr experience helper's behavior. */
  99607. webVROptions: VRExperienceHelperOptions;
  99608. private _scene;
  99609. private _position;
  99610. private _btnVR;
  99611. private _btnVRDisplayed;
  99612. private _webVRsupported;
  99613. private _webVRready;
  99614. private _webVRrequesting;
  99615. private _webVRpresenting;
  99616. private _hasEnteredVR;
  99617. private _fullscreenVRpresenting;
  99618. private _canvas;
  99619. private _webVRCamera;
  99620. private _vrDeviceOrientationCamera;
  99621. private _deviceOrientationCamera;
  99622. private _existingCamera;
  99623. private _onKeyDown;
  99624. private _onVrDisplayPresentChange;
  99625. private _onVRDisplayChanged;
  99626. private _onVRRequestPresentStart;
  99627. private _onVRRequestPresentComplete;
  99628. /**
  99629. * Observable raised right before entering VR.
  99630. */
  99631. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99632. /**
  99633. * Observable raised when entering VR has completed.
  99634. */
  99635. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99636. /**
  99637. * Observable raised when exiting VR.
  99638. */
  99639. onExitingVRObservable: Observable<VRExperienceHelper>;
  99640. /**
  99641. * Observable raised when controller mesh is loaded.
  99642. */
  99643. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99644. /** Return this.onEnteringVRObservable
  99645. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99646. */
  99647. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99648. /** Return this.onExitingVRObservable
  99649. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99650. */
  99651. readonly onExitingVR: Observable<VRExperienceHelper>;
  99652. /** Return this.onControllerMeshLoadedObservable
  99653. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99654. */
  99655. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99656. private _rayLength;
  99657. private _useCustomVRButton;
  99658. private _teleportationRequested;
  99659. private _teleportActive;
  99660. private _floorMeshName;
  99661. private _floorMeshesCollection;
  99662. private _rotationAllowed;
  99663. private _teleportBackwardsVector;
  99664. private _teleportationTarget;
  99665. private _isDefaultTeleportationTarget;
  99666. private _postProcessMove;
  99667. private _teleportationFillColor;
  99668. private _teleportationBorderColor;
  99669. private _rotationAngle;
  99670. private _haloCenter;
  99671. private _cameraGazer;
  99672. private _padSensibilityUp;
  99673. private _padSensibilityDown;
  99674. private _leftController;
  99675. private _rightController;
  99676. /**
  99677. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99678. */
  99679. onNewMeshSelected: Observable<AbstractMesh>;
  99680. /**
  99681. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99682. */
  99683. onNewMeshPicked: Observable<PickingInfo>;
  99684. private _circleEase;
  99685. /**
  99686. * Observable raised before camera teleportation
  99687. */
  99688. onBeforeCameraTeleport: Observable<Vector3>;
  99689. /**
  99690. * Observable raised after camera teleportation
  99691. */
  99692. onAfterCameraTeleport: Observable<Vector3>;
  99693. /**
  99694. * Observable raised when current selected mesh gets unselected
  99695. */
  99696. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99697. private _raySelectionPredicate;
  99698. /**
  99699. * To be optionaly changed by user to define custom ray selection
  99700. */
  99701. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99702. /**
  99703. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99704. */
  99705. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99706. /**
  99707. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99708. */
  99709. teleportationEnabled: boolean;
  99710. private _defaultHeight;
  99711. private _teleportationInitialized;
  99712. private _interactionsEnabled;
  99713. private _interactionsRequested;
  99714. private _displayGaze;
  99715. private _displayLaserPointer;
  99716. /**
  99717. * The mesh used to display where the user is going to teleport.
  99718. */
  99719. /**
  99720. * Sets the mesh to be used to display where the user is going to teleport.
  99721. */
  99722. teleportationTarget: Mesh;
  99723. /**
  99724. * 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
  99725. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99726. * See http://doc.babylonjs.com/resources/baking_transformations
  99727. */
  99728. gazeTrackerMesh: Mesh;
  99729. /**
  99730. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99731. */
  99732. updateGazeTrackerScale: boolean;
  99733. /**
  99734. * If the gaze trackers color should be updated when selecting meshes
  99735. */
  99736. updateGazeTrackerColor: boolean;
  99737. /**
  99738. * The gaze tracking mesh corresponding to the left controller
  99739. */
  99740. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99741. /**
  99742. * The gaze tracking mesh corresponding to the right controller
  99743. */
  99744. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99745. /**
  99746. * If the ray of the gaze should be displayed.
  99747. */
  99748. /**
  99749. * Sets if the ray of the gaze should be displayed.
  99750. */
  99751. displayGaze: boolean;
  99752. /**
  99753. * If the ray of the LaserPointer should be displayed.
  99754. */
  99755. /**
  99756. * Sets if the ray of the LaserPointer should be displayed.
  99757. */
  99758. displayLaserPointer: boolean;
  99759. /**
  99760. * The deviceOrientationCamera used as the camera when not in VR.
  99761. */
  99762. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99763. /**
  99764. * Based on the current WebVR support, returns the current VR camera used.
  99765. */
  99766. readonly currentVRCamera: Nullable<Camera>;
  99767. /**
  99768. * The webVRCamera which is used when in VR.
  99769. */
  99770. readonly webVRCamera: WebVRFreeCamera;
  99771. /**
  99772. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99773. */
  99774. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99775. private readonly _teleportationRequestInitiated;
  99776. /**
  99777. * Defines wether or not Pointer lock should be requested when switching to
  99778. * full screen.
  99779. */
  99780. requestPointerLockOnFullScreen: boolean;
  99781. /**
  99782. * Instantiates a VRExperienceHelper.
  99783. * Helps to quickly add VR support to an existing scene.
  99784. * @param scene The scene the VRExperienceHelper belongs to.
  99785. * @param webVROptions Options to modify the vr experience helper's behavior.
  99786. */
  99787. constructor(scene: Scene,
  99788. /** Options to modify the vr experience helper's behavior. */
  99789. webVROptions?: VRExperienceHelperOptions);
  99790. private _onDefaultMeshLoaded;
  99791. private _onResize;
  99792. private _onFullscreenChange;
  99793. /**
  99794. * Gets a value indicating if we are currently in VR mode.
  99795. */
  99796. readonly isInVRMode: boolean;
  99797. private onVrDisplayPresentChange;
  99798. private onVRDisplayChanged;
  99799. private moveButtonToBottomRight;
  99800. private displayVRButton;
  99801. private updateButtonVisibility;
  99802. private _cachedAngularSensibility;
  99803. /**
  99804. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99805. * Otherwise, will use the fullscreen API.
  99806. */
  99807. enterVR(): void;
  99808. /**
  99809. * Attempt to exit VR, or fullscreen.
  99810. */
  99811. exitVR(): void;
  99812. /**
  99813. * The position of the vr experience helper.
  99814. */
  99815. /**
  99816. * Sets the position of the vr experience helper.
  99817. */
  99818. position: Vector3;
  99819. /**
  99820. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99821. */
  99822. enableInteractions(): void;
  99823. private readonly _noControllerIsActive;
  99824. private beforeRender;
  99825. private _isTeleportationFloor;
  99826. /**
  99827. * Adds a floor mesh to be used for teleportation.
  99828. * @param floorMesh the mesh to be used for teleportation.
  99829. */
  99830. addFloorMesh(floorMesh: Mesh): void;
  99831. /**
  99832. * Removes a floor mesh from being used for teleportation.
  99833. * @param floorMesh the mesh to be removed.
  99834. */
  99835. removeFloorMesh(floorMesh: Mesh): void;
  99836. /**
  99837. * Enables interactions and teleportation using the VR controllers and gaze.
  99838. * @param vrTeleportationOptions options to modify teleportation behavior.
  99839. */
  99840. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99841. private _onNewGamepadConnected;
  99842. private _tryEnableInteractionOnController;
  99843. private _onNewGamepadDisconnected;
  99844. private _enableInteractionOnController;
  99845. private _checkTeleportWithRay;
  99846. private _checkRotate;
  99847. private _checkTeleportBackwards;
  99848. private _enableTeleportationOnController;
  99849. private _createTeleportationCircles;
  99850. private _displayTeleportationTarget;
  99851. private _hideTeleportationTarget;
  99852. private _rotateCamera;
  99853. private _moveTeleportationSelectorTo;
  99854. private _workingVector;
  99855. private _workingQuaternion;
  99856. private _workingMatrix;
  99857. /**
  99858. * Teleports the users feet to the desired location
  99859. * @param location The location where the user's feet should be placed
  99860. */
  99861. teleportCamera(location: Vector3): void;
  99862. private _convertNormalToDirectionOfRay;
  99863. private _castRayAndSelectObject;
  99864. private _notifySelectedMeshUnselected;
  99865. /**
  99866. * Sets the color of the laser ray from the vr controllers.
  99867. * @param color new color for the ray.
  99868. */
  99869. changeLaserColor(color: Color3): void;
  99870. /**
  99871. * Sets the color of the ray from the vr headsets gaze.
  99872. * @param color new color for the ray.
  99873. */
  99874. changeGazeColor(color: Color3): void;
  99875. /**
  99876. * Exits VR and disposes of the vr experience helper
  99877. */
  99878. dispose(): void;
  99879. /**
  99880. * Gets the name of the VRExperienceHelper class
  99881. * @returns "VRExperienceHelper"
  99882. */
  99883. getClassName(): string;
  99884. }
  99885. }
  99886. declare module BABYLON {
  99887. /**
  99888. * Manages an XRSession
  99889. * @see https://doc.babylonjs.com/how_to/webxr
  99890. */
  99891. export class WebXRSessionManager implements IDisposable {
  99892. private scene;
  99893. /**
  99894. * Fires every time a new xrFrame arrives which can be used to update the camera
  99895. */
  99896. onXRFrameObservable: Observable<any>;
  99897. /**
  99898. * Fires when the xr session is ended either by the device or manually done
  99899. */
  99900. onXRSessionEnded: Observable<any>;
  99901. /** @hidden */
  99902. _xrSession: XRSession;
  99903. /** @hidden */
  99904. _frameOfReference: XRFrameOfReference;
  99905. /** @hidden */
  99906. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99907. /** @hidden */
  99908. _currentXRFrame: Nullable<XRFrame>;
  99909. private _xrNavigator;
  99910. private _xrDevice;
  99911. private _tmpMatrix;
  99912. /**
  99913. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99914. * @param scene The scene which the session should be created for
  99915. */
  99916. constructor(scene: Scene);
  99917. /**
  99918. * Initializes the manager
  99919. * After initialization enterXR can be called to start an XR session
  99920. * @returns Promise which resolves after it is initialized
  99921. */
  99922. initializeAsync(): Promise<void>;
  99923. /**
  99924. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99925. * @param sessionCreationOptions xr options to create the session with
  99926. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99927. * @returns Promise which resolves after it enters XR
  99928. */
  99929. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99930. /**
  99931. * Stops the xrSession and restores the renderloop
  99932. * @returns Promise which resolves after it exits XR
  99933. */
  99934. exitXRAsync(): Promise<void>;
  99935. /**
  99936. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99937. * @param ray ray to cast into the environment
  99938. * @returns Promise which resolves with a collision point in the environment if it exists
  99939. */
  99940. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99941. /**
  99942. * Checks if a session would be supported for the creation options specified
  99943. * @param options creation options to check if they are supported
  99944. * @returns true if supported
  99945. */
  99946. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99947. /**
  99948. * @hidden
  99949. * Converts the render layer of xrSession to a render target
  99950. * @param session session to create render target for
  99951. * @param scene scene the new render target should be created for
  99952. */
  99953. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99954. /**
  99955. * Disposes of the session manager
  99956. */
  99957. dispose(): void;
  99958. }
  99959. }
  99960. declare module BABYLON {
  99961. /**
  99962. * WebXR Camera which holds the views for the xrSession
  99963. * @see https://doc.babylonjs.com/how_to/webxr
  99964. */
  99965. export class WebXRCamera extends FreeCamera {
  99966. private static _TmpMatrix;
  99967. /**
  99968. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99969. * @param name the name of the camera
  99970. * @param scene the scene to add the camera to
  99971. */
  99972. constructor(name: string, scene: Scene);
  99973. private _updateNumberOfRigCameras;
  99974. /** @hidden */
  99975. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99976. /**
  99977. * Updates the cameras position from the current pose information of the XR session
  99978. * @param xrSessionManager the session containing pose information
  99979. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99980. */
  99981. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99982. }
  99983. }
  99984. declare module BABYLON {
  99985. /**
  99986. * States of the webXR experience
  99987. */
  99988. export enum WebXRState {
  99989. /**
  99990. * Transitioning to being in XR mode
  99991. */
  99992. ENTERING_XR = 0,
  99993. /**
  99994. * Transitioning to non XR mode
  99995. */
  99996. EXITING_XR = 1,
  99997. /**
  99998. * In XR mode and presenting
  99999. */
  100000. IN_XR = 2,
  100001. /**
  100002. * Not entered XR mode
  100003. */
  100004. NOT_IN_XR = 3
  100005. }
  100006. /**
  100007. * Helper class used to enable XR
  100008. * @see https://doc.babylonjs.com/how_to/webxr
  100009. */
  100010. export class WebXRExperienceHelper implements IDisposable {
  100011. private scene;
  100012. /**
  100013. * 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
  100014. */
  100015. container: AbstractMesh;
  100016. /**
  100017. * Camera used to render xr content
  100018. */
  100019. camera: WebXRCamera;
  100020. /**
  100021. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  100022. */
  100023. state: WebXRState;
  100024. private _setState;
  100025. private static _TmpVector;
  100026. /**
  100027. * Fires when the state of the experience helper has changed
  100028. */
  100029. onStateChangedObservable: Observable<WebXRState>;
  100030. /** @hidden */
  100031. _sessionManager: WebXRSessionManager;
  100032. private _nonVRCamera;
  100033. private _originalSceneAutoClear;
  100034. private _supported;
  100035. /**
  100036. * Creates the experience helper
  100037. * @param scene the scene to attach the experience helper to
  100038. * @returns a promise for the experience helper
  100039. */
  100040. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  100041. /**
  100042. * Creates a WebXRExperienceHelper
  100043. * @param scene The scene the helper should be created in
  100044. */
  100045. private constructor();
  100046. /**
  100047. * Exits XR mode and returns the scene to its original state
  100048. * @returns promise that resolves after xr mode has exited
  100049. */
  100050. exitXRAsync(): Promise<void>;
  100051. /**
  100052. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  100053. * @param sessionCreationOptions options for the XR session
  100054. * @param frameOfReference frame of reference of the XR session
  100055. * @returns promise that resolves after xr mode has entered
  100056. */
  100057. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  100058. /**
  100059. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100060. * @param ray ray to cast into the environment
  100061. * @returns Promise which resolves with a collision point in the environment if it exists
  100062. */
  100063. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100064. /**
  100065. * Updates the global position of the camera by moving the camera's container
  100066. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  100067. * @param position The desired global position of the camera
  100068. */
  100069. setPositionOfCameraUsingContainer(position: Vector3): void;
  100070. /**
  100071. * Rotates the xr camera by rotating the camera's container around the camera's position
  100072. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  100073. * @param rotation the desired quaternion rotation to apply to the camera
  100074. */
  100075. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  100076. /**
  100077. * Checks if the creation options are supported by the xr session
  100078. * @param options creation options
  100079. * @returns true if supported
  100080. */
  100081. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100082. /**
  100083. * Disposes of the experience helper
  100084. */
  100085. dispose(): void;
  100086. }
  100087. }
  100088. declare module BABYLON {
  100089. /**
  100090. * Button which can be used to enter a different mode of XR
  100091. */
  100092. export class WebXREnterExitUIButton {
  100093. /** button element */
  100094. element: HTMLElement;
  100095. /** XR initialization options for the button */
  100096. initializationOptions: XRSessionCreationOptions;
  100097. /**
  100098. * Creates a WebXREnterExitUIButton
  100099. * @param element button element
  100100. * @param initializationOptions XR initialization options for the button
  100101. */
  100102. constructor(
  100103. /** button element */
  100104. element: HTMLElement,
  100105. /** XR initialization options for the button */
  100106. initializationOptions: XRSessionCreationOptions);
  100107. /**
  100108. * Overwritable function which can be used to update the button's visuals when the state changes
  100109. * @param activeButton the current active button in the UI
  100110. */
  100111. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  100112. }
  100113. /**
  100114. * Options to create the webXR UI
  100115. */
  100116. export class WebXREnterExitUIOptions {
  100117. /**
  100118. * Context to enter xr with
  100119. */
  100120. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  100121. /**
  100122. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  100123. */
  100124. customButtons?: Array<WebXREnterExitUIButton>;
  100125. }
  100126. /**
  100127. * UI to allow the user to enter/exit XR mode
  100128. */
  100129. export class WebXREnterExitUI implements IDisposable {
  100130. private scene;
  100131. private _overlay;
  100132. private _buttons;
  100133. private _activeButton;
  100134. /**
  100135. * Fired every time the active button is changed.
  100136. *
  100137. * When xr is entered via a button that launches xr that button will be the callback parameter
  100138. *
  100139. * When exiting xr the callback parameter will be null)
  100140. */
  100141. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  100142. /**
  100143. * Creates UI to allow the user to enter/exit XR mode
  100144. * @param scene the scene to add the ui to
  100145. * @param helper the xr experience helper to enter/exit xr with
  100146. * @param options options to configure the UI
  100147. * @returns the created ui
  100148. */
  100149. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  100150. private constructor();
  100151. private _updateButtons;
  100152. /**
  100153. * Disposes of the object
  100154. */
  100155. dispose(): void;
  100156. }
  100157. }
  100158. declare module BABYLON {
  100159. /**
  100160. * Represents an XR input
  100161. */
  100162. export class WebXRController {
  100163. /**
  100164. * 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
  100165. */
  100166. grip?: AbstractMesh;
  100167. /**
  100168. * Pointer which can be used to select objects or attach a visible laser to
  100169. */
  100170. pointer: AbstractMesh;
  100171. /**
  100172. * Creates the controller
  100173. * @see https://doc.babylonjs.com/how_to/webxr
  100174. * @param scene the scene which the controller should be associated to
  100175. */
  100176. constructor(scene: Scene);
  100177. /**
  100178. * Disposes of the object
  100179. */
  100180. dispose(): void;
  100181. }
  100182. /**
  100183. * XR input used to track XR inputs such as controllers/rays
  100184. */
  100185. export class WebXRInput implements IDisposable {
  100186. private helper;
  100187. /**
  100188. * XR controllers being tracked
  100189. */
  100190. controllers: Array<WebXRController>;
  100191. private _tmpMatrix;
  100192. private _frameObserver;
  100193. /**
  100194. * Initializes the WebXRInput
  100195. * @param helper experience helper which the input should be created for
  100196. */
  100197. constructor(helper: WebXRExperienceHelper);
  100198. /**
  100199. * Disposes of the object
  100200. */
  100201. dispose(): void;
  100202. }
  100203. }
  100204. declare module BABYLON {
  100205. /**
  100206. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  100207. */
  100208. export class WebXRManagedOutputCanvas implements IDisposable {
  100209. private _canvas;
  100210. /**
  100211. * xrpresent context of the canvas which can be used to display/mirror xr content
  100212. */
  100213. canvasContext: Nullable<WebGLRenderingContext>;
  100214. /**
  100215. * Initializes the canvas to be added/removed upon entering/exiting xr
  100216. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  100217. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  100218. */
  100219. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  100220. /**
  100221. * Disposes of the object
  100222. */
  100223. dispose(): void;
  100224. private _setManagedOutputCanvas;
  100225. private _addCanvas;
  100226. private _removeCanvas;
  100227. }
  100228. }
  100229. declare module BABYLON {
  100230. /**
  100231. * Contains an array of blocks representing the octree
  100232. */
  100233. export interface IOctreeContainer<T> {
  100234. /**
  100235. * Blocks within the octree
  100236. */
  100237. blocks: Array<OctreeBlock<T>>;
  100238. }
  100239. /**
  100240. * Class used to store a cell in an octree
  100241. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100242. */
  100243. export class OctreeBlock<T> {
  100244. /**
  100245. * Gets the content of the current block
  100246. */
  100247. entries: T[];
  100248. /**
  100249. * Gets the list of block children
  100250. */
  100251. blocks: Array<OctreeBlock<T>>;
  100252. private _depth;
  100253. private _maxDepth;
  100254. private _capacity;
  100255. private _minPoint;
  100256. private _maxPoint;
  100257. private _boundingVectors;
  100258. private _creationFunc;
  100259. /**
  100260. * Creates a new block
  100261. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  100262. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  100263. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100264. * @param depth defines the current depth of this block in the octree
  100265. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  100266. * @param creationFunc defines a callback to call when an element is added to the block
  100267. */
  100268. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  100269. /**
  100270. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100271. */
  100272. readonly capacity: number;
  100273. /**
  100274. * Gets the minimum vector (in world space) of the block's bounding box
  100275. */
  100276. readonly minPoint: Vector3;
  100277. /**
  100278. * Gets the maximum vector (in world space) of the block's bounding box
  100279. */
  100280. readonly maxPoint: Vector3;
  100281. /**
  100282. * Add a new element to this block
  100283. * @param entry defines the element to add
  100284. */
  100285. addEntry(entry: T): void;
  100286. /**
  100287. * Remove an element from this block
  100288. * @param entry defines the element to remove
  100289. */
  100290. removeEntry(entry: T): void;
  100291. /**
  100292. * Add an array of elements to this block
  100293. * @param entries defines the array of elements to add
  100294. */
  100295. addEntries(entries: T[]): void;
  100296. /**
  100297. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  100298. * @param frustumPlanes defines the frustum planes to test
  100299. * @param selection defines the array to store current content if selection is positive
  100300. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100301. */
  100302. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100303. /**
  100304. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  100305. * @param sphereCenter defines the bounding sphere center
  100306. * @param sphereRadius defines the bounding sphere radius
  100307. * @param selection defines the array to store current content if selection is positive
  100308. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100309. */
  100310. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100311. /**
  100312. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  100313. * @param ray defines the ray to test with
  100314. * @param selection defines the array to store current content if selection is positive
  100315. */
  100316. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  100317. /**
  100318. * Subdivide the content into child blocks (this block will then be empty)
  100319. */
  100320. createInnerBlocks(): void;
  100321. /**
  100322. * @hidden
  100323. */
  100324. 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;
  100325. }
  100326. }
  100327. declare module BABYLON {
  100328. /**
  100329. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  100330. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100331. */
  100332. export class Octree<T> {
  100333. /** 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.) */
  100334. maxDepth: number;
  100335. /**
  100336. * Blocks within the octree containing objects
  100337. */
  100338. blocks: Array<OctreeBlock<T>>;
  100339. /**
  100340. * Content stored in the octree
  100341. */
  100342. dynamicContent: T[];
  100343. private _maxBlockCapacity;
  100344. private _selectionContent;
  100345. private _creationFunc;
  100346. /**
  100347. * Creates a octree
  100348. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100349. * @param creationFunc function to be used to instatiate the octree
  100350. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  100351. * @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.)
  100352. */
  100353. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  100354. /** 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.) */
  100355. maxDepth?: number);
  100356. /**
  100357. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  100358. * @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);
  100359. * @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);
  100360. * @param entries meshes to be added to the octree blocks
  100361. */
  100362. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  100363. /**
  100364. * Adds a mesh to the octree
  100365. * @param entry Mesh to add to the octree
  100366. */
  100367. addMesh(entry: T): void;
  100368. /**
  100369. * Remove an element from the octree
  100370. * @param entry defines the element to remove
  100371. */
  100372. removeMesh(entry: T): void;
  100373. /**
  100374. * Selects an array of meshes within the frustum
  100375. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  100376. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  100377. * @returns array of meshes within the frustum
  100378. */
  100379. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  100380. /**
  100381. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  100382. * @param sphereCenter defines the bounding sphere center
  100383. * @param sphereRadius defines the bounding sphere radius
  100384. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100385. * @returns an array of objects that intersect the sphere
  100386. */
  100387. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  100388. /**
  100389. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  100390. * @param ray defines the ray to test with
  100391. * @returns array of intersected objects
  100392. */
  100393. intersectsRay(ray: Ray): SmartArray<T>;
  100394. /**
  100395. * Adds a mesh into the octree block if it intersects the block
  100396. */
  100397. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  100398. /**
  100399. * Adds a submesh into the octree block if it intersects the block
  100400. */
  100401. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  100402. }
  100403. }
  100404. declare module BABYLON {
  100405. interface Scene {
  100406. /**
  100407. * @hidden
  100408. * Backing Filed
  100409. */
  100410. _selectionOctree: Octree<AbstractMesh>;
  100411. /**
  100412. * Gets the octree used to boost mesh selection (picking)
  100413. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100414. */
  100415. selectionOctree: Octree<AbstractMesh>;
  100416. /**
  100417. * Creates or updates the octree used to boost selection (picking)
  100418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100419. * @param maxCapacity defines the maximum capacity per leaf
  100420. * @param maxDepth defines the maximum depth of the octree
  100421. * @returns an octree of AbstractMesh
  100422. */
  100423. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  100424. }
  100425. interface AbstractMesh {
  100426. /**
  100427. * @hidden
  100428. * Backing Field
  100429. */
  100430. _submeshesOctree: Octree<SubMesh>;
  100431. /**
  100432. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  100433. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  100434. * @param maxCapacity defines the maximum size of each block (64 by default)
  100435. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  100436. * @returns the new octree
  100437. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  100438. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100439. */
  100440. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  100441. }
  100442. /**
  100443. * Defines the octree scene component responsible to manage any octrees
  100444. * in a given scene.
  100445. */
  100446. export class OctreeSceneComponent {
  100447. /**
  100448. * The component name help to identify the component in the list of scene components.
  100449. */
  100450. readonly name: string;
  100451. /**
  100452. * The scene the component belongs to.
  100453. */
  100454. scene: Scene;
  100455. /**
  100456. * Indicates if the meshes have been checked to make sure they are isEnabled()
  100457. */
  100458. readonly checksIsEnabled: boolean;
  100459. /**
  100460. * Creates a new instance of the component for the given scene
  100461. * @param scene Defines the scene to register the component in
  100462. */
  100463. constructor(scene: Scene);
  100464. /**
  100465. * Registers the component in a given scene
  100466. */
  100467. register(): void;
  100468. /**
  100469. * Return the list of active meshes
  100470. * @returns the list of active meshes
  100471. */
  100472. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100473. /**
  100474. * Return the list of active sub meshes
  100475. * @param mesh The mesh to get the candidates sub meshes from
  100476. * @returns the list of active sub meshes
  100477. */
  100478. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100479. private _tempRay;
  100480. /**
  100481. * Return the list of sub meshes intersecting with a given local ray
  100482. * @param mesh defines the mesh to find the submesh for
  100483. * @param localRay defines the ray in local space
  100484. * @returns the list of intersecting sub meshes
  100485. */
  100486. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  100487. /**
  100488. * Return the list of sub meshes colliding with a collider
  100489. * @param mesh defines the mesh to find the submesh for
  100490. * @param collider defines the collider to evaluate the collision against
  100491. * @returns the list of colliding sub meshes
  100492. */
  100493. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  100494. /**
  100495. * Rebuilds the elements related to this component in case of
  100496. * context lost for instance.
  100497. */
  100498. rebuild(): void;
  100499. /**
  100500. * Disposes the component and the associated ressources.
  100501. */
  100502. dispose(): void;
  100503. }
  100504. }
  100505. declare module BABYLON {
  100506. /**
  100507. * Renders a layer on top of an existing scene
  100508. */
  100509. export class UtilityLayerRenderer implements IDisposable {
  100510. /** the original scene that will be rendered on top of */
  100511. originalScene: Scene;
  100512. private _pointerCaptures;
  100513. private _lastPointerEvents;
  100514. private static _DefaultUtilityLayer;
  100515. private static _DefaultKeepDepthUtilityLayer;
  100516. private _sharedGizmoLight;
  100517. /**
  100518. * @hidden
  100519. * Light which used by gizmos to get light shading
  100520. */
  100521. _getSharedGizmoLight(): HemisphericLight;
  100522. /**
  100523. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100524. */
  100525. pickUtilitySceneFirst: boolean;
  100526. /**
  100527. * 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)
  100528. */
  100529. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100530. /**
  100531. * 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)
  100532. */
  100533. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100534. /**
  100535. * The scene that is rendered on top of the original scene
  100536. */
  100537. utilityLayerScene: Scene;
  100538. /**
  100539. * If the utility layer should automatically be rendered on top of existing scene
  100540. */
  100541. shouldRender: boolean;
  100542. /**
  100543. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100544. */
  100545. onlyCheckPointerDownEvents: boolean;
  100546. /**
  100547. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100548. */
  100549. processAllEvents: boolean;
  100550. /**
  100551. * Observable raised when the pointer move from the utility layer scene to the main scene
  100552. */
  100553. onPointerOutObservable: Observable<number>;
  100554. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100555. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100556. private _afterRenderObserver;
  100557. private _sceneDisposeObserver;
  100558. private _originalPointerObserver;
  100559. /**
  100560. * Instantiates a UtilityLayerRenderer
  100561. * @param originalScene the original scene that will be rendered on top of
  100562. * @param handleEvents boolean indicating if the utility layer should handle events
  100563. */
  100564. constructor(
  100565. /** the original scene that will be rendered on top of */
  100566. originalScene: Scene, handleEvents?: boolean);
  100567. private _notifyObservers;
  100568. /**
  100569. * Renders the utility layers scene on top of the original scene
  100570. */
  100571. render(): void;
  100572. /**
  100573. * Disposes of the renderer
  100574. */
  100575. dispose(): void;
  100576. private _updateCamera;
  100577. }
  100578. }
  100579. declare module BABYLON {
  100580. /**
  100581. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100582. */
  100583. export class Gizmo implements IDisposable {
  100584. /** The utility layer the gizmo will be added to */
  100585. gizmoLayer: UtilityLayerRenderer;
  100586. /**
  100587. * The root mesh of the gizmo
  100588. */
  100589. _rootMesh: Mesh;
  100590. private _attachedMesh;
  100591. /**
  100592. * Ratio for the scale of the gizmo (Default: 1)
  100593. */
  100594. scaleRatio: number;
  100595. /**
  100596. * If a custom mesh has been set (Default: false)
  100597. */
  100598. protected _customMeshSet: boolean;
  100599. /**
  100600. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100601. * * When set, interactions will be enabled
  100602. */
  100603. attachedMesh: Nullable<AbstractMesh>;
  100604. /**
  100605. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100606. * @param mesh The mesh to replace the default mesh of the gizmo
  100607. */
  100608. setCustomMesh(mesh: Mesh): void;
  100609. /**
  100610. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100611. */
  100612. updateGizmoRotationToMatchAttachedMesh: boolean;
  100613. /**
  100614. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100615. */
  100616. updateGizmoPositionToMatchAttachedMesh: boolean;
  100617. /**
  100618. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100619. */
  100620. protected _updateScale: boolean;
  100621. protected _interactionsEnabled: boolean;
  100622. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100623. private _beforeRenderObserver;
  100624. private _tempVector;
  100625. /**
  100626. * Creates a gizmo
  100627. * @param gizmoLayer The utility layer the gizmo will be added to
  100628. */
  100629. constructor(
  100630. /** The utility layer the gizmo will be added to */
  100631. gizmoLayer?: UtilityLayerRenderer);
  100632. /**
  100633. * Updates the gizmo to match the attached mesh's position/rotation
  100634. */
  100635. protected _update(): void;
  100636. /**
  100637. * Disposes of the gizmo
  100638. */
  100639. dispose(): void;
  100640. }
  100641. }
  100642. declare module BABYLON {
  100643. /**
  100644. * Single axis drag gizmo
  100645. */
  100646. export class AxisDragGizmo extends Gizmo {
  100647. /**
  100648. * Drag behavior responsible for the gizmos dragging interactions
  100649. */
  100650. dragBehavior: PointerDragBehavior;
  100651. private _pointerObserver;
  100652. /**
  100653. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100654. */
  100655. snapDistance: number;
  100656. /**
  100657. * Event that fires each time the gizmo snaps to a new location.
  100658. * * snapDistance is the the change in distance
  100659. */
  100660. onSnapObservable: Observable<{
  100661. snapDistance: number;
  100662. }>;
  100663. /** @hidden */
  100664. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100665. /** @hidden */
  100666. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100667. /**
  100668. * Creates an AxisDragGizmo
  100669. * @param gizmoLayer The utility layer the gizmo will be added to
  100670. * @param dragAxis The axis which the gizmo will be able to drag on
  100671. * @param color The color of the gizmo
  100672. */
  100673. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100674. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100675. /**
  100676. * Disposes of the gizmo
  100677. */
  100678. dispose(): void;
  100679. }
  100680. }
  100681. declare module BABYLON.Debug {
  100682. /**
  100683. * The Axes viewer will show 3 axes in a specific point in space
  100684. */
  100685. export class AxesViewer {
  100686. private _xAxis;
  100687. private _yAxis;
  100688. private _zAxis;
  100689. private _scaleLinesFactor;
  100690. private _instanced;
  100691. /**
  100692. * Gets the hosting scene
  100693. */
  100694. scene: Scene;
  100695. /**
  100696. * Gets or sets a number used to scale line length
  100697. */
  100698. scaleLines: number;
  100699. /** Gets the node hierarchy used to render x-axis */
  100700. readonly xAxis: TransformNode;
  100701. /** Gets the node hierarchy used to render y-axis */
  100702. readonly yAxis: TransformNode;
  100703. /** Gets the node hierarchy used to render z-axis */
  100704. readonly zAxis: TransformNode;
  100705. /**
  100706. * Creates a new AxesViewer
  100707. * @param scene defines the hosting scene
  100708. * @param scaleLines defines a number used to scale line length (1 by default)
  100709. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100710. * @param xAxis defines the node hierarchy used to render the x-axis
  100711. * @param yAxis defines the node hierarchy used to render the y-axis
  100712. * @param zAxis defines the node hierarchy used to render the z-axis
  100713. */
  100714. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100715. /**
  100716. * Force the viewer to update
  100717. * @param position defines the position of the viewer
  100718. * @param xaxis defines the x axis of the viewer
  100719. * @param yaxis defines the y axis of the viewer
  100720. * @param zaxis defines the z axis of the viewer
  100721. */
  100722. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100723. /**
  100724. * Creates an instance of this axes viewer.
  100725. * @returns a new axes viewer with instanced meshes
  100726. */
  100727. createInstance(): AxesViewer;
  100728. /** Releases resources */
  100729. dispose(): void;
  100730. private static _SetRenderingGroupId;
  100731. }
  100732. }
  100733. declare module BABYLON.Debug {
  100734. /**
  100735. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100736. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100737. */
  100738. export class BoneAxesViewer extends AxesViewer {
  100739. /**
  100740. * Gets or sets the target mesh where to display the axes viewer
  100741. */
  100742. mesh: Nullable<Mesh>;
  100743. /**
  100744. * Gets or sets the target bone where to display the axes viewer
  100745. */
  100746. bone: Nullable<Bone>;
  100747. /** Gets current position */
  100748. pos: Vector3;
  100749. /** Gets direction of X axis */
  100750. xaxis: Vector3;
  100751. /** Gets direction of Y axis */
  100752. yaxis: Vector3;
  100753. /** Gets direction of Z axis */
  100754. zaxis: Vector3;
  100755. /**
  100756. * Creates a new BoneAxesViewer
  100757. * @param scene defines the hosting scene
  100758. * @param bone defines the target bone
  100759. * @param mesh defines the target mesh
  100760. * @param scaleLines defines a scaling factor for line length (1 by default)
  100761. */
  100762. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100763. /**
  100764. * Force the viewer to update
  100765. */
  100766. update(): void;
  100767. /** Releases resources */
  100768. dispose(): void;
  100769. }
  100770. }
  100771. declare module BABYLON {
  100772. /**
  100773. * Interface used to define scene explorer extensibility option
  100774. */
  100775. export interface IExplorerExtensibilityOption {
  100776. /**
  100777. * Define the option label
  100778. */
  100779. label: string;
  100780. /**
  100781. * Defines the action to execute on click
  100782. */
  100783. action: (entity: any) => void;
  100784. }
  100785. /**
  100786. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100787. */
  100788. export interface IExplorerExtensibilityGroup {
  100789. /**
  100790. * Defines a predicate to test if a given type mut be extended
  100791. */
  100792. predicate: (entity: any) => boolean;
  100793. /**
  100794. * Gets the list of options added to a type
  100795. */
  100796. entries: IExplorerExtensibilityOption[];
  100797. }
  100798. /**
  100799. * Interface used to define the options to use to create the Inspector
  100800. */
  100801. export interface IInspectorOptions {
  100802. /**
  100803. * Display in overlay mode (default: false)
  100804. */
  100805. overlay?: boolean;
  100806. /**
  100807. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100808. */
  100809. globalRoot?: HTMLElement;
  100810. /**
  100811. * Display the Scene explorer
  100812. */
  100813. showExplorer?: boolean;
  100814. /**
  100815. * Display the property inspector
  100816. */
  100817. showInspector?: boolean;
  100818. /**
  100819. * Display in embed mode (both panes on the right)
  100820. */
  100821. embedMode?: boolean;
  100822. /**
  100823. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100824. */
  100825. handleResize?: boolean;
  100826. /**
  100827. * Allow the panes to popup (default: true)
  100828. */
  100829. enablePopup?: boolean;
  100830. /**
  100831. * Allow the panes to be closed by users (default: true)
  100832. */
  100833. enableClose?: boolean;
  100834. /**
  100835. * Optional list of extensibility entries
  100836. */
  100837. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100838. /**
  100839. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100840. */
  100841. inspectorURL?: string;
  100842. }
  100843. interface Scene {
  100844. /**
  100845. * @hidden
  100846. * Backing field
  100847. */
  100848. _debugLayer: DebugLayer;
  100849. /**
  100850. * Gets the debug layer (aka Inspector) associated with the scene
  100851. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100852. */
  100853. debugLayer: DebugLayer;
  100854. }
  100855. /**
  100856. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100857. * what is happening in your scene
  100858. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100859. */
  100860. export class DebugLayer {
  100861. /**
  100862. * Define the url to get the inspector script from.
  100863. * By default it uses the babylonjs CDN.
  100864. * @ignoreNaming
  100865. */
  100866. static InspectorURL: string;
  100867. private _scene;
  100868. private BJSINSPECTOR;
  100869. /**
  100870. * Observable triggered when a property is changed through the inspector.
  100871. */
  100872. onPropertyChangedObservable: Observable<{
  100873. object: any;
  100874. property: string;
  100875. value: any;
  100876. initialValue: any;
  100877. }>;
  100878. /**
  100879. * Instantiates a new debug layer.
  100880. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100881. * what is happening in your scene
  100882. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100883. * @param scene Defines the scene to inspect
  100884. */
  100885. constructor(scene: Scene);
  100886. /** Creates the inspector window. */
  100887. private _createInspector;
  100888. /**
  100889. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100890. * @param entity defines the entity to select
  100891. * @param lineContainerTitle defines the specific block to highlight
  100892. */
  100893. select(entity: any, lineContainerTitle?: string): void;
  100894. /** Get the inspector from bundle or global */
  100895. private _getGlobalInspector;
  100896. /**
  100897. * Get if the inspector is visible or not.
  100898. * @returns true if visible otherwise, false
  100899. */
  100900. isVisible(): boolean;
  100901. /**
  100902. * Hide the inspector and close its window.
  100903. */
  100904. hide(): void;
  100905. /**
  100906. * Launch the debugLayer.
  100907. * @param config Define the configuration of the inspector
  100908. * @return a promise fulfilled when the debug layer is visible
  100909. */
  100910. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100911. }
  100912. }
  100913. declare module BABYLON {
  100914. /**
  100915. * Class containing static functions to help procedurally build meshes
  100916. */
  100917. export class BoxBuilder {
  100918. /**
  100919. * Creates a box mesh
  100920. * * The parameter `size` sets the size (float) of each box side (default 1)
  100921. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100922. * * 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)
  100923. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100927. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100928. * @param name defines the name of the mesh
  100929. * @param options defines the options used to create the mesh
  100930. * @param scene defines the hosting scene
  100931. * @returns the box mesh
  100932. */
  100933. static CreateBox(name: string, options: {
  100934. size?: number;
  100935. width?: number;
  100936. height?: number;
  100937. depth?: number;
  100938. faceUV?: Vector4[];
  100939. faceColors?: Color4[];
  100940. sideOrientation?: number;
  100941. frontUVs?: Vector4;
  100942. backUVs?: Vector4;
  100943. wrap?: boolean;
  100944. topBaseAt?: number;
  100945. bottomBaseAt?: number;
  100946. updatable?: boolean;
  100947. }, scene?: Nullable<Scene>): Mesh;
  100948. }
  100949. }
  100950. declare module BABYLON {
  100951. /**
  100952. * Class containing static functions to help procedurally build meshes
  100953. */
  100954. export class SphereBuilder {
  100955. /**
  100956. * Creates a sphere mesh
  100957. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100958. * * 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`)
  100959. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100960. * * 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
  100961. * * 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)
  100962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100965. * @param name defines the name of the mesh
  100966. * @param options defines the options used to create the mesh
  100967. * @param scene defines the hosting scene
  100968. * @returns the sphere mesh
  100969. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100970. */
  100971. static CreateSphere(name: string, options: {
  100972. segments?: number;
  100973. diameter?: number;
  100974. diameterX?: number;
  100975. diameterY?: number;
  100976. diameterZ?: number;
  100977. arc?: number;
  100978. slice?: number;
  100979. sideOrientation?: number;
  100980. frontUVs?: Vector4;
  100981. backUVs?: Vector4;
  100982. updatable?: boolean;
  100983. }, scene: any): Mesh;
  100984. }
  100985. }
  100986. declare module BABYLON.Debug {
  100987. /**
  100988. * Used to show the physics impostor around the specific mesh
  100989. */
  100990. export class PhysicsViewer {
  100991. /** @hidden */
  100992. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  100993. /** @hidden */
  100994. protected _meshes: Array<Nullable<AbstractMesh>>;
  100995. /** @hidden */
  100996. protected _scene: Nullable<Scene>;
  100997. /** @hidden */
  100998. protected _numMeshes: number;
  100999. /** @hidden */
  101000. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  101001. private _renderFunction;
  101002. private _utilityLayer;
  101003. private _debugBoxMesh;
  101004. private _debugSphereMesh;
  101005. private _debugCylinderMesh;
  101006. private _debugMaterial;
  101007. private _debugMeshMeshes;
  101008. /**
  101009. * Creates a new PhysicsViewer
  101010. * @param scene defines the hosting scene
  101011. */
  101012. constructor(scene: Scene);
  101013. /** @hidden */
  101014. protected _updateDebugMeshes(): void;
  101015. /**
  101016. * Renders a specified physic impostor
  101017. * @param impostor defines the impostor to render
  101018. * @param targetMesh defines the mesh represented by the impostor
  101019. * @returns the new debug mesh used to render the impostor
  101020. */
  101021. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  101022. /**
  101023. * Hides a specified physic impostor
  101024. * @param impostor defines the impostor to hide
  101025. */
  101026. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  101027. private _getDebugMaterial;
  101028. private _getDebugBoxMesh;
  101029. private _getDebugSphereMesh;
  101030. private _getDebugCylinderMesh;
  101031. private _getDebugMeshMesh;
  101032. private _getDebugMesh;
  101033. /** Releases all resources */
  101034. dispose(): void;
  101035. }
  101036. }
  101037. declare module BABYLON {
  101038. /**
  101039. * Class containing static functions to help procedurally build meshes
  101040. */
  101041. export class LinesBuilder {
  101042. /**
  101043. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  101044. * * 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
  101045. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  101046. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  101047. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  101048. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  101049. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  101050. * * 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
  101051. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  101052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101053. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  101054. * @param name defines the name of the new line system
  101055. * @param options defines the options used to create the line system
  101056. * @param scene defines the hosting scene
  101057. * @returns a new line system mesh
  101058. */
  101059. static CreateLineSystem(name: string, options: {
  101060. lines: Vector3[][];
  101061. updatable?: boolean;
  101062. instance?: Nullable<LinesMesh>;
  101063. colors?: Nullable<Color4[][]>;
  101064. useVertexAlpha?: boolean;
  101065. }, scene: Nullable<Scene>): LinesMesh;
  101066. /**
  101067. * Creates a line mesh
  101068. * 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
  101069. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101070. * * The parameter `points` is an array successive Vector3
  101071. * * 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
  101072. * * The optional parameter `colors` is an array of successive Color4, one per line point
  101073. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  101074. * * When updating an instance, remember that only point positions can change, not the number of points
  101075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  101077. * @param name defines the name of the new line system
  101078. * @param options defines the options used to create the line system
  101079. * @param scene defines the hosting scene
  101080. * @returns a new line mesh
  101081. */
  101082. static CreateLines(name: string, options: {
  101083. points: Vector3[];
  101084. updatable?: boolean;
  101085. instance?: Nullable<LinesMesh>;
  101086. colors?: Color4[];
  101087. useVertexAlpha?: boolean;
  101088. }, scene?: Nullable<Scene>): LinesMesh;
  101089. /**
  101090. * Creates a dashed line mesh
  101091. * * 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
  101092. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101093. * * The parameter `points` is an array successive Vector3
  101094. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  101095. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  101096. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101097. * * 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
  101098. * * When updating an instance, remember that only point positions can change, not the number of points
  101099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101100. * @param name defines the name of the mesh
  101101. * @param options defines the options used to create the mesh
  101102. * @param scene defines the hosting scene
  101103. * @returns the dashed line mesh
  101104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  101105. */
  101106. static CreateDashedLines(name: string, options: {
  101107. points: Vector3[];
  101108. dashSize?: number;
  101109. gapSize?: number;
  101110. dashNb?: number;
  101111. updatable?: boolean;
  101112. instance?: LinesMesh;
  101113. }, scene?: Nullable<Scene>): LinesMesh;
  101114. }
  101115. }
  101116. declare module BABYLON {
  101117. /**
  101118. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101119. * in order to better appreciate the issue one might have.
  101120. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101121. */
  101122. export class RayHelper {
  101123. /**
  101124. * Defines the ray we are currently tryin to visualize.
  101125. */
  101126. ray: Nullable<Ray>;
  101127. private _renderPoints;
  101128. private _renderLine;
  101129. private _renderFunction;
  101130. private _scene;
  101131. private _updateToMeshFunction;
  101132. private _attachedToMesh;
  101133. private _meshSpaceDirection;
  101134. private _meshSpaceOrigin;
  101135. /**
  101136. * Helper function to create a colored helper in a scene in one line.
  101137. * @param ray Defines the ray we are currently tryin to visualize
  101138. * @param scene Defines the scene the ray is used in
  101139. * @param color Defines the color we want to see the ray in
  101140. * @returns The newly created ray helper.
  101141. */
  101142. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  101143. /**
  101144. * Instantiate a new ray helper.
  101145. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101146. * in order to better appreciate the issue one might have.
  101147. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101148. * @param ray Defines the ray we are currently tryin to visualize
  101149. */
  101150. constructor(ray: Ray);
  101151. /**
  101152. * Shows the ray we are willing to debug.
  101153. * @param scene Defines the scene the ray needs to be rendered in
  101154. * @param color Defines the color the ray needs to be rendered in
  101155. */
  101156. show(scene: Scene, color?: Color3): void;
  101157. /**
  101158. * Hides the ray we are debugging.
  101159. */
  101160. hide(): void;
  101161. private _render;
  101162. /**
  101163. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  101164. * @param mesh Defines the mesh we want the helper attached to
  101165. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  101166. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  101167. * @param length Defines the length of the ray
  101168. */
  101169. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  101170. /**
  101171. * Detach the ray helper from the mesh it has previously been attached to.
  101172. */
  101173. detachFromMesh(): void;
  101174. private _updateToMesh;
  101175. /**
  101176. * Dispose the helper and release its associated resources.
  101177. */
  101178. dispose(): void;
  101179. }
  101180. }
  101181. declare module BABYLON.Debug {
  101182. /**
  101183. * Class used to render a debug view of a given skeleton
  101184. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  101185. */
  101186. export class SkeletonViewer {
  101187. /** defines the skeleton to render */
  101188. skeleton: Skeleton;
  101189. /** defines the mesh attached to the skeleton */
  101190. mesh: AbstractMesh;
  101191. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101192. autoUpdateBonesMatrices: boolean;
  101193. /** defines the rendering group id to use with the viewer */
  101194. renderingGroupId: number;
  101195. /** Gets or sets the color used to render the skeleton */
  101196. color: Color3;
  101197. private _scene;
  101198. private _debugLines;
  101199. private _debugMesh;
  101200. private _isEnabled;
  101201. private _renderFunction;
  101202. private _utilityLayer;
  101203. /**
  101204. * Returns the mesh used to render the bones
  101205. */
  101206. readonly debugMesh: Nullable<LinesMesh>;
  101207. /**
  101208. * Creates a new SkeletonViewer
  101209. * @param skeleton defines the skeleton to render
  101210. * @param mesh defines the mesh attached to the skeleton
  101211. * @param scene defines the hosting scene
  101212. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  101213. * @param renderingGroupId defines the rendering group id to use with the viewer
  101214. */
  101215. constructor(
  101216. /** defines the skeleton to render */
  101217. skeleton: Skeleton,
  101218. /** defines the mesh attached to the skeleton */
  101219. mesh: AbstractMesh, scene: Scene,
  101220. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101221. autoUpdateBonesMatrices?: boolean,
  101222. /** defines the rendering group id to use with the viewer */
  101223. renderingGroupId?: number);
  101224. /** Gets or sets a boolean indicating if the viewer is enabled */
  101225. isEnabled: boolean;
  101226. private _getBonePosition;
  101227. private _getLinesForBonesWithLength;
  101228. private _getLinesForBonesNoLength;
  101229. /** Update the viewer to sync with current skeleton state */
  101230. update(): void;
  101231. /** Release associated resources */
  101232. dispose(): void;
  101233. }
  101234. }
  101235. declare module BABYLON {
  101236. /**
  101237. * Options to create the null engine
  101238. */
  101239. export class NullEngineOptions {
  101240. /**
  101241. * Render width (Default: 512)
  101242. */
  101243. renderWidth: number;
  101244. /**
  101245. * Render height (Default: 256)
  101246. */
  101247. renderHeight: number;
  101248. /**
  101249. * Texture size (Default: 512)
  101250. */
  101251. textureSize: number;
  101252. /**
  101253. * If delta time between frames should be constant
  101254. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101255. */
  101256. deterministicLockstep: boolean;
  101257. /**
  101258. * Maximum about of steps between frames (Default: 4)
  101259. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101260. */
  101261. lockstepMaxSteps: number;
  101262. }
  101263. /**
  101264. * The null engine class provides support for headless version of babylon.js.
  101265. * This can be used in server side scenario or for testing purposes
  101266. */
  101267. export class NullEngine extends Engine {
  101268. private _options;
  101269. /**
  101270. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101271. */
  101272. isDeterministicLockStep(): boolean;
  101273. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  101274. getLockstepMaxSteps(): number;
  101275. /**
  101276. * Sets hardware scaling, used to save performance if needed
  101277. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101278. */
  101279. getHardwareScalingLevel(): number;
  101280. constructor(options?: NullEngineOptions);
  101281. createVertexBuffer(vertices: FloatArray): DataBuffer;
  101282. createIndexBuffer(indices: IndicesArray): DataBuffer;
  101283. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101284. getRenderWidth(useScreen?: boolean): number;
  101285. getRenderHeight(useScreen?: boolean): number;
  101286. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  101287. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  101288. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101289. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101290. bindSamplers(effect: Effect): void;
  101291. enableEffect(effect: Effect): void;
  101292. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101293. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  101294. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  101295. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  101296. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  101297. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  101298. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  101299. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  101300. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  101301. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  101302. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  101303. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  101304. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  101305. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  101306. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  101307. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101308. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101309. setFloat(uniform: WebGLUniformLocation, value: number): void;
  101310. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  101311. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  101312. setBool(uniform: WebGLUniformLocation, bool: number): void;
  101313. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  101314. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  101315. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  101316. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101317. bindBuffers(vertexBuffers: {
  101318. [key: string]: VertexBuffer;
  101319. }, indexBuffer: DataBuffer, effect: Effect): void;
  101320. wipeCaches(bruteForce?: boolean): void;
  101321. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101322. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101323. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101324. /** @hidden */
  101325. _createTexture(): WebGLTexture;
  101326. /** @hidden */
  101327. _releaseTexture(texture: InternalTexture): void;
  101328. 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;
  101329. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  101330. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  101331. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  101332. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101333. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  101334. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  101335. areAllEffectsReady(): boolean;
  101336. /**
  101337. * @hidden
  101338. * Get the current error code of the webGL context
  101339. * @returns the error code
  101340. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  101341. */
  101342. getError(): number;
  101343. /** @hidden */
  101344. _getUnpackAlignement(): number;
  101345. /** @hidden */
  101346. _unpackFlipY(value: boolean): void;
  101347. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  101348. /**
  101349. * Updates a dynamic vertex buffer.
  101350. * @param vertexBuffer the vertex buffer to update
  101351. * @param data the data used to update the vertex buffer
  101352. * @param byteOffset the byte offset of the data (optional)
  101353. * @param byteLength the byte length of the data (optional)
  101354. */
  101355. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  101356. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  101357. /** @hidden */
  101358. _bindTexture(channel: number, texture: InternalTexture): void;
  101359. /** @hidden */
  101360. _releaseBuffer(buffer: DataBuffer): boolean;
  101361. releaseEffects(): void;
  101362. displayLoadingUI(): void;
  101363. hideLoadingUI(): void;
  101364. /** @hidden */
  101365. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101366. /** @hidden */
  101367. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101368. /** @hidden */
  101369. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101370. /** @hidden */
  101371. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  101372. }
  101373. }
  101374. declare module BABYLON {
  101375. /** @hidden */
  101376. export class _OcclusionDataStorage {
  101377. /** @hidden */
  101378. occlusionInternalRetryCounter: number;
  101379. /** @hidden */
  101380. isOcclusionQueryInProgress: boolean;
  101381. /** @hidden */
  101382. isOccluded: boolean;
  101383. /** @hidden */
  101384. occlusionRetryCount: number;
  101385. /** @hidden */
  101386. occlusionType: number;
  101387. /** @hidden */
  101388. occlusionQueryAlgorithmType: number;
  101389. }
  101390. interface Engine {
  101391. /**
  101392. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  101393. * @return the new query
  101394. */
  101395. createQuery(): WebGLQuery;
  101396. /**
  101397. * Delete and release a webGL query
  101398. * @param query defines the query to delete
  101399. * @return the current engine
  101400. */
  101401. deleteQuery(query: WebGLQuery): Engine;
  101402. /**
  101403. * Check if a given query has resolved and got its value
  101404. * @param query defines the query to check
  101405. * @returns true if the query got its value
  101406. */
  101407. isQueryResultAvailable(query: WebGLQuery): boolean;
  101408. /**
  101409. * Gets the value of a given query
  101410. * @param query defines the query to check
  101411. * @returns the value of the query
  101412. */
  101413. getQueryResult(query: WebGLQuery): number;
  101414. /**
  101415. * Initiates an occlusion query
  101416. * @param algorithmType defines the algorithm to use
  101417. * @param query defines the query to use
  101418. * @returns the current engine
  101419. * @see http://doc.babylonjs.com/features/occlusionquery
  101420. */
  101421. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  101422. /**
  101423. * Ends an occlusion query
  101424. * @see http://doc.babylonjs.com/features/occlusionquery
  101425. * @param algorithmType defines the algorithm to use
  101426. * @returns the current engine
  101427. */
  101428. endOcclusionQuery(algorithmType: number): Engine;
  101429. /**
  101430. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  101431. * Please note that only one query can be issued at a time
  101432. * @returns a time token used to track the time span
  101433. */
  101434. startTimeQuery(): Nullable<_TimeToken>;
  101435. /**
  101436. * Ends a time query
  101437. * @param token defines the token used to measure the time span
  101438. * @returns the time spent (in ns)
  101439. */
  101440. endTimeQuery(token: _TimeToken): int;
  101441. /** @hidden */
  101442. _currentNonTimestampToken: Nullable<_TimeToken>;
  101443. /** @hidden */
  101444. _createTimeQuery(): WebGLQuery;
  101445. /** @hidden */
  101446. _deleteTimeQuery(query: WebGLQuery): void;
  101447. /** @hidden */
  101448. _getGlAlgorithmType(algorithmType: number): number;
  101449. /** @hidden */
  101450. _getTimeQueryResult(query: WebGLQuery): any;
  101451. /** @hidden */
  101452. _getTimeQueryAvailability(query: WebGLQuery): any;
  101453. }
  101454. interface AbstractMesh {
  101455. /**
  101456. * Backing filed
  101457. * @hidden
  101458. */
  101459. __occlusionDataStorage: _OcclusionDataStorage;
  101460. /**
  101461. * Access property
  101462. * @hidden
  101463. */
  101464. _occlusionDataStorage: _OcclusionDataStorage;
  101465. /**
  101466. * 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.
  101467. * The default value is -1 which means don't break the query and wait till the result
  101468. * @see http://doc.babylonjs.com/features/occlusionquery
  101469. */
  101470. occlusionRetryCount: number;
  101471. /**
  101472. * 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:
  101473. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  101474. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  101475. * * 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.
  101476. * @see http://doc.babylonjs.com/features/occlusionquery
  101477. */
  101478. occlusionType: number;
  101479. /**
  101480. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101481. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  101482. * * 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.
  101483. * @see http://doc.babylonjs.com/features/occlusionquery
  101484. */
  101485. occlusionQueryAlgorithmType: number;
  101486. /**
  101487. * 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
  101488. * @see http://doc.babylonjs.com/features/occlusionquery
  101489. */
  101490. isOccluded: boolean;
  101491. /**
  101492. * Flag to check the progress status of the query
  101493. * @see http://doc.babylonjs.com/features/occlusionquery
  101494. */
  101495. isOcclusionQueryInProgress: boolean;
  101496. }
  101497. }
  101498. declare module BABYLON {
  101499. /** @hidden */
  101500. export var _forceTransformFeedbackToBundle: boolean;
  101501. interface Engine {
  101502. /**
  101503. * Creates a webGL transform feedback object
  101504. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101505. * @returns the webGL transform feedback object
  101506. */
  101507. createTransformFeedback(): WebGLTransformFeedback;
  101508. /**
  101509. * Delete a webGL transform feedback object
  101510. * @param value defines the webGL transform feedback object to delete
  101511. */
  101512. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101513. /**
  101514. * Bind a webGL transform feedback object to the webgl context
  101515. * @param value defines the webGL transform feedback object to bind
  101516. */
  101517. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101518. /**
  101519. * Begins a transform feedback operation
  101520. * @param usePoints defines if points or triangles must be used
  101521. */
  101522. beginTransformFeedback(usePoints: boolean): void;
  101523. /**
  101524. * Ends a transform feedback operation
  101525. */
  101526. endTransformFeedback(): void;
  101527. /**
  101528. * Specify the varyings to use with transform feedback
  101529. * @param program defines the associated webGL program
  101530. * @param value defines the list of strings representing the varying names
  101531. */
  101532. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101533. /**
  101534. * Bind a webGL buffer for a transform feedback operation
  101535. * @param value defines the webGL buffer to bind
  101536. */
  101537. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  101538. }
  101539. }
  101540. declare module BABYLON {
  101541. /**
  101542. * Creation options of the multi render target texture.
  101543. */
  101544. export interface IMultiRenderTargetOptions {
  101545. /**
  101546. * Define if the texture needs to create mip maps after render.
  101547. */
  101548. generateMipMaps?: boolean;
  101549. /**
  101550. * Define the types of all the draw buffers we want to create
  101551. */
  101552. types?: number[];
  101553. /**
  101554. * Define the sampling modes of all the draw buffers we want to create
  101555. */
  101556. samplingModes?: number[];
  101557. /**
  101558. * Define if a depth buffer is required
  101559. */
  101560. generateDepthBuffer?: boolean;
  101561. /**
  101562. * Define if a stencil buffer is required
  101563. */
  101564. generateStencilBuffer?: boolean;
  101565. /**
  101566. * Define if a depth texture is required instead of a depth buffer
  101567. */
  101568. generateDepthTexture?: boolean;
  101569. /**
  101570. * Define the number of desired draw buffers
  101571. */
  101572. textureCount?: number;
  101573. /**
  101574. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101575. */
  101576. doNotChangeAspectRatio?: boolean;
  101577. /**
  101578. * Define the default type of the buffers we are creating
  101579. */
  101580. defaultType?: number;
  101581. }
  101582. /**
  101583. * A multi render target, like a render target provides the ability to render to a texture.
  101584. * Unlike the render target, it can render to several draw buffers in one draw.
  101585. * This is specially interesting in deferred rendering or for any effects requiring more than
  101586. * just one color from a single pass.
  101587. */
  101588. export class MultiRenderTarget extends RenderTargetTexture {
  101589. private _internalTextures;
  101590. private _textures;
  101591. private _multiRenderTargetOptions;
  101592. /**
  101593. * Get if draw buffers are currently supported by the used hardware and browser.
  101594. */
  101595. readonly isSupported: boolean;
  101596. /**
  101597. * Get the list of textures generated by the multi render target.
  101598. */
  101599. readonly textures: Texture[];
  101600. /**
  101601. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101602. */
  101603. readonly depthTexture: Texture;
  101604. /**
  101605. * Set the wrapping mode on U of all the textures we are rendering to.
  101606. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101607. */
  101608. wrapU: number;
  101609. /**
  101610. * Set the wrapping mode on V of all the textures we are rendering to.
  101611. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101612. */
  101613. wrapV: number;
  101614. /**
  101615. * Instantiate a new multi render target texture.
  101616. * A multi render target, like a render target provides the ability to render to a texture.
  101617. * Unlike the render target, it can render to several draw buffers in one draw.
  101618. * This is specially interesting in deferred rendering or for any effects requiring more than
  101619. * just one color from a single pass.
  101620. * @param name Define the name of the texture
  101621. * @param size Define the size of the buffers to render to
  101622. * @param count Define the number of target we are rendering into
  101623. * @param scene Define the scene the texture belongs to
  101624. * @param options Define the options used to create the multi render target
  101625. */
  101626. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101627. /** @hidden */
  101628. _rebuild(): void;
  101629. private _createInternalTextures;
  101630. private _createTextures;
  101631. /**
  101632. * Define the number of samples used if MSAA is enabled.
  101633. */
  101634. samples: number;
  101635. /**
  101636. * Resize all the textures in the multi render target.
  101637. * Be carrefull as it will recreate all the data in the new texture.
  101638. * @param size Define the new size
  101639. */
  101640. resize(size: any): void;
  101641. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101642. /**
  101643. * Dispose the render targets and their associated resources
  101644. */
  101645. dispose(): void;
  101646. /**
  101647. * Release all the underlying texture used as draw buffers.
  101648. */
  101649. releaseInternalTextures(): void;
  101650. }
  101651. }
  101652. declare module BABYLON {
  101653. interface Engine {
  101654. /**
  101655. * Unbind a list of render target textures from the webGL context
  101656. * This is used only when drawBuffer extension or webGL2 are active
  101657. * @param textures defines the render target textures to unbind
  101658. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101659. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101660. */
  101661. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101662. /**
  101663. * Create a multi render target texture
  101664. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101665. * @param size defines the size of the texture
  101666. * @param options defines the creation options
  101667. * @returns the cube texture as an InternalTexture
  101668. */
  101669. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101670. /**
  101671. * Update the sample count for a given multiple render target texture
  101672. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101673. * @param textures defines the textures to update
  101674. * @param samples defines the sample count to set
  101675. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101676. */
  101677. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101678. }
  101679. }
  101680. declare module BABYLON {
  101681. /**
  101682. * Gather the list of clipboard event types as constants.
  101683. */
  101684. export class ClipboardEventTypes {
  101685. /**
  101686. * The clipboard event is fired when a copy command is active (pressed).
  101687. */
  101688. static readonly COPY: number;
  101689. /**
  101690. * The clipboard event is fired when a cut command is active (pressed).
  101691. */
  101692. static readonly CUT: number;
  101693. /**
  101694. * The clipboard event is fired when a paste command is active (pressed).
  101695. */
  101696. static readonly PASTE: number;
  101697. }
  101698. /**
  101699. * This class is used to store clipboard related info for the onClipboardObservable event.
  101700. */
  101701. export class ClipboardInfo {
  101702. /**
  101703. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101704. */
  101705. type: number;
  101706. /**
  101707. * Defines the related dom event
  101708. */
  101709. event: ClipboardEvent;
  101710. /**
  101711. *Creates an instance of ClipboardInfo.
  101712. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101713. * @param event Defines the related dom event
  101714. */
  101715. constructor(
  101716. /**
  101717. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101718. */
  101719. type: number,
  101720. /**
  101721. * Defines the related dom event
  101722. */
  101723. event: ClipboardEvent);
  101724. /**
  101725. * Get the clipboard event's type from the keycode.
  101726. * @param keyCode Defines the keyCode for the current keyboard event.
  101727. * @return {number}
  101728. */
  101729. static GetTypeFromCharacter(keyCode: number): number;
  101730. }
  101731. }
  101732. declare module BABYLON {
  101733. /**
  101734. * Class used to represent data loading progression
  101735. */
  101736. export class SceneLoaderProgressEvent {
  101737. /** defines if data length to load can be evaluated */
  101738. readonly lengthComputable: boolean;
  101739. /** defines the loaded data length */
  101740. readonly loaded: number;
  101741. /** defines the data length to load */
  101742. readonly total: number;
  101743. /**
  101744. * Create a new progress event
  101745. * @param lengthComputable defines if data length to load can be evaluated
  101746. * @param loaded defines the loaded data length
  101747. * @param total defines the data length to load
  101748. */
  101749. constructor(
  101750. /** defines if data length to load can be evaluated */
  101751. lengthComputable: boolean,
  101752. /** defines the loaded data length */
  101753. loaded: number,
  101754. /** defines the data length to load */
  101755. total: number);
  101756. /**
  101757. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101758. * @param event defines the source event
  101759. * @returns a new SceneLoaderProgressEvent
  101760. */
  101761. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101762. }
  101763. /**
  101764. * Interface used by SceneLoader plugins to define supported file extensions
  101765. */
  101766. export interface ISceneLoaderPluginExtensions {
  101767. /**
  101768. * Defines the list of supported extensions
  101769. */
  101770. [extension: string]: {
  101771. isBinary: boolean;
  101772. };
  101773. }
  101774. /**
  101775. * Interface used by SceneLoader plugin factory
  101776. */
  101777. export interface ISceneLoaderPluginFactory {
  101778. /**
  101779. * Defines the name of the factory
  101780. */
  101781. name: string;
  101782. /**
  101783. * Function called to create a new plugin
  101784. * @return the new plugin
  101785. */
  101786. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101787. /**
  101788. * Boolean indicating if the plugin can direct load specific data
  101789. */
  101790. canDirectLoad?: (data: string) => boolean;
  101791. }
  101792. /**
  101793. * Interface used to define a SceneLoader plugin
  101794. */
  101795. export interface ISceneLoaderPlugin {
  101796. /**
  101797. * The friendly name of this plugin.
  101798. */
  101799. name: string;
  101800. /**
  101801. * The file extensions supported by this plugin.
  101802. */
  101803. extensions: string | ISceneLoaderPluginExtensions;
  101804. /**
  101805. * Import meshes into a scene.
  101806. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101807. * @param scene The scene to import into
  101808. * @param data The data to import
  101809. * @param rootUrl The root url for scene and resources
  101810. * @param meshes The meshes array to import into
  101811. * @param particleSystems The particle systems array to import into
  101812. * @param skeletons The skeletons array to import into
  101813. * @param onError The callback when import fails
  101814. * @returns True if successful or false otherwise
  101815. */
  101816. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  101817. /**
  101818. * Load into a scene.
  101819. * @param scene The scene to load into
  101820. * @param data The data to import
  101821. * @param rootUrl The root url for scene and resources
  101822. * @param onError The callback when import fails
  101823. * @returns true if successful or false otherwise
  101824. */
  101825. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  101826. /**
  101827. * The callback that returns true if the data can be directly loaded.
  101828. */
  101829. canDirectLoad?: (data: string) => boolean;
  101830. /**
  101831. * The callback that allows custom handling of the root url based on the response url.
  101832. */
  101833. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101834. /**
  101835. * Load into an asset container.
  101836. * @param scene The scene to load into
  101837. * @param data The data to import
  101838. * @param rootUrl The root url for scene and resources
  101839. * @param onError The callback when import fails
  101840. * @returns The loaded asset container
  101841. */
  101842. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101843. }
  101844. /**
  101845. * Interface used to define an async SceneLoader plugin
  101846. */
  101847. export interface ISceneLoaderPluginAsync {
  101848. /**
  101849. * The friendly name of this plugin.
  101850. */
  101851. name: string;
  101852. /**
  101853. * The file extensions supported by this plugin.
  101854. */
  101855. extensions: string | ISceneLoaderPluginExtensions;
  101856. /**
  101857. * Import meshes into a scene.
  101858. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101859. * @param scene The scene to import into
  101860. * @param data The data to import
  101861. * @param rootUrl The root url for scene and resources
  101862. * @param onProgress The callback when the load progresses
  101863. * @param fileName Defines the name of the file to load
  101864. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101865. */
  101866. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101867. meshes: AbstractMesh[];
  101868. particleSystems: IParticleSystem[];
  101869. skeletons: Skeleton[];
  101870. animationGroups: AnimationGroup[];
  101871. }>;
  101872. /**
  101873. * Load into a scene.
  101874. * @param scene The scene to load into
  101875. * @param data The data to import
  101876. * @param rootUrl The root url for scene and resources
  101877. * @param onProgress The callback when the load progresses
  101878. * @param fileName Defines the name of the file to load
  101879. * @returns Nothing
  101880. */
  101881. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101882. /**
  101883. * The callback that returns true if the data can be directly loaded.
  101884. */
  101885. canDirectLoad?: (data: string) => boolean;
  101886. /**
  101887. * The callback that allows custom handling of the root url based on the response url.
  101888. */
  101889. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101890. /**
  101891. * Load into an asset container.
  101892. * @param scene The scene to load into
  101893. * @param data The data to import
  101894. * @param rootUrl The root url for scene and resources
  101895. * @param onProgress The callback when the load progresses
  101896. * @param fileName Defines the name of the file to load
  101897. * @returns The loaded asset container
  101898. */
  101899. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101900. }
  101901. /**
  101902. * Class used to load scene from various file formats using registered plugins
  101903. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101904. */
  101905. export class SceneLoader {
  101906. /**
  101907. * No logging while loading
  101908. */
  101909. static readonly NO_LOGGING: number;
  101910. /**
  101911. * Minimal logging while loading
  101912. */
  101913. static readonly MINIMAL_LOGGING: number;
  101914. /**
  101915. * Summary logging while loading
  101916. */
  101917. static readonly SUMMARY_LOGGING: number;
  101918. /**
  101919. * Detailled logging while loading
  101920. */
  101921. static readonly DETAILED_LOGGING: number;
  101922. /**
  101923. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101924. */
  101925. static ForceFullSceneLoadingForIncremental: boolean;
  101926. /**
  101927. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101928. */
  101929. static ShowLoadingScreen: boolean;
  101930. /**
  101931. * Defines the current logging level (while loading the scene)
  101932. * @ignorenaming
  101933. */
  101934. static loggingLevel: number;
  101935. /**
  101936. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101937. */
  101938. static CleanBoneMatrixWeights: boolean;
  101939. /**
  101940. * Event raised when a plugin is used to load a scene
  101941. */
  101942. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101943. private static _registeredPlugins;
  101944. private static _getDefaultPlugin;
  101945. private static _getPluginForExtension;
  101946. private static _getPluginForDirectLoad;
  101947. private static _getPluginForFilename;
  101948. private static _getDirectLoad;
  101949. private static _loadData;
  101950. private static _getFileInfo;
  101951. /**
  101952. * Gets a plugin that can load the given extension
  101953. * @param extension defines the extension to load
  101954. * @returns a plugin or null if none works
  101955. */
  101956. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101957. /**
  101958. * Gets a boolean indicating that the given extension can be loaded
  101959. * @param extension defines the extension to load
  101960. * @returns true if the extension is supported
  101961. */
  101962. static IsPluginForExtensionAvailable(extension: string): boolean;
  101963. /**
  101964. * Adds a new plugin to the list of registered plugins
  101965. * @param plugin defines the plugin to add
  101966. */
  101967. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101968. /**
  101969. * Import meshes into a scene
  101970. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101971. * @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)
  101972. * @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)
  101973. * @param scene the instance of BABYLON.Scene to append to
  101974. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101975. * @param onProgress a callback with a progress event for each file being loaded
  101976. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101977. * @param pluginExtension the extension used to determine the plugin
  101978. * @returns The loaded plugin
  101979. */
  101980. 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>;
  101981. /**
  101982. * Import meshes into a scene
  101983. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101984. * @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)
  101985. * @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)
  101986. * @param scene the instance of BABYLON.Scene to append to
  101987. * @param onProgress a callback with a progress event for each file being loaded
  101988. * @param pluginExtension the extension used to determine the plugin
  101989. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  101990. */
  101991. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  101992. meshes: AbstractMesh[];
  101993. particleSystems: IParticleSystem[];
  101994. skeletons: Skeleton[];
  101995. animationGroups: AnimationGroup[];
  101996. }>;
  101997. /**
  101998. * Load a scene
  101999. * @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)
  102000. * @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)
  102001. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102002. * @param onSuccess a callback with the scene when import succeeds
  102003. * @param onProgress a callback with a progress event for each file being loaded
  102004. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102005. * @param pluginExtension the extension used to determine the plugin
  102006. * @returns The loaded plugin
  102007. */
  102008. 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>;
  102009. /**
  102010. * Load a scene
  102011. * @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)
  102012. * @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)
  102013. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102014. * @param onProgress a callback with a progress event for each file being loaded
  102015. * @param pluginExtension the extension used to determine the plugin
  102016. * @returns The loaded scene
  102017. */
  102018. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102019. /**
  102020. * Append a scene
  102021. * @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)
  102022. * @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)
  102023. * @param scene is the instance of BABYLON.Scene to append to
  102024. * @param onSuccess a callback with the scene when import succeeds
  102025. * @param onProgress a callback with a progress event for each file being loaded
  102026. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102027. * @param pluginExtension the extension used to determine the plugin
  102028. * @returns The loaded plugin
  102029. */
  102030. 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>;
  102031. /**
  102032. * Append a scene
  102033. * @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)
  102034. * @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)
  102035. * @param scene is the instance of BABYLON.Scene to append to
  102036. * @param onProgress a callback with a progress event for each file being loaded
  102037. * @param pluginExtension the extension used to determine the plugin
  102038. * @returns The given scene
  102039. */
  102040. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102041. /**
  102042. * Load a scene into an asset container
  102043. * @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)
  102044. * @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)
  102045. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  102046. * @param onSuccess a callback with the scene when import succeeds
  102047. * @param onProgress a callback with a progress event for each file being loaded
  102048. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102049. * @param pluginExtension the extension used to determine the plugin
  102050. * @returns The loaded plugin
  102051. */
  102052. 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>;
  102053. /**
  102054. * Load a scene into an asset container
  102055. * @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)
  102056. * @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)
  102057. * @param scene is the instance of Scene to append to
  102058. * @param onProgress a callback with a progress event for each file being loaded
  102059. * @param pluginExtension the extension used to determine the plugin
  102060. * @returns The loaded asset container
  102061. */
  102062. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  102063. }
  102064. }
  102065. declare module BABYLON {
  102066. /**
  102067. * Google Daydream controller
  102068. */
  102069. export class DaydreamController extends WebVRController {
  102070. /**
  102071. * Base Url for the controller model.
  102072. */
  102073. static MODEL_BASE_URL: string;
  102074. /**
  102075. * File name for the controller model.
  102076. */
  102077. static MODEL_FILENAME: string;
  102078. /**
  102079. * Gamepad Id prefix used to identify Daydream Controller.
  102080. */
  102081. static readonly GAMEPAD_ID_PREFIX: string;
  102082. /**
  102083. * Creates a new DaydreamController from a gamepad
  102084. * @param vrGamepad the gamepad that the controller should be created from
  102085. */
  102086. constructor(vrGamepad: any);
  102087. /**
  102088. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102089. * @param scene scene in which to add meshes
  102090. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102091. */
  102092. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102093. /**
  102094. * Called once for each button that changed state since the last frame
  102095. * @param buttonIdx Which button index changed
  102096. * @param state New state of the button
  102097. * @param changes Which properties on the state changed since last frame
  102098. */
  102099. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102100. }
  102101. }
  102102. declare module BABYLON {
  102103. /**
  102104. * Gear VR Controller
  102105. */
  102106. export class GearVRController extends WebVRController {
  102107. /**
  102108. * Base Url for the controller model.
  102109. */
  102110. static MODEL_BASE_URL: string;
  102111. /**
  102112. * File name for the controller model.
  102113. */
  102114. static MODEL_FILENAME: string;
  102115. /**
  102116. * Gamepad Id prefix used to identify this controller.
  102117. */
  102118. static readonly GAMEPAD_ID_PREFIX: string;
  102119. private readonly _buttonIndexToObservableNameMap;
  102120. /**
  102121. * Creates a new GearVRController from a gamepad
  102122. * @param vrGamepad the gamepad that the controller should be created from
  102123. */
  102124. constructor(vrGamepad: any);
  102125. /**
  102126. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102127. * @param scene scene in which to add meshes
  102128. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102129. */
  102130. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102131. /**
  102132. * Called once for each button that changed state since the last frame
  102133. * @param buttonIdx Which button index changed
  102134. * @param state New state of the button
  102135. * @param changes Which properties on the state changed since last frame
  102136. */
  102137. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102138. }
  102139. }
  102140. declare module BABYLON {
  102141. /**
  102142. * Generic Controller
  102143. */
  102144. export class GenericController extends WebVRController {
  102145. /**
  102146. * Base Url for the controller model.
  102147. */
  102148. static readonly MODEL_BASE_URL: string;
  102149. /**
  102150. * File name for the controller model.
  102151. */
  102152. static readonly MODEL_FILENAME: string;
  102153. /**
  102154. * Creates a new GenericController from a gamepad
  102155. * @param vrGamepad the gamepad that the controller should be created from
  102156. */
  102157. constructor(vrGamepad: any);
  102158. /**
  102159. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102160. * @param scene scene in which to add meshes
  102161. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102162. */
  102163. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102164. /**
  102165. * Called once for each button that changed state since the last frame
  102166. * @param buttonIdx Which button index changed
  102167. * @param state New state of the button
  102168. * @param changes Which properties on the state changed since last frame
  102169. */
  102170. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102171. }
  102172. }
  102173. declare module BABYLON {
  102174. /**
  102175. * Oculus Touch Controller
  102176. */
  102177. export class OculusTouchController extends WebVRController {
  102178. /**
  102179. * Base Url for the controller model.
  102180. */
  102181. static MODEL_BASE_URL: string;
  102182. /**
  102183. * File name for the left controller model.
  102184. */
  102185. static MODEL_LEFT_FILENAME: string;
  102186. /**
  102187. * File name for the right controller model.
  102188. */
  102189. static MODEL_RIGHT_FILENAME: string;
  102190. /**
  102191. * Fired when the secondary trigger on this controller is modified
  102192. */
  102193. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  102194. /**
  102195. * Fired when the thumb rest on this controller is modified
  102196. */
  102197. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  102198. /**
  102199. * Creates a new OculusTouchController from a gamepad
  102200. * @param vrGamepad the gamepad that the controller should be created from
  102201. */
  102202. constructor(vrGamepad: any);
  102203. /**
  102204. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102205. * @param scene scene in which to add meshes
  102206. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102207. */
  102208. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102209. /**
  102210. * Fired when the A button on this controller is modified
  102211. */
  102212. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102213. /**
  102214. * Fired when the B button on this controller is modified
  102215. */
  102216. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102217. /**
  102218. * Fired when the X button on this controller is modified
  102219. */
  102220. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102221. /**
  102222. * Fired when the Y button on this controller is modified
  102223. */
  102224. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102225. /**
  102226. * Called once for each button that changed state since the last frame
  102227. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  102228. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  102229. * 2) secondary trigger (same)
  102230. * 3) A (right) X (left), touch, pressed = value
  102231. * 4) B / Y
  102232. * 5) thumb rest
  102233. * @param buttonIdx Which button index changed
  102234. * @param state New state of the button
  102235. * @param changes Which properties on the state changed since last frame
  102236. */
  102237. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102238. }
  102239. }
  102240. declare module BABYLON {
  102241. /**
  102242. * Vive Controller
  102243. */
  102244. export class ViveController extends WebVRController {
  102245. /**
  102246. * Base Url for the controller model.
  102247. */
  102248. static MODEL_BASE_URL: string;
  102249. /**
  102250. * File name for the controller model.
  102251. */
  102252. static MODEL_FILENAME: string;
  102253. /**
  102254. * Creates a new ViveController from a gamepad
  102255. * @param vrGamepad the gamepad that the controller should be created from
  102256. */
  102257. constructor(vrGamepad: any);
  102258. /**
  102259. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102260. * @param scene scene in which to add meshes
  102261. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102262. */
  102263. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102264. /**
  102265. * Fired when the left button on this controller is modified
  102266. */
  102267. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102268. /**
  102269. * Fired when the right button on this controller is modified
  102270. */
  102271. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102272. /**
  102273. * Fired when the menu button on this controller is modified
  102274. */
  102275. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102276. /**
  102277. * Called once for each button that changed state since the last frame
  102278. * Vive mapping:
  102279. * 0: touchpad
  102280. * 1: trigger
  102281. * 2: left AND right buttons
  102282. * 3: menu button
  102283. * @param buttonIdx Which button index changed
  102284. * @param state New state of the button
  102285. * @param changes Which properties on the state changed since last frame
  102286. */
  102287. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102288. }
  102289. }
  102290. declare module BABYLON {
  102291. /**
  102292. * Defines the WindowsMotionController object that the state of the windows motion controller
  102293. */
  102294. export class WindowsMotionController extends WebVRController {
  102295. /**
  102296. * The base url used to load the left and right controller models
  102297. */
  102298. static MODEL_BASE_URL: string;
  102299. /**
  102300. * The name of the left controller model file
  102301. */
  102302. static MODEL_LEFT_FILENAME: string;
  102303. /**
  102304. * The name of the right controller model file
  102305. */
  102306. static MODEL_RIGHT_FILENAME: string;
  102307. /**
  102308. * The controller name prefix for this controller type
  102309. */
  102310. static readonly GAMEPAD_ID_PREFIX: string;
  102311. /**
  102312. * The controller id pattern for this controller type
  102313. */
  102314. private static readonly GAMEPAD_ID_PATTERN;
  102315. private _loadedMeshInfo;
  102316. private readonly _mapping;
  102317. /**
  102318. * Fired when the trackpad on this controller is clicked
  102319. */
  102320. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  102321. /**
  102322. * Fired when the trackpad on this controller is modified
  102323. */
  102324. onTrackpadValuesChangedObservable: Observable<StickValues>;
  102325. /**
  102326. * The current x and y values of this controller's trackpad
  102327. */
  102328. trackpad: StickValues;
  102329. /**
  102330. * Creates a new WindowsMotionController from a gamepad
  102331. * @param vrGamepad the gamepad that the controller should be created from
  102332. */
  102333. constructor(vrGamepad: any);
  102334. /**
  102335. * Fired when the trigger on this controller is modified
  102336. */
  102337. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102338. /**
  102339. * Fired when the menu button on this controller is modified
  102340. */
  102341. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102342. /**
  102343. * Fired when the grip button on this controller is modified
  102344. */
  102345. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102346. /**
  102347. * Fired when the thumbstick button on this controller is modified
  102348. */
  102349. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102350. /**
  102351. * Fired when the touchpad button on this controller is modified
  102352. */
  102353. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102354. /**
  102355. * Fired when the touchpad values on this controller are modified
  102356. */
  102357. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  102358. private _updateTrackpad;
  102359. /**
  102360. * Called once per frame by the engine.
  102361. */
  102362. update(): void;
  102363. /**
  102364. * Called once for each button that changed state since the last frame
  102365. * @param buttonIdx Which button index changed
  102366. * @param state New state of the button
  102367. * @param changes Which properties on the state changed since last frame
  102368. */
  102369. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102370. /**
  102371. * Moves the buttons on the controller mesh based on their current state
  102372. * @param buttonName the name of the button to move
  102373. * @param buttonValue the value of the button which determines the buttons new position
  102374. */
  102375. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  102376. /**
  102377. * Moves the axis on the controller mesh based on its current state
  102378. * @param axis the index of the axis
  102379. * @param axisValue the value of the axis which determines the meshes new position
  102380. * @hidden
  102381. */
  102382. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  102383. /**
  102384. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102385. * @param scene scene in which to add meshes
  102386. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102387. */
  102388. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  102389. /**
  102390. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  102391. * can be transformed by button presses and axes values, based on this._mapping.
  102392. *
  102393. * @param scene scene in which the meshes exist
  102394. * @param meshes list of meshes that make up the controller model to process
  102395. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  102396. */
  102397. private processModel;
  102398. private createMeshInfo;
  102399. /**
  102400. * Gets the ray of the controller in the direction the controller is pointing
  102401. * @param length the length the resulting ray should be
  102402. * @returns a ray in the direction the controller is pointing
  102403. */
  102404. getForwardRay(length?: number): Ray;
  102405. /**
  102406. * Disposes of the controller
  102407. */
  102408. dispose(): void;
  102409. }
  102410. }
  102411. declare module BABYLON {
  102412. /**
  102413. * Single axis scale gizmo
  102414. */
  102415. export class AxisScaleGizmo extends Gizmo {
  102416. private _coloredMaterial;
  102417. /**
  102418. * Drag behavior responsible for the gizmos dragging interactions
  102419. */
  102420. dragBehavior: PointerDragBehavior;
  102421. private _pointerObserver;
  102422. /**
  102423. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102424. */
  102425. snapDistance: number;
  102426. /**
  102427. * Event that fires each time the gizmo snaps to a new location.
  102428. * * snapDistance is the the change in distance
  102429. */
  102430. onSnapObservable: Observable<{
  102431. snapDistance: number;
  102432. }>;
  102433. /**
  102434. * If the scaling operation should be done on all axis (default: false)
  102435. */
  102436. uniformScaling: boolean;
  102437. /**
  102438. * Creates an AxisScaleGizmo
  102439. * @param gizmoLayer The utility layer the gizmo will be added to
  102440. * @param dragAxis The axis which the gizmo will be able to scale on
  102441. * @param color The color of the gizmo
  102442. */
  102443. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102444. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102445. /**
  102446. * Disposes of the gizmo
  102447. */
  102448. dispose(): void;
  102449. /**
  102450. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102451. * @param mesh The mesh to replace the default mesh of the gizmo
  102452. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  102453. */
  102454. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  102455. }
  102456. }
  102457. declare module BABYLON {
  102458. /**
  102459. * Bounding box gizmo
  102460. */
  102461. export class BoundingBoxGizmo extends Gizmo {
  102462. private _lineBoundingBox;
  102463. private _rotateSpheresParent;
  102464. private _scaleBoxesParent;
  102465. private _boundingDimensions;
  102466. private _renderObserver;
  102467. private _pointerObserver;
  102468. private _scaleDragSpeed;
  102469. private _tmpQuaternion;
  102470. private _tmpVector;
  102471. private _tmpRotationMatrix;
  102472. /**
  102473. * 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)
  102474. */
  102475. ignoreChildren: boolean;
  102476. /**
  102477. * 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)
  102478. */
  102479. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  102480. /**
  102481. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  102482. */
  102483. rotationSphereSize: number;
  102484. /**
  102485. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  102486. */
  102487. scaleBoxSize: number;
  102488. /**
  102489. * 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)
  102490. */
  102491. fixedDragMeshScreenSize: boolean;
  102492. /**
  102493. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  102494. */
  102495. fixedDragMeshScreenSizeDistanceFactor: number;
  102496. /**
  102497. * Fired when a rotation sphere or scale box is dragged
  102498. */
  102499. onDragStartObservable: Observable<{}>;
  102500. /**
  102501. * Fired when a scale box is dragged
  102502. */
  102503. onScaleBoxDragObservable: Observable<{}>;
  102504. /**
  102505. * Fired when a scale box drag is ended
  102506. */
  102507. onScaleBoxDragEndObservable: Observable<{}>;
  102508. /**
  102509. * Fired when a rotation sphere is dragged
  102510. */
  102511. onRotationSphereDragObservable: Observable<{}>;
  102512. /**
  102513. * Fired when a rotation sphere drag is ended
  102514. */
  102515. onRotationSphereDragEndObservable: Observable<{}>;
  102516. /**
  102517. * 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)
  102518. */
  102519. scalePivot: Nullable<Vector3>;
  102520. /**
  102521. * Mesh used as a pivot to rotate the attached mesh
  102522. */
  102523. private _anchorMesh;
  102524. private _existingMeshScale;
  102525. private _dragMesh;
  102526. private pointerDragBehavior;
  102527. private coloredMaterial;
  102528. private hoverColoredMaterial;
  102529. /**
  102530. * Sets the color of the bounding box gizmo
  102531. * @param color the color to set
  102532. */
  102533. setColor(color: Color3): void;
  102534. /**
  102535. * Creates an BoundingBoxGizmo
  102536. * @param gizmoLayer The utility layer the gizmo will be added to
  102537. * @param color The color of the gizmo
  102538. */
  102539. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102540. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102541. private _selectNode;
  102542. /**
  102543. * Updates the bounding box information for the Gizmo
  102544. */
  102545. updateBoundingBox(): void;
  102546. private _updateRotationSpheres;
  102547. private _updateScaleBoxes;
  102548. /**
  102549. * Enables rotation on the specified axis and disables rotation on the others
  102550. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102551. */
  102552. setEnabledRotationAxis(axis: string): void;
  102553. /**
  102554. * Enables/disables scaling
  102555. * @param enable if scaling should be enabled
  102556. */
  102557. setEnabledScaling(enable: boolean): void;
  102558. private _updateDummy;
  102559. /**
  102560. * Enables a pointer drag behavior on the bounding box of the gizmo
  102561. */
  102562. enableDragBehavior(): void;
  102563. /**
  102564. * Disposes of the gizmo
  102565. */
  102566. dispose(): void;
  102567. /**
  102568. * 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)
  102569. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102570. * @returns the bounding box mesh with the passed in mesh as a child
  102571. */
  102572. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102573. /**
  102574. * CustomMeshes are not supported by this gizmo
  102575. * @param mesh The mesh to replace the default mesh of the gizmo
  102576. */
  102577. setCustomMesh(mesh: Mesh): void;
  102578. }
  102579. }
  102580. declare module BABYLON {
  102581. /**
  102582. * Single plane rotation gizmo
  102583. */
  102584. export class PlaneRotationGizmo extends Gizmo {
  102585. /**
  102586. * Drag behavior responsible for the gizmos dragging interactions
  102587. */
  102588. dragBehavior: PointerDragBehavior;
  102589. private _pointerObserver;
  102590. /**
  102591. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102592. */
  102593. snapDistance: number;
  102594. /**
  102595. * Event that fires each time the gizmo snaps to a new location.
  102596. * * snapDistance is the the change in distance
  102597. */
  102598. onSnapObservable: Observable<{
  102599. snapDistance: number;
  102600. }>;
  102601. /**
  102602. * Creates a PlaneRotationGizmo
  102603. * @param gizmoLayer The utility layer the gizmo will be added to
  102604. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102605. * @param color The color of the gizmo
  102606. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102607. */
  102608. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102609. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102610. /**
  102611. * Disposes of the gizmo
  102612. */
  102613. dispose(): void;
  102614. }
  102615. }
  102616. declare module BABYLON {
  102617. /**
  102618. * Gizmo that enables rotating a mesh along 3 axis
  102619. */
  102620. export class RotationGizmo extends Gizmo {
  102621. /**
  102622. * Internal gizmo used for interactions on the x axis
  102623. */
  102624. xGizmo: PlaneRotationGizmo;
  102625. /**
  102626. * Internal gizmo used for interactions on the y axis
  102627. */
  102628. yGizmo: PlaneRotationGizmo;
  102629. /**
  102630. * Internal gizmo used for interactions on the z axis
  102631. */
  102632. zGizmo: PlaneRotationGizmo;
  102633. /** Fires an event when any of it's sub gizmos are dragged */
  102634. onDragStartObservable: Observable<{}>;
  102635. /** Fires an event when any of it's sub gizmos are released from dragging */
  102636. onDragEndObservable: Observable<{}>;
  102637. attachedMesh: Nullable<AbstractMesh>;
  102638. /**
  102639. * Creates a RotationGizmo
  102640. * @param gizmoLayer The utility layer the gizmo will be added to
  102641. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102642. */
  102643. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102644. updateGizmoRotationToMatchAttachedMesh: boolean;
  102645. /**
  102646. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102647. */
  102648. snapDistance: number;
  102649. /**
  102650. * Ratio for the scale of the gizmo (Default: 1)
  102651. */
  102652. scaleRatio: number;
  102653. /**
  102654. * Disposes of the gizmo
  102655. */
  102656. dispose(): void;
  102657. /**
  102658. * CustomMeshes are not supported by this gizmo
  102659. * @param mesh The mesh to replace the default mesh of the gizmo
  102660. */
  102661. setCustomMesh(mesh: Mesh): void;
  102662. }
  102663. }
  102664. declare module BABYLON {
  102665. /**
  102666. * Gizmo that enables dragging a mesh along 3 axis
  102667. */
  102668. export class PositionGizmo extends Gizmo {
  102669. /**
  102670. * Internal gizmo used for interactions on the x axis
  102671. */
  102672. xGizmo: AxisDragGizmo;
  102673. /**
  102674. * Internal gizmo used for interactions on the y axis
  102675. */
  102676. yGizmo: AxisDragGizmo;
  102677. /**
  102678. * Internal gizmo used for interactions on the z axis
  102679. */
  102680. zGizmo: AxisDragGizmo;
  102681. /** Fires an event when any of it's sub gizmos are dragged */
  102682. onDragStartObservable: Observable<{}>;
  102683. /** Fires an event when any of it's sub gizmos are released from dragging */
  102684. onDragEndObservable: Observable<{}>;
  102685. attachedMesh: Nullable<AbstractMesh>;
  102686. /**
  102687. * Creates a PositionGizmo
  102688. * @param gizmoLayer The utility layer the gizmo will be added to
  102689. */
  102690. constructor(gizmoLayer?: UtilityLayerRenderer);
  102691. updateGizmoRotationToMatchAttachedMesh: boolean;
  102692. /**
  102693. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102694. */
  102695. snapDistance: number;
  102696. /**
  102697. * Ratio for the scale of the gizmo (Default: 1)
  102698. */
  102699. scaleRatio: number;
  102700. /**
  102701. * Disposes of the gizmo
  102702. */
  102703. dispose(): void;
  102704. /**
  102705. * CustomMeshes are not supported by this gizmo
  102706. * @param mesh The mesh to replace the default mesh of the gizmo
  102707. */
  102708. setCustomMesh(mesh: Mesh): void;
  102709. }
  102710. }
  102711. declare module BABYLON {
  102712. /**
  102713. * Class containing static functions to help procedurally build meshes
  102714. */
  102715. export class PolyhedronBuilder {
  102716. /**
  102717. * Creates a polyhedron mesh
  102718. * * 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
  102719. * * The parameter `size` (positive float, default 1) sets the polygon size
  102720. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102721. * * 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`
  102722. * * 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
  102723. * * 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)`)
  102724. * * 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
  102725. * * 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
  102726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102729. * @param name defines the name of the mesh
  102730. * @param options defines the options used to create the mesh
  102731. * @param scene defines the hosting scene
  102732. * @returns the polyhedron mesh
  102733. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102734. */
  102735. static CreatePolyhedron(name: string, options: {
  102736. type?: number;
  102737. size?: number;
  102738. sizeX?: number;
  102739. sizeY?: number;
  102740. sizeZ?: number;
  102741. custom?: any;
  102742. faceUV?: Vector4[];
  102743. faceColors?: Color4[];
  102744. flat?: boolean;
  102745. updatable?: boolean;
  102746. sideOrientation?: number;
  102747. frontUVs?: Vector4;
  102748. backUVs?: Vector4;
  102749. }, scene?: Nullable<Scene>): Mesh;
  102750. }
  102751. }
  102752. declare module BABYLON {
  102753. /**
  102754. * Gizmo that enables scaling a mesh along 3 axis
  102755. */
  102756. export class ScaleGizmo extends Gizmo {
  102757. /**
  102758. * Internal gizmo used for interactions on the x axis
  102759. */
  102760. xGizmo: AxisScaleGizmo;
  102761. /**
  102762. * Internal gizmo used for interactions on the y axis
  102763. */
  102764. yGizmo: AxisScaleGizmo;
  102765. /**
  102766. * Internal gizmo used for interactions on the z axis
  102767. */
  102768. zGizmo: AxisScaleGizmo;
  102769. /**
  102770. * Internal gizmo used to scale all axis equally
  102771. */
  102772. uniformScaleGizmo: AxisScaleGizmo;
  102773. /** Fires an event when any of it's sub gizmos are dragged */
  102774. onDragStartObservable: Observable<{}>;
  102775. /** Fires an event when any of it's sub gizmos are released from dragging */
  102776. onDragEndObservable: Observable<{}>;
  102777. attachedMesh: Nullable<AbstractMesh>;
  102778. /**
  102779. * Creates a ScaleGizmo
  102780. * @param gizmoLayer The utility layer the gizmo will be added to
  102781. */
  102782. constructor(gizmoLayer?: UtilityLayerRenderer);
  102783. updateGizmoRotationToMatchAttachedMesh: boolean;
  102784. /**
  102785. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102786. */
  102787. snapDistance: number;
  102788. /**
  102789. * Ratio for the scale of the gizmo (Default: 1)
  102790. */
  102791. scaleRatio: number;
  102792. /**
  102793. * Disposes of the gizmo
  102794. */
  102795. dispose(): void;
  102796. }
  102797. }
  102798. declare module BABYLON {
  102799. /**
  102800. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102801. */
  102802. export class GizmoManager implements IDisposable {
  102803. private scene;
  102804. /**
  102805. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102806. */
  102807. gizmos: {
  102808. positionGizmo: Nullable<PositionGizmo>;
  102809. rotationGizmo: Nullable<RotationGizmo>;
  102810. scaleGizmo: Nullable<ScaleGizmo>;
  102811. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102812. };
  102813. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102814. clearGizmoOnEmptyPointerEvent: boolean;
  102815. /** Fires an event when the manager is attached to a mesh */
  102816. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  102817. private _gizmosEnabled;
  102818. private _pointerObserver;
  102819. private _attachedMesh;
  102820. private _boundingBoxColor;
  102821. private _defaultUtilityLayer;
  102822. private _defaultKeepDepthUtilityLayer;
  102823. /**
  102824. * When bounding box gizmo is enabled, this can be used to track drag/end events
  102825. */
  102826. boundingBoxDragBehavior: SixDofDragBehavior;
  102827. /**
  102828. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  102829. */
  102830. attachableMeshes: Nullable<Array<AbstractMesh>>;
  102831. /**
  102832. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  102833. */
  102834. usePointerToAttachGizmos: boolean;
  102835. /**
  102836. * Instatiates a gizmo manager
  102837. * @param scene the scene to overlay the gizmos on top of
  102838. */
  102839. constructor(scene: Scene);
  102840. /**
  102841. * Attaches a set of gizmos to the specified mesh
  102842. * @param mesh The mesh the gizmo's should be attached to
  102843. */
  102844. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102845. /**
  102846. * If the position gizmo is enabled
  102847. */
  102848. positionGizmoEnabled: boolean;
  102849. /**
  102850. * If the rotation gizmo is enabled
  102851. */
  102852. rotationGizmoEnabled: boolean;
  102853. /**
  102854. * If the scale gizmo is enabled
  102855. */
  102856. scaleGizmoEnabled: boolean;
  102857. /**
  102858. * If the boundingBox gizmo is enabled
  102859. */
  102860. boundingBoxGizmoEnabled: boolean;
  102861. /**
  102862. * Disposes of the gizmo manager
  102863. */
  102864. dispose(): void;
  102865. }
  102866. }
  102867. declare module BABYLON {
  102868. /**
  102869. * A directional light is defined by a direction (what a surprise!).
  102870. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102871. * 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.
  102872. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102873. */
  102874. export class DirectionalLight extends ShadowLight {
  102875. private _shadowFrustumSize;
  102876. /**
  102877. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102878. */
  102879. /**
  102880. * Specifies a fix frustum size for the shadow generation.
  102881. */
  102882. shadowFrustumSize: number;
  102883. private _shadowOrthoScale;
  102884. /**
  102885. * Gets the shadow projection scale against the optimal computed one.
  102886. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102887. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102888. */
  102889. /**
  102890. * Sets the shadow projection scale against the optimal computed one.
  102891. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102892. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102893. */
  102894. shadowOrthoScale: number;
  102895. /**
  102896. * Automatically compute the projection matrix to best fit (including all the casters)
  102897. * on each frame.
  102898. */
  102899. autoUpdateExtends: boolean;
  102900. private _orthoLeft;
  102901. private _orthoRight;
  102902. private _orthoTop;
  102903. private _orthoBottom;
  102904. /**
  102905. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102906. * The directional light is emitted from everywhere in the given direction.
  102907. * It can cast shadows.
  102908. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102909. * @param name The friendly name of the light
  102910. * @param direction The direction of the light
  102911. * @param scene The scene the light belongs to
  102912. */
  102913. constructor(name: string, direction: Vector3, scene: Scene);
  102914. /**
  102915. * Returns the string "DirectionalLight".
  102916. * @return The class name
  102917. */
  102918. getClassName(): string;
  102919. /**
  102920. * Returns the integer 1.
  102921. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102922. */
  102923. getTypeID(): number;
  102924. /**
  102925. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102926. * Returns the DirectionalLight Shadow projection matrix.
  102927. */
  102928. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102929. /**
  102930. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102931. * Returns the DirectionalLight Shadow projection matrix.
  102932. */
  102933. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102934. /**
  102935. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102936. * Returns the DirectionalLight Shadow projection matrix.
  102937. */
  102938. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102939. protected _buildUniformLayout(): void;
  102940. /**
  102941. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102942. * @param effect The effect to update
  102943. * @param lightIndex The index of the light in the effect to update
  102944. * @returns The directional light
  102945. */
  102946. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102947. /**
  102948. * Gets the minZ used for shadow according to both the scene and the light.
  102949. *
  102950. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102951. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102952. * @param activeCamera The camera we are returning the min for
  102953. * @returns the depth min z
  102954. */
  102955. getDepthMinZ(activeCamera: Camera): number;
  102956. /**
  102957. * Gets the maxZ used for shadow according to both the scene and the light.
  102958. *
  102959. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102960. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102961. * @param activeCamera The camera we are returning the max for
  102962. * @returns the depth max z
  102963. */
  102964. getDepthMaxZ(activeCamera: Camera): number;
  102965. /**
  102966. * Prepares the list of defines specific to the light type.
  102967. * @param defines the list of defines
  102968. * @param lightIndex defines the index of the light for the effect
  102969. */
  102970. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102971. }
  102972. }
  102973. declare module BABYLON {
  102974. /**
  102975. * Class containing static functions to help procedurally build meshes
  102976. */
  102977. export class HemisphereBuilder {
  102978. /**
  102979. * Creates a hemisphere mesh
  102980. * @param name defines the name of the mesh
  102981. * @param options defines the options used to create the mesh
  102982. * @param scene defines the hosting scene
  102983. * @returns the hemisphere mesh
  102984. */
  102985. static CreateHemisphere(name: string, options: {
  102986. segments?: number;
  102987. diameter?: number;
  102988. sideOrientation?: number;
  102989. }, scene: any): Mesh;
  102990. }
  102991. }
  102992. declare module BABYLON {
  102993. /**
  102994. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102995. * These values define a cone of light starting from the position, emitting toward the direction.
  102996. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102997. * and the exponent defines the speed of the decay of the light with distance (reach).
  102998. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102999. */
  103000. export class SpotLight extends ShadowLight {
  103001. private _angle;
  103002. private _innerAngle;
  103003. private _cosHalfAngle;
  103004. private _lightAngleScale;
  103005. private _lightAngleOffset;
  103006. /**
  103007. * Gets the cone angle of the spot light in Radians.
  103008. */
  103009. /**
  103010. * Sets the cone angle of the spot light in Radians.
  103011. */
  103012. angle: number;
  103013. /**
  103014. * Only used in gltf falloff mode, this defines the angle where
  103015. * the directional falloff will start before cutting at angle which could be seen
  103016. * as outer angle.
  103017. */
  103018. /**
  103019. * Only used in gltf falloff mode, this defines the angle where
  103020. * the directional falloff will start before cutting at angle which could be seen
  103021. * as outer angle.
  103022. */
  103023. innerAngle: number;
  103024. private _shadowAngleScale;
  103025. /**
  103026. * Allows scaling the angle of the light for shadow generation only.
  103027. */
  103028. /**
  103029. * Allows scaling the angle of the light for shadow generation only.
  103030. */
  103031. shadowAngleScale: number;
  103032. /**
  103033. * The light decay speed with the distance from the emission spot.
  103034. */
  103035. exponent: number;
  103036. private _projectionTextureMatrix;
  103037. /**
  103038. * Allows reading the projecton texture
  103039. */
  103040. readonly projectionTextureMatrix: Matrix;
  103041. protected _projectionTextureLightNear: number;
  103042. /**
  103043. * Gets the near clip of the Spotlight for texture projection.
  103044. */
  103045. /**
  103046. * Sets the near clip of the Spotlight for texture projection.
  103047. */
  103048. projectionTextureLightNear: number;
  103049. protected _projectionTextureLightFar: number;
  103050. /**
  103051. * Gets the far clip of the Spotlight for texture projection.
  103052. */
  103053. /**
  103054. * Sets the far clip of the Spotlight for texture projection.
  103055. */
  103056. projectionTextureLightFar: number;
  103057. protected _projectionTextureUpDirection: Vector3;
  103058. /**
  103059. * Gets the Up vector of the Spotlight for texture projection.
  103060. */
  103061. /**
  103062. * Sets the Up vector of the Spotlight for texture projection.
  103063. */
  103064. projectionTextureUpDirection: Vector3;
  103065. private _projectionTexture;
  103066. /**
  103067. * Gets the projection texture of the light.
  103068. */
  103069. /**
  103070. * Sets the projection texture of the light.
  103071. */
  103072. projectionTexture: Nullable<BaseTexture>;
  103073. private _projectionTextureViewLightDirty;
  103074. private _projectionTextureProjectionLightDirty;
  103075. private _projectionTextureDirty;
  103076. private _projectionTextureViewTargetVector;
  103077. private _projectionTextureViewLightMatrix;
  103078. private _projectionTextureProjectionLightMatrix;
  103079. private _projectionTextureScalingMatrix;
  103080. /**
  103081. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103082. * It can cast shadows.
  103083. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103084. * @param name The light friendly name
  103085. * @param position The position of the spot light in the scene
  103086. * @param direction The direction of the light in the scene
  103087. * @param angle The cone angle of the light in Radians
  103088. * @param exponent The light decay speed with the distance from the emission spot
  103089. * @param scene The scene the lights belongs to
  103090. */
  103091. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103092. /**
  103093. * Returns the string "SpotLight".
  103094. * @returns the class name
  103095. */
  103096. getClassName(): string;
  103097. /**
  103098. * Returns the integer 2.
  103099. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103100. */
  103101. getTypeID(): number;
  103102. /**
  103103. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103104. */
  103105. protected _setDirection(value: Vector3): void;
  103106. /**
  103107. * Overrides the position setter to recompute the projection texture view light Matrix.
  103108. */
  103109. protected _setPosition(value: Vector3): void;
  103110. /**
  103111. * 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.
  103112. * Returns the SpotLight.
  103113. */
  103114. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103115. protected _computeProjectionTextureViewLightMatrix(): void;
  103116. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103117. /**
  103118. * Main function for light texture projection matrix computing.
  103119. */
  103120. protected _computeProjectionTextureMatrix(): void;
  103121. protected _buildUniformLayout(): void;
  103122. private _computeAngleValues;
  103123. /**
  103124. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103125. * @param effect The effect to update
  103126. * @param lightIndex The index of the light in the effect to update
  103127. * @returns The spot light
  103128. */
  103129. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103130. /**
  103131. * Disposes the light and the associated resources.
  103132. */
  103133. dispose(): void;
  103134. /**
  103135. * Prepares the list of defines specific to the light type.
  103136. * @param defines the list of defines
  103137. * @param lightIndex defines the index of the light for the effect
  103138. */
  103139. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103140. }
  103141. }
  103142. declare module BABYLON {
  103143. /**
  103144. * Gizmo that enables viewing a light
  103145. */
  103146. export class LightGizmo extends Gizmo {
  103147. private _lightMesh;
  103148. private _material;
  103149. /**
  103150. * Creates a LightGizmo
  103151. * @param gizmoLayer The utility layer the gizmo will be added to
  103152. */
  103153. constructor(gizmoLayer?: UtilityLayerRenderer);
  103154. private _light;
  103155. /**
  103156. * The light that the gizmo is attached to
  103157. */
  103158. light: Nullable<Light>;
  103159. /**
  103160. * @hidden
  103161. * Updates the gizmo to match the attached mesh's position/rotation
  103162. */
  103163. protected _update(): void;
  103164. private static _Scale;
  103165. /**
  103166. * Creates the lines for a light mesh
  103167. */
  103168. private static _createLightLines;
  103169. private static _CreateHemisphericLightMesh;
  103170. private static _CreatePointLightMesh;
  103171. private static _CreateSpotLightMesh;
  103172. private static _CreateDirectionalLightMesh;
  103173. }
  103174. }
  103175. declare module BABYLON {
  103176. /** @hidden */
  103177. export var backgroundFragmentDeclaration: {
  103178. name: string;
  103179. shader: string;
  103180. };
  103181. }
  103182. declare module BABYLON {
  103183. /** @hidden */
  103184. export var backgroundUboDeclaration: {
  103185. name: string;
  103186. shader: string;
  103187. };
  103188. }
  103189. declare module BABYLON {
  103190. /** @hidden */
  103191. export var backgroundPixelShader: {
  103192. name: string;
  103193. shader: string;
  103194. };
  103195. }
  103196. declare module BABYLON {
  103197. /** @hidden */
  103198. export var backgroundVertexDeclaration: {
  103199. name: string;
  103200. shader: string;
  103201. };
  103202. }
  103203. declare module BABYLON {
  103204. /** @hidden */
  103205. export var backgroundVertexShader: {
  103206. name: string;
  103207. shader: string;
  103208. };
  103209. }
  103210. declare module BABYLON {
  103211. /**
  103212. * Background material used to create an efficient environement around your scene.
  103213. */
  103214. export class BackgroundMaterial extends PushMaterial {
  103215. /**
  103216. * Standard reflectance value at parallel view angle.
  103217. */
  103218. static StandardReflectance0: number;
  103219. /**
  103220. * Standard reflectance value at grazing angle.
  103221. */
  103222. static StandardReflectance90: number;
  103223. protected _primaryColor: Color3;
  103224. /**
  103225. * Key light Color (multiply against the environement texture)
  103226. */
  103227. primaryColor: Color3;
  103228. protected __perceptualColor: Nullable<Color3>;
  103229. /**
  103230. * Experimental Internal Use Only.
  103231. *
  103232. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  103233. * This acts as a helper to set the primary color to a more "human friendly" value.
  103234. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  103235. * output color as close as possible from the chosen value.
  103236. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  103237. * part of lighting setup.)
  103238. */
  103239. _perceptualColor: Nullable<Color3>;
  103240. protected _primaryColorShadowLevel: float;
  103241. /**
  103242. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  103243. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  103244. */
  103245. primaryColorShadowLevel: float;
  103246. protected _primaryColorHighlightLevel: float;
  103247. /**
  103248. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  103249. * The primary color is used at the level chosen to define what the white area would look.
  103250. */
  103251. primaryColorHighlightLevel: float;
  103252. protected _reflectionTexture: Nullable<BaseTexture>;
  103253. /**
  103254. * Reflection Texture used in the material.
  103255. * Should be author in a specific way for the best result (refer to the documentation).
  103256. */
  103257. reflectionTexture: Nullable<BaseTexture>;
  103258. protected _reflectionBlur: float;
  103259. /**
  103260. * Reflection Texture level of blur.
  103261. *
  103262. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  103263. * texture twice.
  103264. */
  103265. reflectionBlur: float;
  103266. protected _diffuseTexture: Nullable<BaseTexture>;
  103267. /**
  103268. * Diffuse Texture used in the material.
  103269. * Should be author in a specific way for the best result (refer to the documentation).
  103270. */
  103271. diffuseTexture: Nullable<BaseTexture>;
  103272. protected _shadowLights: Nullable<IShadowLight[]>;
  103273. /**
  103274. * Specify the list of lights casting shadow on the material.
  103275. * All scene shadow lights will be included if null.
  103276. */
  103277. shadowLights: Nullable<IShadowLight[]>;
  103278. protected _shadowLevel: float;
  103279. /**
  103280. * Helps adjusting the shadow to a softer level if required.
  103281. * 0 means black shadows and 1 means no shadows.
  103282. */
  103283. shadowLevel: float;
  103284. protected _sceneCenter: Vector3;
  103285. /**
  103286. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  103287. * It is usually zero but might be interesting to modify according to your setup.
  103288. */
  103289. sceneCenter: Vector3;
  103290. protected _opacityFresnel: boolean;
  103291. /**
  103292. * This helps specifying that the material is falling off to the sky box at grazing angle.
  103293. * This helps ensuring a nice transition when the camera goes under the ground.
  103294. */
  103295. opacityFresnel: boolean;
  103296. protected _reflectionFresnel: boolean;
  103297. /**
  103298. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  103299. * This helps adding a mirror texture on the ground.
  103300. */
  103301. reflectionFresnel: boolean;
  103302. protected _reflectionFalloffDistance: number;
  103303. /**
  103304. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  103305. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  103306. */
  103307. reflectionFalloffDistance: number;
  103308. protected _reflectionAmount: number;
  103309. /**
  103310. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  103311. */
  103312. reflectionAmount: number;
  103313. protected _reflectionReflectance0: number;
  103314. /**
  103315. * This specifies the weight of the reflection at grazing angle.
  103316. */
  103317. reflectionReflectance0: number;
  103318. protected _reflectionReflectance90: number;
  103319. /**
  103320. * This specifies the weight of the reflection at a perpendicular point of view.
  103321. */
  103322. reflectionReflectance90: number;
  103323. /**
  103324. * Sets the reflection reflectance fresnel values according to the default standard
  103325. * empirically know to work well :-)
  103326. */
  103327. reflectionStandardFresnelWeight: number;
  103328. protected _useRGBColor: boolean;
  103329. /**
  103330. * Helps to directly use the maps channels instead of their level.
  103331. */
  103332. useRGBColor: boolean;
  103333. protected _enableNoise: boolean;
  103334. /**
  103335. * This helps reducing the banding effect that could occur on the background.
  103336. */
  103337. enableNoise: boolean;
  103338. /**
  103339. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103340. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  103341. * Recommended to be keep at 1.0 except for special cases.
  103342. */
  103343. fovMultiplier: number;
  103344. private _fovMultiplier;
  103345. /**
  103346. * Enable the FOV adjustment feature controlled by fovMultiplier.
  103347. */
  103348. useEquirectangularFOV: boolean;
  103349. private _maxSimultaneousLights;
  103350. /**
  103351. * Number of Simultaneous lights allowed on the material.
  103352. */
  103353. maxSimultaneousLights: int;
  103354. /**
  103355. * Default configuration related to image processing available in the Background Material.
  103356. */
  103357. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103358. /**
  103359. * Keep track of the image processing observer to allow dispose and replace.
  103360. */
  103361. private _imageProcessingObserver;
  103362. /**
  103363. * Attaches a new image processing configuration to the PBR Material.
  103364. * @param configuration (if null the scene configuration will be use)
  103365. */
  103366. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103367. /**
  103368. * Gets the image processing configuration used either in this material.
  103369. */
  103370. /**
  103371. * Sets the Default image processing configuration used either in the this material.
  103372. *
  103373. * If sets to null, the scene one is in use.
  103374. */
  103375. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  103376. /**
  103377. * Gets wether the color curves effect is enabled.
  103378. */
  103379. /**
  103380. * Sets wether the color curves effect is enabled.
  103381. */
  103382. cameraColorCurvesEnabled: boolean;
  103383. /**
  103384. * Gets wether the color grading effect is enabled.
  103385. */
  103386. /**
  103387. * Gets wether the color grading effect is enabled.
  103388. */
  103389. cameraColorGradingEnabled: boolean;
  103390. /**
  103391. * Gets wether tonemapping is enabled or not.
  103392. */
  103393. /**
  103394. * Sets wether tonemapping is enabled or not
  103395. */
  103396. cameraToneMappingEnabled: boolean;
  103397. /**
  103398. * The camera exposure used on this material.
  103399. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103400. * This corresponds to a photographic exposure.
  103401. */
  103402. /**
  103403. * The camera exposure used on this material.
  103404. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103405. * This corresponds to a photographic exposure.
  103406. */
  103407. cameraExposure: float;
  103408. /**
  103409. * Gets The camera contrast used on this material.
  103410. */
  103411. /**
  103412. * Sets The camera contrast used on this material.
  103413. */
  103414. cameraContrast: float;
  103415. /**
  103416. * Gets the Color Grading 2D Lookup Texture.
  103417. */
  103418. /**
  103419. * Sets the Color Grading 2D Lookup Texture.
  103420. */
  103421. cameraColorGradingTexture: Nullable<BaseTexture>;
  103422. /**
  103423. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103424. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103425. * 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;
  103426. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103427. */
  103428. /**
  103429. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103430. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103431. * 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;
  103432. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103433. */
  103434. cameraColorCurves: Nullable<ColorCurves>;
  103435. /**
  103436. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  103437. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  103438. */
  103439. switchToBGR: boolean;
  103440. private _renderTargets;
  103441. private _reflectionControls;
  103442. private _white;
  103443. private _primaryShadowColor;
  103444. private _primaryHighlightColor;
  103445. /**
  103446. * Instantiates a Background Material in the given scene
  103447. * @param name The friendly name of the material
  103448. * @param scene The scene to add the material to
  103449. */
  103450. constructor(name: string, scene: Scene);
  103451. /**
  103452. * Gets a boolean indicating that current material needs to register RTT
  103453. */
  103454. readonly hasRenderTargetTextures: boolean;
  103455. /**
  103456. * The entire material has been created in order to prevent overdraw.
  103457. * @returns false
  103458. */
  103459. needAlphaTesting(): boolean;
  103460. /**
  103461. * The entire material has been created in order to prevent overdraw.
  103462. * @returns true if blending is enable
  103463. */
  103464. needAlphaBlending(): boolean;
  103465. /**
  103466. * Checks wether the material is ready to be rendered for a given mesh.
  103467. * @param mesh The mesh to render
  103468. * @param subMesh The submesh to check against
  103469. * @param useInstances Specify wether or not the material is used with instances
  103470. * @returns true if all the dependencies are ready (Textures, Effects...)
  103471. */
  103472. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103473. /**
  103474. * Compute the primary color according to the chosen perceptual color.
  103475. */
  103476. private _computePrimaryColorFromPerceptualColor;
  103477. /**
  103478. * Compute the highlights and shadow colors according to their chosen levels.
  103479. */
  103480. private _computePrimaryColors;
  103481. /**
  103482. * Build the uniform buffer used in the material.
  103483. */
  103484. buildUniformLayout(): void;
  103485. /**
  103486. * Unbind the material.
  103487. */
  103488. unbind(): void;
  103489. /**
  103490. * Bind only the world matrix to the material.
  103491. * @param world The world matrix to bind.
  103492. */
  103493. bindOnlyWorldMatrix(world: Matrix): void;
  103494. /**
  103495. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  103496. * @param world The world matrix to bind.
  103497. * @param subMesh The submesh to bind for.
  103498. */
  103499. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103500. /**
  103501. * Dispose the material.
  103502. * @param forceDisposeEffect Force disposal of the associated effect.
  103503. * @param forceDisposeTextures Force disposal of the associated textures.
  103504. */
  103505. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103506. /**
  103507. * Clones the material.
  103508. * @param name The cloned name.
  103509. * @returns The cloned material.
  103510. */
  103511. clone(name: string): BackgroundMaterial;
  103512. /**
  103513. * Serializes the current material to its JSON representation.
  103514. * @returns The JSON representation.
  103515. */
  103516. serialize(): any;
  103517. /**
  103518. * Gets the class name of the material
  103519. * @returns "BackgroundMaterial"
  103520. */
  103521. getClassName(): string;
  103522. /**
  103523. * Parse a JSON input to create back a background material.
  103524. * @param source The JSON data to parse
  103525. * @param scene The scene to create the parsed material in
  103526. * @param rootUrl The root url of the assets the material depends upon
  103527. * @returns the instantiated BackgroundMaterial.
  103528. */
  103529. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103530. }
  103531. }
  103532. declare module BABYLON {
  103533. /**
  103534. * Represents the different options available during the creation of
  103535. * a Environment helper.
  103536. *
  103537. * This can control the default ground, skybox and image processing setup of your scene.
  103538. */
  103539. export interface IEnvironmentHelperOptions {
  103540. /**
  103541. * Specifies wether or not to create a ground.
  103542. * True by default.
  103543. */
  103544. createGround: boolean;
  103545. /**
  103546. * Specifies the ground size.
  103547. * 15 by default.
  103548. */
  103549. groundSize: number;
  103550. /**
  103551. * The texture used on the ground for the main color.
  103552. * Comes from the BabylonJS CDN by default.
  103553. *
  103554. * Remarks: Can be either a texture or a url.
  103555. */
  103556. groundTexture: string | BaseTexture;
  103557. /**
  103558. * The color mixed in the ground texture by default.
  103559. * BabylonJS clearColor by default.
  103560. */
  103561. groundColor: Color3;
  103562. /**
  103563. * Specifies the ground opacity.
  103564. * 1 by default.
  103565. */
  103566. groundOpacity: number;
  103567. /**
  103568. * Enables the ground to receive shadows.
  103569. * True by default.
  103570. */
  103571. enableGroundShadow: boolean;
  103572. /**
  103573. * Helps preventing the shadow to be fully black on the ground.
  103574. * 0.5 by default.
  103575. */
  103576. groundShadowLevel: number;
  103577. /**
  103578. * Creates a mirror texture attach to the ground.
  103579. * false by default.
  103580. */
  103581. enableGroundMirror: boolean;
  103582. /**
  103583. * Specifies the ground mirror size ratio.
  103584. * 0.3 by default as the default kernel is 64.
  103585. */
  103586. groundMirrorSizeRatio: number;
  103587. /**
  103588. * Specifies the ground mirror blur kernel size.
  103589. * 64 by default.
  103590. */
  103591. groundMirrorBlurKernel: number;
  103592. /**
  103593. * Specifies the ground mirror visibility amount.
  103594. * 1 by default
  103595. */
  103596. groundMirrorAmount: number;
  103597. /**
  103598. * Specifies the ground mirror reflectance weight.
  103599. * This uses the standard weight of the background material to setup the fresnel effect
  103600. * of the mirror.
  103601. * 1 by default.
  103602. */
  103603. groundMirrorFresnelWeight: number;
  103604. /**
  103605. * Specifies the ground mirror Falloff distance.
  103606. * This can helps reducing the size of the reflection.
  103607. * 0 by Default.
  103608. */
  103609. groundMirrorFallOffDistance: number;
  103610. /**
  103611. * Specifies the ground mirror texture type.
  103612. * Unsigned Int by Default.
  103613. */
  103614. groundMirrorTextureType: number;
  103615. /**
  103616. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103617. * the shown objects.
  103618. */
  103619. groundYBias: number;
  103620. /**
  103621. * Specifies wether or not to create a skybox.
  103622. * True by default.
  103623. */
  103624. createSkybox: boolean;
  103625. /**
  103626. * Specifies the skybox size.
  103627. * 20 by default.
  103628. */
  103629. skyboxSize: number;
  103630. /**
  103631. * The texture used on the skybox for the main color.
  103632. * Comes from the BabylonJS CDN by default.
  103633. *
  103634. * Remarks: Can be either a texture or a url.
  103635. */
  103636. skyboxTexture: string | BaseTexture;
  103637. /**
  103638. * The color mixed in the skybox texture by default.
  103639. * BabylonJS clearColor by default.
  103640. */
  103641. skyboxColor: Color3;
  103642. /**
  103643. * The background rotation around the Y axis of the scene.
  103644. * This helps aligning the key lights of your scene with the background.
  103645. * 0 by default.
  103646. */
  103647. backgroundYRotation: number;
  103648. /**
  103649. * Compute automatically the size of the elements to best fit with the scene.
  103650. */
  103651. sizeAuto: boolean;
  103652. /**
  103653. * Default position of the rootMesh if autoSize is not true.
  103654. */
  103655. rootPosition: Vector3;
  103656. /**
  103657. * Sets up the image processing in the scene.
  103658. * true by default.
  103659. */
  103660. setupImageProcessing: boolean;
  103661. /**
  103662. * The texture used as your environment texture in the scene.
  103663. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103664. *
  103665. * Remarks: Can be either a texture or a url.
  103666. */
  103667. environmentTexture: string | BaseTexture;
  103668. /**
  103669. * The value of the exposure to apply to the scene.
  103670. * 0.6 by default if setupImageProcessing is true.
  103671. */
  103672. cameraExposure: number;
  103673. /**
  103674. * The value of the contrast to apply to the scene.
  103675. * 1.6 by default if setupImageProcessing is true.
  103676. */
  103677. cameraContrast: number;
  103678. /**
  103679. * Specifies wether or not tonemapping should be enabled in the scene.
  103680. * true by default if setupImageProcessing is true.
  103681. */
  103682. toneMappingEnabled: boolean;
  103683. }
  103684. /**
  103685. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103686. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103687. * It also helps with the default setup of your imageProcessing configuration.
  103688. */
  103689. export class EnvironmentHelper {
  103690. /**
  103691. * Default ground texture URL.
  103692. */
  103693. private static _groundTextureCDNUrl;
  103694. /**
  103695. * Default skybox texture URL.
  103696. */
  103697. private static _skyboxTextureCDNUrl;
  103698. /**
  103699. * Default environment texture URL.
  103700. */
  103701. private static _environmentTextureCDNUrl;
  103702. /**
  103703. * Creates the default options for the helper.
  103704. */
  103705. private static _getDefaultOptions;
  103706. private _rootMesh;
  103707. /**
  103708. * Gets the root mesh created by the helper.
  103709. */
  103710. readonly rootMesh: Mesh;
  103711. private _skybox;
  103712. /**
  103713. * Gets the skybox created by the helper.
  103714. */
  103715. readonly skybox: Nullable<Mesh>;
  103716. private _skyboxTexture;
  103717. /**
  103718. * Gets the skybox texture created by the helper.
  103719. */
  103720. readonly skyboxTexture: Nullable<BaseTexture>;
  103721. private _skyboxMaterial;
  103722. /**
  103723. * Gets the skybox material created by the helper.
  103724. */
  103725. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103726. private _ground;
  103727. /**
  103728. * Gets the ground mesh created by the helper.
  103729. */
  103730. readonly ground: Nullable<Mesh>;
  103731. private _groundTexture;
  103732. /**
  103733. * Gets the ground texture created by the helper.
  103734. */
  103735. readonly groundTexture: Nullable<BaseTexture>;
  103736. private _groundMirror;
  103737. /**
  103738. * Gets the ground mirror created by the helper.
  103739. */
  103740. readonly groundMirror: Nullable<MirrorTexture>;
  103741. /**
  103742. * Gets the ground mirror render list to helps pushing the meshes
  103743. * you wish in the ground reflection.
  103744. */
  103745. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103746. private _groundMaterial;
  103747. /**
  103748. * Gets the ground material created by the helper.
  103749. */
  103750. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103751. /**
  103752. * Stores the creation options.
  103753. */
  103754. private readonly _scene;
  103755. private _options;
  103756. /**
  103757. * This observable will be notified with any error during the creation of the environment,
  103758. * mainly texture creation errors.
  103759. */
  103760. onErrorObservable: Observable<{
  103761. message?: string;
  103762. exception?: any;
  103763. }>;
  103764. /**
  103765. * constructor
  103766. * @param options Defines the options we want to customize the helper
  103767. * @param scene The scene to add the material to
  103768. */
  103769. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103770. /**
  103771. * Updates the background according to the new options
  103772. * @param options
  103773. */
  103774. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103775. /**
  103776. * Sets the primary color of all the available elements.
  103777. * @param color the main color to affect to the ground and the background
  103778. */
  103779. setMainColor(color: Color3): void;
  103780. /**
  103781. * Setup the image processing according to the specified options.
  103782. */
  103783. private _setupImageProcessing;
  103784. /**
  103785. * Setup the environment texture according to the specified options.
  103786. */
  103787. private _setupEnvironmentTexture;
  103788. /**
  103789. * Setup the background according to the specified options.
  103790. */
  103791. private _setupBackground;
  103792. /**
  103793. * Get the scene sizes according to the setup.
  103794. */
  103795. private _getSceneSize;
  103796. /**
  103797. * Setup the ground according to the specified options.
  103798. */
  103799. private _setupGround;
  103800. /**
  103801. * Setup the ground material according to the specified options.
  103802. */
  103803. private _setupGroundMaterial;
  103804. /**
  103805. * Setup the ground diffuse texture according to the specified options.
  103806. */
  103807. private _setupGroundDiffuseTexture;
  103808. /**
  103809. * Setup the ground mirror texture according to the specified options.
  103810. */
  103811. private _setupGroundMirrorTexture;
  103812. /**
  103813. * Setup the ground to receive the mirror texture.
  103814. */
  103815. private _setupMirrorInGroundMaterial;
  103816. /**
  103817. * Setup the skybox according to the specified options.
  103818. */
  103819. private _setupSkybox;
  103820. /**
  103821. * Setup the skybox material according to the specified options.
  103822. */
  103823. private _setupSkyboxMaterial;
  103824. /**
  103825. * Setup the skybox reflection texture according to the specified options.
  103826. */
  103827. private _setupSkyboxReflectionTexture;
  103828. private _errorHandler;
  103829. /**
  103830. * Dispose all the elements created by the Helper.
  103831. */
  103832. dispose(): void;
  103833. }
  103834. }
  103835. declare module BABYLON {
  103836. /**
  103837. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  103838. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103839. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103840. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103841. */
  103842. export class PhotoDome extends TransformNode {
  103843. private _useDirectMapping;
  103844. /**
  103845. * The texture being displayed on the sphere
  103846. */
  103847. protected _photoTexture: Texture;
  103848. /**
  103849. * Gets or sets the texture being displayed on the sphere
  103850. */
  103851. photoTexture: Texture;
  103852. /**
  103853. * Observable raised when an error occured while loading the 360 image
  103854. */
  103855. onLoadErrorObservable: Observable<string>;
  103856. /**
  103857. * The skybox material
  103858. */
  103859. protected _material: BackgroundMaterial;
  103860. /**
  103861. * The surface used for the skybox
  103862. */
  103863. protected _mesh: Mesh;
  103864. /**
  103865. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103866. * Also see the options.resolution property.
  103867. */
  103868. fovMultiplier: number;
  103869. /**
  103870. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103871. * @param name Element's name, child elements will append suffixes for their own names.
  103872. * @param urlsOfPhoto defines the url of the photo to display
  103873. * @param options defines an object containing optional or exposed sub element properties
  103874. * @param onError defines a callback called when an error occured while loading the texture
  103875. */
  103876. constructor(name: string, urlOfPhoto: string, options: {
  103877. resolution?: number;
  103878. size?: number;
  103879. useDirectMapping?: boolean;
  103880. faceForward?: boolean;
  103881. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103882. /**
  103883. * Releases resources associated with this node.
  103884. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103885. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103886. */
  103887. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103888. }
  103889. }
  103890. declare module BABYLON {
  103891. /** @hidden */
  103892. export var rgbdDecodePixelShader: {
  103893. name: string;
  103894. shader: string;
  103895. };
  103896. }
  103897. declare module BABYLON {
  103898. /**
  103899. * Class used to host texture specific utilities
  103900. */
  103901. export class BRDFTextureTools {
  103902. /**
  103903. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103904. * @param texture the texture to expand.
  103905. */
  103906. private static _ExpandDefaultBRDFTexture;
  103907. /**
  103908. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103909. * @param scene defines the hosting scene
  103910. * @returns the environment BRDF texture
  103911. */
  103912. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103913. private static _environmentBRDFBase64Texture;
  103914. }
  103915. }
  103916. declare module BABYLON {
  103917. /**
  103918. * @hidden
  103919. */
  103920. export interface IMaterialClearCoatDefines {
  103921. CLEARCOAT: boolean;
  103922. CLEARCOAT_DEFAULTIOR: boolean;
  103923. CLEARCOAT_TEXTURE: boolean;
  103924. CLEARCOAT_TEXTUREDIRECTUV: number;
  103925. CLEARCOAT_BUMP: boolean;
  103926. CLEARCOAT_BUMPDIRECTUV: number;
  103927. CLEARCOAT_TINT: boolean;
  103928. CLEARCOAT_TINT_TEXTURE: boolean;
  103929. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103930. /** @hidden */
  103931. _areTexturesDirty: boolean;
  103932. }
  103933. /**
  103934. * Define the code related to the clear coat parameters of the pbr material.
  103935. */
  103936. export class PBRClearCoatConfiguration {
  103937. /**
  103938. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103939. * The default fits with a polyurethane material.
  103940. */
  103941. private static readonly _DefaultIndiceOfRefraction;
  103942. private _isEnabled;
  103943. /**
  103944. * Defines if the clear coat is enabled in the material.
  103945. */
  103946. isEnabled: boolean;
  103947. /**
  103948. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103949. */
  103950. intensity: number;
  103951. /**
  103952. * Defines the clear coat layer roughness.
  103953. */
  103954. roughness: number;
  103955. private _indiceOfRefraction;
  103956. /**
  103957. * Defines the indice of refraction of the clear coat.
  103958. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103959. * The default fits with a polyurethane material.
  103960. * Changing the default value is more performance intensive.
  103961. */
  103962. indiceOfRefraction: number;
  103963. private _texture;
  103964. /**
  103965. * Stores the clear coat values in a texture.
  103966. */
  103967. texture: Nullable<BaseTexture>;
  103968. private _bumpTexture;
  103969. /**
  103970. * Define the clear coat specific bump texture.
  103971. */
  103972. bumpTexture: Nullable<BaseTexture>;
  103973. private _isTintEnabled;
  103974. /**
  103975. * Defines if the clear coat tint is enabled in the material.
  103976. */
  103977. isTintEnabled: boolean;
  103978. /**
  103979. * Defines the clear coat tint of the material.
  103980. * This is only use if tint is enabled
  103981. */
  103982. tintColor: Color3;
  103983. /**
  103984. * Defines the distance at which the tint color should be found in the
  103985. * clear coat media.
  103986. * This is only use if tint is enabled
  103987. */
  103988. tintColorAtDistance: number;
  103989. /**
  103990. * Defines the clear coat layer thickness.
  103991. * This is only use if tint is enabled
  103992. */
  103993. tintThickness: number;
  103994. private _tintTexture;
  103995. /**
  103996. * Stores the clear tint values in a texture.
  103997. * rgb is tint
  103998. * a is a thickness factor
  103999. */
  104000. tintTexture: Nullable<BaseTexture>;
  104001. /** @hidden */
  104002. private _internalMarkAllSubMeshesAsTexturesDirty;
  104003. /** @hidden */
  104004. _markAllSubMeshesAsTexturesDirty(): void;
  104005. /**
  104006. * Instantiate a new istance of clear coat configuration.
  104007. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104008. */
  104009. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104010. /**
  104011. * Gets wehter the submesh is ready to be used or not.
  104012. * @param defines the list of "defines" to update.
  104013. * @param scene defines the scene the material belongs to.
  104014. * @param engine defines the engine the material belongs to.
  104015. * @param disableBumpMap defines wether the material disables bump or not.
  104016. * @returns - boolean indicating that the submesh is ready or not.
  104017. */
  104018. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  104019. /**
  104020. * Checks to see if a texture is used in the material.
  104021. * @param defines the list of "defines" to update.
  104022. * @param scene defines the scene to the material belongs to.
  104023. */
  104024. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  104025. /**
  104026. * Binds the material data.
  104027. * @param uniformBuffer defines the Uniform buffer to fill in.
  104028. * @param scene defines the scene the material belongs to.
  104029. * @param engine defines the engine the material belongs to.
  104030. * @param disableBumpMap defines wether the material disables bump or not.
  104031. * @param isFrozen defines wether the material is frozen or not.
  104032. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104033. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104034. */
  104035. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  104036. /**
  104037. * Checks to see if a texture is used in the material.
  104038. * @param texture - Base texture to use.
  104039. * @returns - Boolean specifying if a texture is used in the material.
  104040. */
  104041. hasTexture(texture: BaseTexture): boolean;
  104042. /**
  104043. * Returns an array of the actively used textures.
  104044. * @param activeTextures Array of BaseTextures
  104045. */
  104046. getActiveTextures(activeTextures: BaseTexture[]): void;
  104047. /**
  104048. * Returns the animatable textures.
  104049. * @param animatables Array of animatable textures.
  104050. */
  104051. getAnimatables(animatables: IAnimatable[]): void;
  104052. /**
  104053. * Disposes the resources of the material.
  104054. * @param forceDisposeTextures - Forces the disposal of all textures.
  104055. */
  104056. dispose(forceDisposeTextures?: boolean): void;
  104057. /**
  104058. * Get the current class name of the texture useful for serialization or dynamic coding.
  104059. * @returns "PBRClearCoatConfiguration"
  104060. */
  104061. getClassName(): string;
  104062. /**
  104063. * Add fallbacks to the effect fallbacks list.
  104064. * @param defines defines the Base texture to use.
  104065. * @param fallbacks defines the current fallback list.
  104066. * @param currentRank defines the current fallback rank.
  104067. * @returns the new fallback rank.
  104068. */
  104069. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104070. /**
  104071. * Add the required uniforms to the current list.
  104072. * @param uniforms defines the current uniform list.
  104073. */
  104074. static AddUniforms(uniforms: string[]): void;
  104075. /**
  104076. * Add the required samplers to the current list.
  104077. * @param samplers defines the current sampler list.
  104078. */
  104079. static AddSamplers(samplers: string[]): void;
  104080. /**
  104081. * Add the required uniforms to the current buffer.
  104082. * @param uniformBuffer defines the current uniform buffer.
  104083. */
  104084. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104085. /**
  104086. * Makes a duplicate of the current configuration into another one.
  104087. * @param clearCoatConfiguration define the config where to copy the info
  104088. */
  104089. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104090. /**
  104091. * Serializes this clear coat configuration.
  104092. * @returns - An object with the serialized config.
  104093. */
  104094. serialize(): any;
  104095. /**
  104096. * Parses a Clear Coat Configuration from a serialized object.
  104097. * @param source - Serialized object.
  104098. */
  104099. parse(source: any): void;
  104100. }
  104101. }
  104102. declare module BABYLON {
  104103. /**
  104104. * @hidden
  104105. */
  104106. export interface IMaterialAnisotropicDefines {
  104107. ANISOTROPIC: boolean;
  104108. ANISOTROPIC_TEXTURE: boolean;
  104109. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104110. MAINUV1: boolean;
  104111. _areTexturesDirty: boolean;
  104112. _needUVs: boolean;
  104113. }
  104114. /**
  104115. * Define the code related to the anisotropic parameters of the pbr material.
  104116. */
  104117. export class PBRAnisotropicConfiguration {
  104118. private _isEnabled;
  104119. /**
  104120. * Defines if the anisotropy is enabled in the material.
  104121. */
  104122. isEnabled: boolean;
  104123. /**
  104124. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104125. */
  104126. intensity: number;
  104127. /**
  104128. * Defines if the effect is along the tangents, bitangents or in between.
  104129. * By default, the effect is "strectching" the highlights along the tangents.
  104130. */
  104131. direction: Vector2;
  104132. private _texture;
  104133. /**
  104134. * Stores the anisotropy values in a texture.
  104135. * rg is direction (like normal from -1 to 1)
  104136. * b is a intensity
  104137. */
  104138. texture: Nullable<BaseTexture>;
  104139. /** @hidden */
  104140. private _internalMarkAllSubMeshesAsTexturesDirty;
  104141. /** @hidden */
  104142. _markAllSubMeshesAsTexturesDirty(): void;
  104143. /**
  104144. * Instantiate a new istance of anisotropy configuration.
  104145. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104146. */
  104147. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104148. /**
  104149. * Specifies that the submesh is ready to be used.
  104150. * @param defines the list of "defines" to update.
  104151. * @param scene defines the scene the material belongs to.
  104152. * @returns - boolean indicating that the submesh is ready or not.
  104153. */
  104154. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104155. /**
  104156. * Checks to see if a texture is used in the material.
  104157. * @param defines the list of "defines" to update.
  104158. * @param mesh the mesh we are preparing the defines for.
  104159. * @param scene defines the scene the material belongs to.
  104160. */
  104161. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104162. /**
  104163. * Binds the material data.
  104164. * @param uniformBuffer defines the Uniform buffer to fill in.
  104165. * @param scene defines the scene the material belongs to.
  104166. * @param isFrozen defines wether the material is frozen or not.
  104167. */
  104168. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104169. /**
  104170. * Checks to see if a texture is used in the material.
  104171. * @param texture - Base texture to use.
  104172. * @returns - Boolean specifying if a texture is used in the material.
  104173. */
  104174. hasTexture(texture: BaseTexture): boolean;
  104175. /**
  104176. * Returns an array of the actively used textures.
  104177. * @param activeTextures Array of BaseTextures
  104178. */
  104179. getActiveTextures(activeTextures: BaseTexture[]): void;
  104180. /**
  104181. * Returns the animatable textures.
  104182. * @param animatables Array of animatable textures.
  104183. */
  104184. getAnimatables(animatables: IAnimatable[]): void;
  104185. /**
  104186. * Disposes the resources of the material.
  104187. * @param forceDisposeTextures - Forces the disposal of all textures.
  104188. */
  104189. dispose(forceDisposeTextures?: boolean): void;
  104190. /**
  104191. * Get the current class name of the texture useful for serialization or dynamic coding.
  104192. * @returns "PBRAnisotropicConfiguration"
  104193. */
  104194. getClassName(): string;
  104195. /**
  104196. * Add fallbacks to the effect fallbacks list.
  104197. * @param defines defines the Base texture to use.
  104198. * @param fallbacks defines the current fallback list.
  104199. * @param currentRank defines the current fallback rank.
  104200. * @returns the new fallback rank.
  104201. */
  104202. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104203. /**
  104204. * Add the required uniforms to the current list.
  104205. * @param uniforms defines the current uniform list.
  104206. */
  104207. static AddUniforms(uniforms: string[]): void;
  104208. /**
  104209. * Add the required uniforms to the current buffer.
  104210. * @param uniformBuffer defines the current uniform buffer.
  104211. */
  104212. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104213. /**
  104214. * Add the required samplers to the current list.
  104215. * @param samplers defines the current sampler list.
  104216. */
  104217. static AddSamplers(samplers: string[]): void;
  104218. /**
  104219. * Makes a duplicate of the current configuration into another one.
  104220. * @param anisotropicConfiguration define the config where to copy the info
  104221. */
  104222. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104223. /**
  104224. * Serializes this anisotropy configuration.
  104225. * @returns - An object with the serialized config.
  104226. */
  104227. serialize(): any;
  104228. /**
  104229. * Parses a anisotropy Configuration from a serialized object.
  104230. * @param source - Serialized object.
  104231. */
  104232. parse(source: any): void;
  104233. }
  104234. }
  104235. declare module BABYLON {
  104236. /**
  104237. * @hidden
  104238. */
  104239. export interface IMaterialBRDFDefines {
  104240. BRDF_V_HEIGHT_CORRELATED: boolean;
  104241. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104242. SPHERICAL_HARMONICS: boolean;
  104243. /** @hidden */
  104244. _areMiscDirty: boolean;
  104245. }
  104246. /**
  104247. * Define the code related to the BRDF parameters of the pbr material.
  104248. */
  104249. export class PBRBRDFConfiguration {
  104250. /**
  104251. * Default value used for the energy conservation.
  104252. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104253. */
  104254. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104255. /**
  104256. * Default value used for the Smith Visibility Height Correlated mode.
  104257. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104258. */
  104259. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104260. /**
  104261. * Default value used for the IBL diffuse part.
  104262. * This can help switching back to the polynomials mode globally which is a tiny bit
  104263. * less GPU intensive at the drawback of a lower quality.
  104264. */
  104265. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  104266. private _useEnergyConservation;
  104267. /**
  104268. * Defines if the material uses energy conservation.
  104269. */
  104270. useEnergyConservation: boolean;
  104271. private _useSmithVisibilityHeightCorrelated;
  104272. /**
  104273. * LEGACY Mode set to false
  104274. * Defines if the material uses height smith correlated visibility term.
  104275. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104276. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104277. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104278. * Not relying on height correlated will also disable energy conservation.
  104279. */
  104280. useSmithVisibilityHeightCorrelated: boolean;
  104281. private _useSphericalHarmonics;
  104282. /**
  104283. * LEGACY Mode set to false
  104284. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  104285. * diffuse part of the IBL.
  104286. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  104287. * to the ground truth.
  104288. */
  104289. useSphericalHarmonics: boolean;
  104290. /** @hidden */
  104291. private _internalMarkAllSubMeshesAsMiscDirty;
  104292. /** @hidden */
  104293. _markAllSubMeshesAsMiscDirty(): void;
  104294. /**
  104295. * Instantiate a new istance of clear coat configuration.
  104296. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104297. */
  104298. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104299. /**
  104300. * Checks to see if a texture is used in the material.
  104301. * @param defines the list of "defines" to update.
  104302. */
  104303. prepareDefines(defines: IMaterialBRDFDefines): void;
  104304. /**
  104305. * Get the current class name of the texture useful for serialization or dynamic coding.
  104306. * @returns "PBRClearCoatConfiguration"
  104307. */
  104308. getClassName(): string;
  104309. /**
  104310. * Makes a duplicate of the current configuration into another one.
  104311. * @param brdfConfiguration define the config where to copy the info
  104312. */
  104313. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104314. /**
  104315. * Serializes this BRDF configuration.
  104316. * @returns - An object with the serialized config.
  104317. */
  104318. serialize(): any;
  104319. /**
  104320. * Parses a BRDF Configuration from a serialized object.
  104321. * @param source - Serialized object.
  104322. */
  104323. parse(source: any): void;
  104324. }
  104325. }
  104326. declare module BABYLON {
  104327. /**
  104328. * @hidden
  104329. */
  104330. export interface IMaterialSheenDefines {
  104331. SHEEN: boolean;
  104332. SHEEN_TEXTURE: boolean;
  104333. SHEEN_TEXTUREDIRECTUV: number;
  104334. SHEEN_LINKWITHALBEDO: boolean;
  104335. /** @hidden */
  104336. _areTexturesDirty: boolean;
  104337. }
  104338. /**
  104339. * Define the code related to the Sheen parameters of the pbr material.
  104340. */
  104341. export class PBRSheenConfiguration {
  104342. private _isEnabled;
  104343. /**
  104344. * Defines if the material uses sheen.
  104345. */
  104346. isEnabled: boolean;
  104347. private _linkSheenWithAlbedo;
  104348. /**
  104349. * Defines if the sheen is linked to the sheen color.
  104350. */
  104351. linkSheenWithAlbedo: boolean;
  104352. /**
  104353. * Defines the sheen intensity.
  104354. */
  104355. intensity: number;
  104356. /**
  104357. * Defines the sheen color.
  104358. */
  104359. color: Color3;
  104360. private _texture;
  104361. /**
  104362. * Stores the sheen tint values in a texture.
  104363. * rgb is tint
  104364. * a is a intensity
  104365. */
  104366. texture: Nullable<BaseTexture>;
  104367. /** @hidden */
  104368. private _internalMarkAllSubMeshesAsTexturesDirty;
  104369. /** @hidden */
  104370. _markAllSubMeshesAsTexturesDirty(): void;
  104371. /**
  104372. * Instantiate a new istance of clear coat configuration.
  104373. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104374. */
  104375. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104376. /**
  104377. * Specifies that the submesh is ready to be used.
  104378. * @param defines the list of "defines" to update.
  104379. * @param scene defines the scene the material belongs to.
  104380. * @returns - boolean indicating that the submesh is ready or not.
  104381. */
  104382. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  104383. /**
  104384. * Checks to see if a texture is used in the material.
  104385. * @param defines the list of "defines" to update.
  104386. * @param scene defines the scene the material belongs to.
  104387. */
  104388. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  104389. /**
  104390. * Binds the material data.
  104391. * @param uniformBuffer defines the Uniform buffer to fill in.
  104392. * @param scene defines the scene the material belongs to.
  104393. * @param isFrozen defines wether the material is frozen or not.
  104394. */
  104395. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104396. /**
  104397. * Checks to see if a texture is used in the material.
  104398. * @param texture - Base texture to use.
  104399. * @returns - Boolean specifying if a texture is used in the material.
  104400. */
  104401. hasTexture(texture: BaseTexture): boolean;
  104402. /**
  104403. * Returns an array of the actively used textures.
  104404. * @param activeTextures Array of BaseTextures
  104405. */
  104406. getActiveTextures(activeTextures: BaseTexture[]): void;
  104407. /**
  104408. * Returns the animatable textures.
  104409. * @param animatables Array of animatable textures.
  104410. */
  104411. getAnimatables(animatables: IAnimatable[]): void;
  104412. /**
  104413. * Disposes the resources of the material.
  104414. * @param forceDisposeTextures - Forces the disposal of all textures.
  104415. */
  104416. dispose(forceDisposeTextures?: boolean): void;
  104417. /**
  104418. * Get the current class name of the texture useful for serialization or dynamic coding.
  104419. * @returns "PBRSheenConfiguration"
  104420. */
  104421. getClassName(): string;
  104422. /**
  104423. * Add fallbacks to the effect fallbacks list.
  104424. * @param defines defines the Base texture to use.
  104425. * @param fallbacks defines the current fallback list.
  104426. * @param currentRank defines the current fallback rank.
  104427. * @returns the new fallback rank.
  104428. */
  104429. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104430. /**
  104431. * Add the required uniforms to the current list.
  104432. * @param uniforms defines the current uniform list.
  104433. */
  104434. static AddUniforms(uniforms: string[]): void;
  104435. /**
  104436. * Add the required uniforms to the current buffer.
  104437. * @param uniformBuffer defines the current uniform buffer.
  104438. */
  104439. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104440. /**
  104441. * Add the required samplers to the current list.
  104442. * @param samplers defines the current sampler list.
  104443. */
  104444. static AddSamplers(samplers: string[]): void;
  104445. /**
  104446. * Makes a duplicate of the current configuration into another one.
  104447. * @param sheenConfiguration define the config where to copy the info
  104448. */
  104449. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  104450. /**
  104451. * Serializes this BRDF configuration.
  104452. * @returns - An object with the serialized config.
  104453. */
  104454. serialize(): any;
  104455. /**
  104456. * Parses a Sheen Configuration from a serialized object.
  104457. * @param source - Serialized object.
  104458. */
  104459. parse(source: any): void;
  104460. }
  104461. }
  104462. declare module BABYLON {
  104463. /**
  104464. * @hidden
  104465. */
  104466. export interface IMaterialSubSurfaceDefines {
  104467. SUBSURFACE: boolean;
  104468. SS_REFRACTION: boolean;
  104469. SS_TRANSLUCENCY: boolean;
  104470. SS_SCATERRING: boolean;
  104471. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104472. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104473. SS_REFRACTIONMAP_3D: boolean;
  104474. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104475. SS_LODINREFRACTIONALPHA: boolean;
  104476. SS_GAMMAREFRACTION: boolean;
  104477. SS_RGBDREFRACTION: boolean;
  104478. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104479. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104480. /** @hidden */
  104481. _areTexturesDirty: boolean;
  104482. }
  104483. /**
  104484. * Define the code related to the sub surface parameters of the pbr material.
  104485. */
  104486. export class PBRSubSurfaceConfiguration {
  104487. private _isRefractionEnabled;
  104488. /**
  104489. * Defines if the refraction is enabled in the material.
  104490. */
  104491. isRefractionEnabled: boolean;
  104492. private _isTranslucencyEnabled;
  104493. /**
  104494. * Defines if the translucency is enabled in the material.
  104495. */
  104496. isTranslucencyEnabled: boolean;
  104497. private _isScatteringEnabled;
  104498. /**
  104499. * Defines the refraction intensity of the material.
  104500. * The refraction when enabled replaces the Diffuse part of the material.
  104501. * The intensity helps transitionning between diffuse and refraction.
  104502. */
  104503. refractionIntensity: number;
  104504. /**
  104505. * Defines the translucency intensity of the material.
  104506. * When translucency has been enabled, this defines how much of the "translucency"
  104507. * is addded to the diffuse part of the material.
  104508. */
  104509. translucencyIntensity: number;
  104510. /**
  104511. * Defines the scattering intensity of the material.
  104512. * When scattering has been enabled, this defines how much of the "scattered light"
  104513. * is addded to the diffuse part of the material.
  104514. */
  104515. scatteringIntensity: number;
  104516. private _thicknessTexture;
  104517. /**
  104518. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  104519. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  104520. * 0 would mean minimumThickness
  104521. * 1 would mean maximumThickness
  104522. * The other channels might be use as a mask to vary the different effects intensity.
  104523. */
  104524. thicknessTexture: Nullable<BaseTexture>;
  104525. private _refractionTexture;
  104526. /**
  104527. * Defines the texture to use for refraction.
  104528. */
  104529. refractionTexture: Nullable<BaseTexture>;
  104530. private _indexOfRefraction;
  104531. /**
  104532. * Defines the indice of refraction used in the material.
  104533. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104534. */
  104535. indexOfRefraction: number;
  104536. private _invertRefractionY;
  104537. /**
  104538. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104539. */
  104540. invertRefractionY: boolean;
  104541. private _linkRefractionWithTransparency;
  104542. /**
  104543. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104544. * Materials half opaque for instance using refraction could benefit from this control.
  104545. */
  104546. linkRefractionWithTransparency: boolean;
  104547. /**
  104548. * Defines the minimum thickness stored in the thickness map.
  104549. * If no thickness map is defined, this value will be used to simulate thickness.
  104550. */
  104551. minimumThickness: number;
  104552. /**
  104553. * Defines the maximum thickness stored in the thickness map.
  104554. */
  104555. maximumThickness: number;
  104556. /**
  104557. * Defines the volume tint of the material.
  104558. * This is used for both translucency and scattering.
  104559. */
  104560. tintColor: Color3;
  104561. /**
  104562. * Defines the distance at which the tint color should be found in the media.
  104563. * This is used for refraction only.
  104564. */
  104565. tintColorAtDistance: number;
  104566. /**
  104567. * Defines how far each channel transmit through the media.
  104568. * It is defined as a color to simplify it selection.
  104569. */
  104570. diffusionDistance: Color3;
  104571. private _useMaskFromThicknessTexture;
  104572. /**
  104573. * Stores the intensity of the different subsurface effects in the thickness texture.
  104574. * * the green channel is the translucency intensity.
  104575. * * the blue channel is the scattering intensity.
  104576. * * the alpha channel is the refraction intensity.
  104577. */
  104578. useMaskFromThicknessTexture: boolean;
  104579. /** @hidden */
  104580. private _internalMarkAllSubMeshesAsTexturesDirty;
  104581. /** @hidden */
  104582. _markAllSubMeshesAsTexturesDirty(): void;
  104583. /**
  104584. * Instantiate a new istance of sub surface configuration.
  104585. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104586. */
  104587. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104588. /**
  104589. * Gets wehter the submesh is ready to be used or not.
  104590. * @param defines the list of "defines" to update.
  104591. * @param scene defines the scene the material belongs to.
  104592. * @returns - boolean indicating that the submesh is ready or not.
  104593. */
  104594. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104595. /**
  104596. * Checks to see if a texture is used in the material.
  104597. * @param defines the list of "defines" to update.
  104598. * @param scene defines the scene to the material belongs to.
  104599. */
  104600. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104601. /**
  104602. * Binds the material data.
  104603. * @param uniformBuffer defines the Uniform buffer to fill in.
  104604. * @param scene defines the scene the material belongs to.
  104605. * @param engine defines the engine the material belongs to.
  104606. * @param isFrozen defines wether the material is frozen or not.
  104607. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104608. */
  104609. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104610. /**
  104611. * Unbinds the material from the mesh.
  104612. * @param activeEffect defines the effect that should be unbound from.
  104613. * @returns true if unbound, otherwise false
  104614. */
  104615. unbind(activeEffect: Effect): boolean;
  104616. /**
  104617. * Returns the texture used for refraction or null if none is used.
  104618. * @param scene defines the scene the material belongs to.
  104619. * @returns - Refraction texture if present. If no refraction texture and refraction
  104620. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104621. */
  104622. private _getRefractionTexture;
  104623. /**
  104624. * Returns true if alpha blending should be disabled.
  104625. */
  104626. readonly disableAlphaBlending: boolean;
  104627. /**
  104628. * Fills the list of render target textures.
  104629. * @param renderTargets the list of render targets to update
  104630. */
  104631. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104632. /**
  104633. * Checks to see if a texture is used in the material.
  104634. * @param texture - Base texture to use.
  104635. * @returns - Boolean specifying if a texture is used in the material.
  104636. */
  104637. hasTexture(texture: BaseTexture): boolean;
  104638. /**
  104639. * Gets a boolean indicating that current material needs to register RTT
  104640. * @returns true if this uses a render target otherwise false.
  104641. */
  104642. hasRenderTargetTextures(): boolean;
  104643. /**
  104644. * Returns an array of the actively used textures.
  104645. * @param activeTextures Array of BaseTextures
  104646. */
  104647. getActiveTextures(activeTextures: BaseTexture[]): void;
  104648. /**
  104649. * Returns the animatable textures.
  104650. * @param animatables Array of animatable textures.
  104651. */
  104652. getAnimatables(animatables: IAnimatable[]): void;
  104653. /**
  104654. * Disposes the resources of the material.
  104655. * @param forceDisposeTextures - Forces the disposal of all textures.
  104656. */
  104657. dispose(forceDisposeTextures?: boolean): void;
  104658. /**
  104659. * Get the current class name of the texture useful for serialization or dynamic coding.
  104660. * @returns "PBRSubSurfaceConfiguration"
  104661. */
  104662. getClassName(): string;
  104663. /**
  104664. * Add fallbacks to the effect fallbacks list.
  104665. * @param defines defines the Base texture to use.
  104666. * @param fallbacks defines the current fallback list.
  104667. * @param currentRank defines the current fallback rank.
  104668. * @returns the new fallback rank.
  104669. */
  104670. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104671. /**
  104672. * Add the required uniforms to the current list.
  104673. * @param uniforms defines the current uniform list.
  104674. */
  104675. static AddUniforms(uniforms: string[]): void;
  104676. /**
  104677. * Add the required samplers to the current list.
  104678. * @param samplers defines the current sampler list.
  104679. */
  104680. static AddSamplers(samplers: string[]): void;
  104681. /**
  104682. * Add the required uniforms to the current buffer.
  104683. * @param uniformBuffer defines the current uniform buffer.
  104684. */
  104685. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104686. /**
  104687. * Makes a duplicate of the current configuration into another one.
  104688. * @param configuration define the config where to copy the info
  104689. */
  104690. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104691. /**
  104692. * Serializes this Sub Surface configuration.
  104693. * @returns - An object with the serialized config.
  104694. */
  104695. serialize(): any;
  104696. /**
  104697. * Parses a Sub Surface Configuration from a serialized object.
  104698. * @param source - Serialized object.
  104699. */
  104700. parse(source: any): void;
  104701. }
  104702. }
  104703. declare module BABYLON {
  104704. /** @hidden */
  104705. export var pbrFragmentDeclaration: {
  104706. name: string;
  104707. shader: string;
  104708. };
  104709. }
  104710. declare module BABYLON {
  104711. /** @hidden */
  104712. export var pbrUboDeclaration: {
  104713. name: string;
  104714. shader: string;
  104715. };
  104716. }
  104717. declare module BABYLON {
  104718. /** @hidden */
  104719. export var pbrFragmentExtraDeclaration: {
  104720. name: string;
  104721. shader: string;
  104722. };
  104723. }
  104724. declare module BABYLON {
  104725. /** @hidden */
  104726. export var pbrFragmentSamplersDeclaration: {
  104727. name: string;
  104728. shader: string;
  104729. };
  104730. }
  104731. declare module BABYLON {
  104732. /** @hidden */
  104733. export var pbrHelperFunctions: {
  104734. name: string;
  104735. shader: string;
  104736. };
  104737. }
  104738. declare module BABYLON {
  104739. /** @hidden */
  104740. export var harmonicsFunctions: {
  104741. name: string;
  104742. shader: string;
  104743. };
  104744. }
  104745. declare module BABYLON {
  104746. /** @hidden */
  104747. export var pbrDirectLightingSetupFunctions: {
  104748. name: string;
  104749. shader: string;
  104750. };
  104751. }
  104752. declare module BABYLON {
  104753. /** @hidden */
  104754. export var pbrDirectLightingFalloffFunctions: {
  104755. name: string;
  104756. shader: string;
  104757. };
  104758. }
  104759. declare module BABYLON {
  104760. /** @hidden */
  104761. export var pbrBRDFFunctions: {
  104762. name: string;
  104763. shader: string;
  104764. };
  104765. }
  104766. declare module BABYLON {
  104767. /** @hidden */
  104768. export var pbrDirectLightingFunctions: {
  104769. name: string;
  104770. shader: string;
  104771. };
  104772. }
  104773. declare module BABYLON {
  104774. /** @hidden */
  104775. export var pbrIBLFunctions: {
  104776. name: string;
  104777. shader: string;
  104778. };
  104779. }
  104780. declare module BABYLON {
  104781. /** @hidden */
  104782. export var pbrDebug: {
  104783. name: string;
  104784. shader: string;
  104785. };
  104786. }
  104787. declare module BABYLON {
  104788. /** @hidden */
  104789. export var pbrPixelShader: {
  104790. name: string;
  104791. shader: string;
  104792. };
  104793. }
  104794. declare module BABYLON {
  104795. /** @hidden */
  104796. export var pbrVertexDeclaration: {
  104797. name: string;
  104798. shader: string;
  104799. };
  104800. }
  104801. declare module BABYLON {
  104802. /** @hidden */
  104803. export var pbrVertexShader: {
  104804. name: string;
  104805. shader: string;
  104806. };
  104807. }
  104808. declare module BABYLON {
  104809. /**
  104810. * Manages the defines for the PBR Material.
  104811. * @hidden
  104812. */
  104813. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  104814. PBR: boolean;
  104815. MAINUV1: boolean;
  104816. MAINUV2: boolean;
  104817. UV1: boolean;
  104818. UV2: boolean;
  104819. ALBEDO: boolean;
  104820. ALBEDODIRECTUV: number;
  104821. VERTEXCOLOR: boolean;
  104822. AMBIENT: boolean;
  104823. AMBIENTDIRECTUV: number;
  104824. AMBIENTINGRAYSCALE: boolean;
  104825. OPACITY: boolean;
  104826. VERTEXALPHA: boolean;
  104827. OPACITYDIRECTUV: number;
  104828. OPACITYRGB: boolean;
  104829. ALPHATEST: boolean;
  104830. DEPTHPREPASS: boolean;
  104831. ALPHABLEND: boolean;
  104832. ALPHAFROMALBEDO: boolean;
  104833. ALPHATESTVALUE: string;
  104834. SPECULAROVERALPHA: boolean;
  104835. RADIANCEOVERALPHA: boolean;
  104836. ALPHAFRESNEL: boolean;
  104837. LINEARALPHAFRESNEL: boolean;
  104838. PREMULTIPLYALPHA: boolean;
  104839. EMISSIVE: boolean;
  104840. EMISSIVEDIRECTUV: number;
  104841. REFLECTIVITY: boolean;
  104842. REFLECTIVITYDIRECTUV: number;
  104843. SPECULARTERM: boolean;
  104844. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  104845. MICROSURFACEAUTOMATIC: boolean;
  104846. LODBASEDMICROSFURACE: boolean;
  104847. MICROSURFACEMAP: boolean;
  104848. MICROSURFACEMAPDIRECTUV: number;
  104849. METALLICWORKFLOW: boolean;
  104850. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  104851. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  104852. METALLNESSSTOREINMETALMAPBLUE: boolean;
  104853. AOSTOREINMETALMAPRED: boolean;
  104854. ENVIRONMENTBRDF: boolean;
  104855. ENVIRONMENTBRDF_RGBD: boolean;
  104856. NORMAL: boolean;
  104857. TANGENT: boolean;
  104858. BUMP: boolean;
  104859. BUMPDIRECTUV: number;
  104860. OBJECTSPACE_NORMALMAP: boolean;
  104861. PARALLAX: boolean;
  104862. PARALLAXOCCLUSION: boolean;
  104863. NORMALXYSCALE: boolean;
  104864. LIGHTMAP: boolean;
  104865. LIGHTMAPDIRECTUV: number;
  104866. USELIGHTMAPASSHADOWMAP: boolean;
  104867. GAMMALIGHTMAP: boolean;
  104868. REFLECTION: boolean;
  104869. REFLECTIONMAP_3D: boolean;
  104870. REFLECTIONMAP_SPHERICAL: boolean;
  104871. REFLECTIONMAP_PLANAR: boolean;
  104872. REFLECTIONMAP_CUBIC: boolean;
  104873. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104874. REFLECTIONMAP_PROJECTION: boolean;
  104875. REFLECTIONMAP_SKYBOX: boolean;
  104876. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104877. REFLECTIONMAP_EXPLICIT: boolean;
  104878. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104879. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104880. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104881. INVERTCUBICMAP: boolean;
  104882. USESPHERICALFROMREFLECTIONMAP: boolean;
  104883. SPHERICAL_HARMONICS: boolean;
  104884. USESPHERICALINVERTEX: boolean;
  104885. REFLECTIONMAP_OPPOSITEZ: boolean;
  104886. LODINREFLECTIONALPHA: boolean;
  104887. GAMMAREFLECTION: boolean;
  104888. RGBDREFLECTION: boolean;
  104889. RADIANCEOCCLUSION: boolean;
  104890. HORIZONOCCLUSION: boolean;
  104891. INSTANCES: boolean;
  104892. NUM_BONE_INFLUENCERS: number;
  104893. BonesPerMesh: number;
  104894. BONETEXTURE: boolean;
  104895. NONUNIFORMSCALING: boolean;
  104896. MORPHTARGETS: boolean;
  104897. MORPHTARGETS_NORMAL: boolean;
  104898. MORPHTARGETS_TANGENT: boolean;
  104899. NUM_MORPH_INFLUENCERS: number;
  104900. IMAGEPROCESSING: boolean;
  104901. VIGNETTE: boolean;
  104902. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104903. VIGNETTEBLENDMODEOPAQUE: boolean;
  104904. TONEMAPPING: boolean;
  104905. TONEMAPPING_ACES: boolean;
  104906. CONTRAST: boolean;
  104907. COLORCURVES: boolean;
  104908. COLORGRADING: boolean;
  104909. COLORGRADING3D: boolean;
  104910. SAMPLER3DGREENDEPTH: boolean;
  104911. SAMPLER3DBGRMAP: boolean;
  104912. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104913. EXPOSURE: boolean;
  104914. MULTIVIEW: boolean;
  104915. USEPHYSICALLIGHTFALLOFF: boolean;
  104916. USEGLTFLIGHTFALLOFF: boolean;
  104917. TWOSIDEDLIGHTING: boolean;
  104918. SHADOWFLOAT: boolean;
  104919. CLIPPLANE: boolean;
  104920. CLIPPLANE2: boolean;
  104921. CLIPPLANE3: boolean;
  104922. CLIPPLANE4: boolean;
  104923. POINTSIZE: boolean;
  104924. FOG: boolean;
  104925. LOGARITHMICDEPTH: boolean;
  104926. FORCENORMALFORWARD: boolean;
  104927. SPECULARAA: boolean;
  104928. CLEARCOAT: boolean;
  104929. CLEARCOAT_DEFAULTIOR: boolean;
  104930. CLEARCOAT_TEXTURE: boolean;
  104931. CLEARCOAT_TEXTUREDIRECTUV: number;
  104932. CLEARCOAT_BUMP: boolean;
  104933. CLEARCOAT_BUMPDIRECTUV: number;
  104934. CLEARCOAT_TINT: boolean;
  104935. CLEARCOAT_TINT_TEXTURE: boolean;
  104936. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104937. ANISOTROPIC: boolean;
  104938. ANISOTROPIC_TEXTURE: boolean;
  104939. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104940. BRDF_V_HEIGHT_CORRELATED: boolean;
  104941. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104942. SHEEN: boolean;
  104943. SHEEN_TEXTURE: boolean;
  104944. SHEEN_TEXTUREDIRECTUV: number;
  104945. SHEEN_LINKWITHALBEDO: boolean;
  104946. SUBSURFACE: boolean;
  104947. SS_REFRACTION: boolean;
  104948. SS_TRANSLUCENCY: boolean;
  104949. SS_SCATERRING: boolean;
  104950. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104951. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104952. SS_REFRACTIONMAP_3D: boolean;
  104953. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104954. SS_LODINREFRACTIONALPHA: boolean;
  104955. SS_GAMMAREFRACTION: boolean;
  104956. SS_RGBDREFRACTION: boolean;
  104957. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104958. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104959. UNLIT: boolean;
  104960. DEBUGMODE: number;
  104961. /**
  104962. * Initializes the PBR Material defines.
  104963. */
  104964. constructor();
  104965. /**
  104966. * Resets the PBR Material defines.
  104967. */
  104968. reset(): void;
  104969. }
  104970. /**
  104971. * The Physically based material base class of BJS.
  104972. *
  104973. * This offers the main features of a standard PBR material.
  104974. * For more information, please refer to the documentation :
  104975. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104976. */
  104977. export abstract class PBRBaseMaterial extends PushMaterial {
  104978. /**
  104979. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104980. */
  104981. static readonly PBRMATERIAL_OPAQUE: number;
  104982. /**
  104983. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104984. */
  104985. static readonly PBRMATERIAL_ALPHATEST: number;
  104986. /**
  104987. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104988. */
  104989. static readonly PBRMATERIAL_ALPHABLEND: number;
  104990. /**
  104991. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104992. * They are also discarded below the alpha cutoff threshold to improve performances.
  104993. */
  104994. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104995. /**
  104996. * Defines the default value of how much AO map is occluding the analytical lights
  104997. * (point spot...).
  104998. */
  104999. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105000. /**
  105001. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  105002. */
  105003. static readonly LIGHTFALLOFF_PHYSICAL: number;
  105004. /**
  105005. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  105006. * to enhance interoperability with other engines.
  105007. */
  105008. static readonly LIGHTFALLOFF_GLTF: number;
  105009. /**
  105010. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  105011. * to enhance interoperability with other materials.
  105012. */
  105013. static readonly LIGHTFALLOFF_STANDARD: number;
  105014. /**
  105015. * Intensity of the direct lights e.g. the four lights available in your scene.
  105016. * This impacts both the direct diffuse and specular highlights.
  105017. */
  105018. protected _directIntensity: number;
  105019. /**
  105020. * Intensity of the emissive part of the material.
  105021. * This helps controlling the emissive effect without modifying the emissive color.
  105022. */
  105023. protected _emissiveIntensity: number;
  105024. /**
  105025. * Intensity of the environment e.g. how much the environment will light the object
  105026. * either through harmonics for rough material or through the refelction for shiny ones.
  105027. */
  105028. protected _environmentIntensity: number;
  105029. /**
  105030. * This is a special control allowing the reduction of the specular highlights coming from the
  105031. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105032. */
  105033. protected _specularIntensity: number;
  105034. /**
  105035. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  105036. */
  105037. private _lightingInfos;
  105038. /**
  105039. * Debug Control allowing disabling the bump map on this material.
  105040. */
  105041. protected _disableBumpMap: boolean;
  105042. /**
  105043. * AKA Diffuse Texture in standard nomenclature.
  105044. */
  105045. protected _albedoTexture: Nullable<BaseTexture>;
  105046. /**
  105047. * AKA Occlusion Texture in other nomenclature.
  105048. */
  105049. protected _ambientTexture: Nullable<BaseTexture>;
  105050. /**
  105051. * AKA Occlusion Texture Intensity in other nomenclature.
  105052. */
  105053. protected _ambientTextureStrength: number;
  105054. /**
  105055. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105056. * 1 means it completely occludes it
  105057. * 0 mean it has no impact
  105058. */
  105059. protected _ambientTextureImpactOnAnalyticalLights: number;
  105060. /**
  105061. * Stores the alpha values in a texture.
  105062. */
  105063. protected _opacityTexture: Nullable<BaseTexture>;
  105064. /**
  105065. * Stores the reflection values in a texture.
  105066. */
  105067. protected _reflectionTexture: Nullable<BaseTexture>;
  105068. /**
  105069. * Stores the emissive values in a texture.
  105070. */
  105071. protected _emissiveTexture: Nullable<BaseTexture>;
  105072. /**
  105073. * AKA Specular texture in other nomenclature.
  105074. */
  105075. protected _reflectivityTexture: Nullable<BaseTexture>;
  105076. /**
  105077. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105078. */
  105079. protected _metallicTexture: Nullable<BaseTexture>;
  105080. /**
  105081. * Specifies the metallic scalar of the metallic/roughness workflow.
  105082. * Can also be used to scale the metalness values of the metallic texture.
  105083. */
  105084. protected _metallic: Nullable<number>;
  105085. /**
  105086. * Specifies the roughness scalar of the metallic/roughness workflow.
  105087. * Can also be used to scale the roughness values of the metallic texture.
  105088. */
  105089. protected _roughness: Nullable<number>;
  105090. /**
  105091. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105092. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105093. */
  105094. protected _microSurfaceTexture: Nullable<BaseTexture>;
  105095. /**
  105096. * Stores surface normal data used to displace a mesh in a texture.
  105097. */
  105098. protected _bumpTexture: Nullable<BaseTexture>;
  105099. /**
  105100. * Stores the pre-calculated light information of a mesh in a texture.
  105101. */
  105102. protected _lightmapTexture: Nullable<BaseTexture>;
  105103. /**
  105104. * The color of a material in ambient lighting.
  105105. */
  105106. protected _ambientColor: Color3;
  105107. /**
  105108. * AKA Diffuse Color in other nomenclature.
  105109. */
  105110. protected _albedoColor: Color3;
  105111. /**
  105112. * AKA Specular Color in other nomenclature.
  105113. */
  105114. protected _reflectivityColor: Color3;
  105115. /**
  105116. * The color applied when light is reflected from a material.
  105117. */
  105118. protected _reflectionColor: Color3;
  105119. /**
  105120. * The color applied when light is emitted from a material.
  105121. */
  105122. protected _emissiveColor: Color3;
  105123. /**
  105124. * AKA Glossiness in other nomenclature.
  105125. */
  105126. protected _microSurface: number;
  105127. /**
  105128. * Specifies that the material will use the light map as a show map.
  105129. */
  105130. protected _useLightmapAsShadowmap: boolean;
  105131. /**
  105132. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105133. * makes the reflect vector face the model (under horizon).
  105134. */
  105135. protected _useHorizonOcclusion: boolean;
  105136. /**
  105137. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105138. * too much the area relying on ambient texture to define their ambient occlusion.
  105139. */
  105140. protected _useRadianceOcclusion: boolean;
  105141. /**
  105142. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105143. */
  105144. protected _useAlphaFromAlbedoTexture: boolean;
  105145. /**
  105146. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  105147. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105148. */
  105149. protected _useSpecularOverAlpha: boolean;
  105150. /**
  105151. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105152. */
  105153. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105154. /**
  105155. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105156. */
  105157. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  105158. /**
  105159. * Specifies if the metallic texture contains the roughness information in its green channel.
  105160. */
  105161. protected _useRoughnessFromMetallicTextureGreen: boolean;
  105162. /**
  105163. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105164. */
  105165. protected _useMetallnessFromMetallicTextureBlue: boolean;
  105166. /**
  105167. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105168. */
  105169. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  105170. /**
  105171. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105172. */
  105173. protected _useAmbientInGrayScale: boolean;
  105174. /**
  105175. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105176. * The material will try to infer what glossiness each pixel should be.
  105177. */
  105178. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  105179. /**
  105180. * Defines the falloff type used in this material.
  105181. * It by default is Physical.
  105182. */
  105183. protected _lightFalloff: number;
  105184. /**
  105185. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105186. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105187. */
  105188. protected _useRadianceOverAlpha: boolean;
  105189. /**
  105190. * Allows using an object space normal map (instead of tangent space).
  105191. */
  105192. protected _useObjectSpaceNormalMap: boolean;
  105193. /**
  105194. * Allows using the bump map in parallax mode.
  105195. */
  105196. protected _useParallax: boolean;
  105197. /**
  105198. * Allows using the bump map in parallax occlusion mode.
  105199. */
  105200. protected _useParallaxOcclusion: boolean;
  105201. /**
  105202. * Controls the scale bias of the parallax mode.
  105203. */
  105204. protected _parallaxScaleBias: number;
  105205. /**
  105206. * If sets to true, disables all the lights affecting the material.
  105207. */
  105208. protected _disableLighting: boolean;
  105209. /**
  105210. * Number of Simultaneous lights allowed on the material.
  105211. */
  105212. protected _maxSimultaneousLights: number;
  105213. /**
  105214. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105215. */
  105216. protected _invertNormalMapX: boolean;
  105217. /**
  105218. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105219. */
  105220. protected _invertNormalMapY: boolean;
  105221. /**
  105222. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105223. */
  105224. protected _twoSidedLighting: boolean;
  105225. /**
  105226. * Defines the alpha limits in alpha test mode.
  105227. */
  105228. protected _alphaCutOff: number;
  105229. /**
  105230. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105231. */
  105232. protected _forceAlphaTest: boolean;
  105233. /**
  105234. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105235. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105236. */
  105237. protected _useAlphaFresnel: boolean;
  105238. /**
  105239. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105240. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105241. */
  105242. protected _useLinearAlphaFresnel: boolean;
  105243. /**
  105244. * The transparency mode of the material.
  105245. */
  105246. protected _transparencyMode: Nullable<number>;
  105247. /**
  105248. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  105249. * from cos thetav and roughness:
  105250. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  105251. */
  105252. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  105253. /**
  105254. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105255. */
  105256. protected _forceIrradianceInFragment: boolean;
  105257. /**
  105258. * Force normal to face away from face.
  105259. */
  105260. protected _forceNormalForward: boolean;
  105261. /**
  105262. * Enables specular anti aliasing in the PBR shader.
  105263. * It will both interacts on the Geometry for analytical and IBL lighting.
  105264. * It also prefilter the roughness map based on the bump values.
  105265. */
  105266. protected _enableSpecularAntiAliasing: boolean;
  105267. /**
  105268. * Default configuration related to image processing available in the PBR Material.
  105269. */
  105270. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105271. /**
  105272. * Keep track of the image processing observer to allow dispose and replace.
  105273. */
  105274. private _imageProcessingObserver;
  105275. /**
  105276. * Attaches a new image processing configuration to the PBR Material.
  105277. * @param configuration
  105278. */
  105279. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105280. /**
  105281. * Stores the available render targets.
  105282. */
  105283. private _renderTargets;
  105284. /**
  105285. * Sets the global ambient color for the material used in lighting calculations.
  105286. */
  105287. private _globalAmbientColor;
  105288. /**
  105289. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  105290. */
  105291. private _useLogarithmicDepth;
  105292. /**
  105293. * If set to true, no lighting calculations will be applied.
  105294. */
  105295. private _unlit;
  105296. private _debugMode;
  105297. /**
  105298. * @hidden
  105299. * This is reserved for the inspector.
  105300. * Defines the material debug mode.
  105301. * It helps seeing only some components of the material while troubleshooting.
  105302. */
  105303. debugMode: number;
  105304. /**
  105305. * @hidden
  105306. * This is reserved for the inspector.
  105307. * Specify from where on screen the debug mode should start.
  105308. * The value goes from -1 (full screen) to 1 (not visible)
  105309. * It helps with side by side comparison against the final render
  105310. * This defaults to -1
  105311. */
  105312. private debugLimit;
  105313. /**
  105314. * @hidden
  105315. * This is reserved for the inspector.
  105316. * As the default viewing range might not be enough (if the ambient is really small for instance)
  105317. * You can use the factor to better multiply the final value.
  105318. */
  105319. private debugFactor;
  105320. /**
  105321. * Defines the clear coat layer parameters for the material.
  105322. */
  105323. readonly clearCoat: PBRClearCoatConfiguration;
  105324. /**
  105325. * Defines the anisotropic parameters for the material.
  105326. */
  105327. readonly anisotropy: PBRAnisotropicConfiguration;
  105328. /**
  105329. * Defines the BRDF parameters for the material.
  105330. */
  105331. readonly brdf: PBRBRDFConfiguration;
  105332. /**
  105333. * Defines the Sheen parameters for the material.
  105334. */
  105335. readonly sheen: PBRSheenConfiguration;
  105336. /**
  105337. * Defines the SubSurface parameters for the material.
  105338. */
  105339. readonly subSurface: PBRSubSurfaceConfiguration;
  105340. /**
  105341. * Custom callback helping to override the default shader used in the material.
  105342. */
  105343. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  105344. /**
  105345. * Instantiates a new PBRMaterial instance.
  105346. *
  105347. * @param name The material name
  105348. * @param scene The scene the material will be use in.
  105349. */
  105350. constructor(name: string, scene: Scene);
  105351. /**
  105352. * Gets a boolean indicating that current material needs to register RTT
  105353. */
  105354. readonly hasRenderTargetTextures: boolean;
  105355. /**
  105356. * Gets the name of the material class.
  105357. */
  105358. getClassName(): string;
  105359. /**
  105360. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105361. */
  105362. /**
  105363. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105364. */
  105365. useLogarithmicDepth: boolean;
  105366. /**
  105367. * Gets the current transparency mode.
  105368. */
  105369. /**
  105370. * Sets the transparency mode of the material.
  105371. *
  105372. * | Value | Type | Description |
  105373. * | ----- | ----------------------------------- | ----------- |
  105374. * | 0 | OPAQUE | |
  105375. * | 1 | ALPHATEST | |
  105376. * | 2 | ALPHABLEND | |
  105377. * | 3 | ALPHATESTANDBLEND | |
  105378. *
  105379. */
  105380. transparencyMode: Nullable<number>;
  105381. /**
  105382. * Returns true if alpha blending should be disabled.
  105383. */
  105384. private readonly _disableAlphaBlending;
  105385. /**
  105386. * Specifies whether or not this material should be rendered in alpha blend mode.
  105387. */
  105388. needAlphaBlending(): boolean;
  105389. /**
  105390. * Specifies if the mesh will require alpha blending.
  105391. * @param mesh - BJS mesh.
  105392. */
  105393. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105394. /**
  105395. * Specifies whether or not this material should be rendered in alpha test mode.
  105396. */
  105397. needAlphaTesting(): boolean;
  105398. /**
  105399. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  105400. */
  105401. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  105402. /**
  105403. * Gets the texture used for the alpha test.
  105404. */
  105405. getAlphaTestTexture(): Nullable<BaseTexture>;
  105406. /**
  105407. * Specifies that the submesh is ready to be used.
  105408. * @param mesh - BJS mesh.
  105409. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  105410. * @param useInstances - Specifies that instances should be used.
  105411. * @returns - boolean indicating that the submesh is ready or not.
  105412. */
  105413. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105414. /**
  105415. * Specifies if the material uses metallic roughness workflow.
  105416. * @returns boolean specifiying if the material uses metallic roughness workflow.
  105417. */
  105418. isMetallicWorkflow(): boolean;
  105419. private _prepareEffect;
  105420. private _prepareDefines;
  105421. /**
  105422. * Force shader compilation
  105423. */
  105424. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  105425. clipPlane: boolean;
  105426. }>): void;
  105427. /**
  105428. * Initializes the uniform buffer layout for the shader.
  105429. */
  105430. buildUniformLayout(): void;
  105431. /**
  105432. * Unbinds the material from the mesh
  105433. */
  105434. unbind(): void;
  105435. /**
  105436. * Binds the submesh data.
  105437. * @param world - The world matrix.
  105438. * @param mesh - The BJS mesh.
  105439. * @param subMesh - A submesh of the BJS mesh.
  105440. */
  105441. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105442. /**
  105443. * Returns the animatable textures.
  105444. * @returns - Array of animatable textures.
  105445. */
  105446. getAnimatables(): IAnimatable[];
  105447. /**
  105448. * Returns the texture used for reflections.
  105449. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  105450. */
  105451. private _getReflectionTexture;
  105452. /**
  105453. * Returns an array of the actively used textures.
  105454. * @returns - Array of BaseTextures
  105455. */
  105456. getActiveTextures(): BaseTexture[];
  105457. /**
  105458. * Checks to see if a texture is used in the material.
  105459. * @param texture - Base texture to use.
  105460. * @returns - Boolean specifying if a texture is used in the material.
  105461. */
  105462. hasTexture(texture: BaseTexture): boolean;
  105463. /**
  105464. * Disposes the resources of the material.
  105465. * @param forceDisposeEffect - Forces the disposal of effects.
  105466. * @param forceDisposeTextures - Forces the disposal of all textures.
  105467. */
  105468. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105469. }
  105470. }
  105471. declare module BABYLON {
  105472. /**
  105473. * The Physically based material of BJS.
  105474. *
  105475. * This offers the main features of a standard PBR material.
  105476. * For more information, please refer to the documentation :
  105477. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105478. */
  105479. export class PBRMaterial extends PBRBaseMaterial {
  105480. /**
  105481. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105482. */
  105483. static readonly PBRMATERIAL_OPAQUE: number;
  105484. /**
  105485. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105486. */
  105487. static readonly PBRMATERIAL_ALPHATEST: number;
  105488. /**
  105489. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105490. */
  105491. static readonly PBRMATERIAL_ALPHABLEND: number;
  105492. /**
  105493. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105494. * They are also discarded below the alpha cutoff threshold to improve performances.
  105495. */
  105496. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105497. /**
  105498. * Defines the default value of how much AO map is occluding the analytical lights
  105499. * (point spot...).
  105500. */
  105501. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105502. /**
  105503. * Intensity of the direct lights e.g. the four lights available in your scene.
  105504. * This impacts both the direct diffuse and specular highlights.
  105505. */
  105506. directIntensity: number;
  105507. /**
  105508. * Intensity of the emissive part of the material.
  105509. * This helps controlling the emissive effect without modifying the emissive color.
  105510. */
  105511. emissiveIntensity: number;
  105512. /**
  105513. * Intensity of the environment e.g. how much the environment will light the object
  105514. * either through harmonics for rough material or through the refelction for shiny ones.
  105515. */
  105516. environmentIntensity: number;
  105517. /**
  105518. * This is a special control allowing the reduction of the specular highlights coming from the
  105519. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105520. */
  105521. specularIntensity: number;
  105522. /**
  105523. * Debug Control allowing disabling the bump map on this material.
  105524. */
  105525. disableBumpMap: boolean;
  105526. /**
  105527. * AKA Diffuse Texture in standard nomenclature.
  105528. */
  105529. albedoTexture: BaseTexture;
  105530. /**
  105531. * AKA Occlusion Texture in other nomenclature.
  105532. */
  105533. ambientTexture: BaseTexture;
  105534. /**
  105535. * AKA Occlusion Texture Intensity in other nomenclature.
  105536. */
  105537. ambientTextureStrength: number;
  105538. /**
  105539. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105540. * 1 means it completely occludes it
  105541. * 0 mean it has no impact
  105542. */
  105543. ambientTextureImpactOnAnalyticalLights: number;
  105544. /**
  105545. * Stores the alpha values in a texture.
  105546. */
  105547. opacityTexture: BaseTexture;
  105548. /**
  105549. * Stores the reflection values in a texture.
  105550. */
  105551. reflectionTexture: Nullable<BaseTexture>;
  105552. /**
  105553. * Stores the emissive values in a texture.
  105554. */
  105555. emissiveTexture: BaseTexture;
  105556. /**
  105557. * AKA Specular texture in other nomenclature.
  105558. */
  105559. reflectivityTexture: BaseTexture;
  105560. /**
  105561. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105562. */
  105563. metallicTexture: BaseTexture;
  105564. /**
  105565. * Specifies the metallic scalar of the metallic/roughness workflow.
  105566. * Can also be used to scale the metalness values of the metallic texture.
  105567. */
  105568. metallic: Nullable<number>;
  105569. /**
  105570. * Specifies the roughness scalar of the metallic/roughness workflow.
  105571. * Can also be used to scale the roughness values of the metallic texture.
  105572. */
  105573. roughness: Nullable<number>;
  105574. /**
  105575. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105576. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105577. */
  105578. microSurfaceTexture: BaseTexture;
  105579. /**
  105580. * Stores surface normal data used to displace a mesh in a texture.
  105581. */
  105582. bumpTexture: BaseTexture;
  105583. /**
  105584. * Stores the pre-calculated light information of a mesh in a texture.
  105585. */
  105586. lightmapTexture: BaseTexture;
  105587. /**
  105588. * Stores the refracted light information in a texture.
  105589. */
  105590. refractionTexture: Nullable<BaseTexture>;
  105591. /**
  105592. * The color of a material in ambient lighting.
  105593. */
  105594. ambientColor: Color3;
  105595. /**
  105596. * AKA Diffuse Color in other nomenclature.
  105597. */
  105598. albedoColor: Color3;
  105599. /**
  105600. * AKA Specular Color in other nomenclature.
  105601. */
  105602. reflectivityColor: Color3;
  105603. /**
  105604. * The color reflected from the material.
  105605. */
  105606. reflectionColor: Color3;
  105607. /**
  105608. * The color emitted from the material.
  105609. */
  105610. emissiveColor: Color3;
  105611. /**
  105612. * AKA Glossiness in other nomenclature.
  105613. */
  105614. microSurface: number;
  105615. /**
  105616. * source material index of refraction (IOR)' / 'destination material IOR.
  105617. */
  105618. indexOfRefraction: number;
  105619. /**
  105620. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105621. */
  105622. invertRefractionY: boolean;
  105623. /**
  105624. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105625. * Materials half opaque for instance using refraction could benefit from this control.
  105626. */
  105627. linkRefractionWithTransparency: boolean;
  105628. /**
  105629. * If true, the light map contains occlusion information instead of lighting info.
  105630. */
  105631. useLightmapAsShadowmap: boolean;
  105632. /**
  105633. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105634. */
  105635. useAlphaFromAlbedoTexture: boolean;
  105636. /**
  105637. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105638. */
  105639. forceAlphaTest: boolean;
  105640. /**
  105641. * Defines the alpha limits in alpha test mode.
  105642. */
  105643. alphaCutOff: number;
  105644. /**
  105645. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105646. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105647. */
  105648. useSpecularOverAlpha: boolean;
  105649. /**
  105650. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105651. */
  105652. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105653. /**
  105654. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105655. */
  105656. useRoughnessFromMetallicTextureAlpha: boolean;
  105657. /**
  105658. * Specifies if the metallic texture contains the roughness information in its green channel.
  105659. */
  105660. useRoughnessFromMetallicTextureGreen: boolean;
  105661. /**
  105662. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105663. */
  105664. useMetallnessFromMetallicTextureBlue: boolean;
  105665. /**
  105666. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105667. */
  105668. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105669. /**
  105670. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105671. */
  105672. useAmbientInGrayScale: boolean;
  105673. /**
  105674. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105675. * The material will try to infer what glossiness each pixel should be.
  105676. */
  105677. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105678. /**
  105679. * BJS is using an harcoded light falloff based on a manually sets up range.
  105680. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105681. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105682. */
  105683. /**
  105684. * BJS is using an harcoded light falloff based on a manually sets up range.
  105685. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105686. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105687. */
  105688. usePhysicalLightFalloff: boolean;
  105689. /**
  105690. * In order to support the falloff compatibility with gltf, a special mode has been added
  105691. * to reproduce the gltf light falloff.
  105692. */
  105693. /**
  105694. * In order to support the falloff compatibility with gltf, a special mode has been added
  105695. * to reproduce the gltf light falloff.
  105696. */
  105697. useGLTFLightFalloff: boolean;
  105698. /**
  105699. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105700. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105701. */
  105702. useRadianceOverAlpha: boolean;
  105703. /**
  105704. * Allows using an object space normal map (instead of tangent space).
  105705. */
  105706. useObjectSpaceNormalMap: boolean;
  105707. /**
  105708. * Allows using the bump map in parallax mode.
  105709. */
  105710. useParallax: boolean;
  105711. /**
  105712. * Allows using the bump map in parallax occlusion mode.
  105713. */
  105714. useParallaxOcclusion: boolean;
  105715. /**
  105716. * Controls the scale bias of the parallax mode.
  105717. */
  105718. parallaxScaleBias: number;
  105719. /**
  105720. * If sets to true, disables all the lights affecting the material.
  105721. */
  105722. disableLighting: boolean;
  105723. /**
  105724. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105725. */
  105726. forceIrradianceInFragment: boolean;
  105727. /**
  105728. * Number of Simultaneous lights allowed on the material.
  105729. */
  105730. maxSimultaneousLights: number;
  105731. /**
  105732. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105733. */
  105734. invertNormalMapX: boolean;
  105735. /**
  105736. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105737. */
  105738. invertNormalMapY: boolean;
  105739. /**
  105740. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105741. */
  105742. twoSidedLighting: boolean;
  105743. /**
  105744. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105745. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105746. */
  105747. useAlphaFresnel: boolean;
  105748. /**
  105749. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105750. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105751. */
  105752. useLinearAlphaFresnel: boolean;
  105753. /**
  105754. * Let user defines the brdf lookup texture used for IBL.
  105755. * A default 8bit version is embedded but you could point at :
  105756. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105757. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105758. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105759. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105760. */
  105761. environmentBRDFTexture: Nullable<BaseTexture>;
  105762. /**
  105763. * Force normal to face away from face.
  105764. */
  105765. forceNormalForward: boolean;
  105766. /**
  105767. * Enables specular anti aliasing in the PBR shader.
  105768. * It will both interacts on the Geometry for analytical and IBL lighting.
  105769. * It also prefilter the roughness map based on the bump values.
  105770. */
  105771. enableSpecularAntiAliasing: boolean;
  105772. /**
  105773. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105774. * makes the reflect vector face the model (under horizon).
  105775. */
  105776. useHorizonOcclusion: boolean;
  105777. /**
  105778. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105779. * too much the area relying on ambient texture to define their ambient occlusion.
  105780. */
  105781. useRadianceOcclusion: boolean;
  105782. /**
  105783. * If set to true, no lighting calculations will be applied.
  105784. */
  105785. unlit: boolean;
  105786. /**
  105787. * Gets the image processing configuration used either in this material.
  105788. */
  105789. /**
  105790. * Sets the Default image processing configuration used either in the this material.
  105791. *
  105792. * If sets to null, the scene one is in use.
  105793. */
  105794. imageProcessingConfiguration: ImageProcessingConfiguration;
  105795. /**
  105796. * Gets wether the color curves effect is enabled.
  105797. */
  105798. /**
  105799. * Sets wether the color curves effect is enabled.
  105800. */
  105801. cameraColorCurvesEnabled: boolean;
  105802. /**
  105803. * Gets wether the color grading effect is enabled.
  105804. */
  105805. /**
  105806. * Gets wether the color grading effect is enabled.
  105807. */
  105808. cameraColorGradingEnabled: boolean;
  105809. /**
  105810. * Gets wether tonemapping is enabled or not.
  105811. */
  105812. /**
  105813. * Sets wether tonemapping is enabled or not
  105814. */
  105815. cameraToneMappingEnabled: boolean;
  105816. /**
  105817. * The camera exposure used on this material.
  105818. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105819. * This corresponds to a photographic exposure.
  105820. */
  105821. /**
  105822. * The camera exposure used on this material.
  105823. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105824. * This corresponds to a photographic exposure.
  105825. */
  105826. cameraExposure: number;
  105827. /**
  105828. * Gets The camera contrast used on this material.
  105829. */
  105830. /**
  105831. * Sets The camera contrast used on this material.
  105832. */
  105833. cameraContrast: number;
  105834. /**
  105835. * Gets the Color Grading 2D Lookup Texture.
  105836. */
  105837. /**
  105838. * Sets the Color Grading 2D Lookup Texture.
  105839. */
  105840. cameraColorGradingTexture: Nullable<BaseTexture>;
  105841. /**
  105842. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105843. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105844. * 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;
  105845. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105846. */
  105847. /**
  105848. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105849. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105850. * 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;
  105851. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105852. */
  105853. cameraColorCurves: Nullable<ColorCurves>;
  105854. /**
  105855. * Instantiates a new PBRMaterial instance.
  105856. *
  105857. * @param name The material name
  105858. * @param scene The scene the material will be use in.
  105859. */
  105860. constructor(name: string, scene: Scene);
  105861. /**
  105862. * Returns the name of this material class.
  105863. */
  105864. getClassName(): string;
  105865. /**
  105866. * Makes a duplicate of the current material.
  105867. * @param name - name to use for the new material.
  105868. */
  105869. clone(name: string): PBRMaterial;
  105870. /**
  105871. * Serializes this PBR Material.
  105872. * @returns - An object with the serialized material.
  105873. */
  105874. serialize(): any;
  105875. /**
  105876. * Parses a PBR Material from a serialized object.
  105877. * @param source - Serialized object.
  105878. * @param scene - BJS scene instance.
  105879. * @param rootUrl - url for the scene object
  105880. * @returns - PBRMaterial
  105881. */
  105882. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105883. }
  105884. }
  105885. declare module BABYLON {
  105886. /**
  105887. * Direct draw surface info
  105888. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105889. */
  105890. export interface DDSInfo {
  105891. /**
  105892. * Width of the texture
  105893. */
  105894. width: number;
  105895. /**
  105896. * Width of the texture
  105897. */
  105898. height: number;
  105899. /**
  105900. * Number of Mipmaps for the texture
  105901. * @see https://en.wikipedia.org/wiki/Mipmap
  105902. */
  105903. mipmapCount: number;
  105904. /**
  105905. * If the textures format is a known fourCC format
  105906. * @see https://www.fourcc.org/
  105907. */
  105908. isFourCC: boolean;
  105909. /**
  105910. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105911. */
  105912. isRGB: boolean;
  105913. /**
  105914. * If the texture is a lumincance format
  105915. */
  105916. isLuminance: boolean;
  105917. /**
  105918. * If this is a cube texture
  105919. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105920. */
  105921. isCube: boolean;
  105922. /**
  105923. * If the texture is a compressed format eg. FOURCC_DXT1
  105924. */
  105925. isCompressed: boolean;
  105926. /**
  105927. * The dxgiFormat of the texture
  105928. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105929. */
  105930. dxgiFormat: number;
  105931. /**
  105932. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105933. */
  105934. textureType: number;
  105935. /**
  105936. * Sphericle polynomial created for the dds texture
  105937. */
  105938. sphericalPolynomial?: SphericalPolynomial;
  105939. }
  105940. /**
  105941. * Class used to provide DDS decompression tools
  105942. */
  105943. export class DDSTools {
  105944. /**
  105945. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105946. */
  105947. static StoreLODInAlphaChannel: boolean;
  105948. /**
  105949. * Gets DDS information from an array buffer
  105950. * @param arrayBuffer defines the array buffer to read data from
  105951. * @returns the DDS information
  105952. */
  105953. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105954. private static _FloatView;
  105955. private static _Int32View;
  105956. private static _ToHalfFloat;
  105957. private static _FromHalfFloat;
  105958. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105959. private static _GetHalfFloatRGBAArrayBuffer;
  105960. private static _GetFloatRGBAArrayBuffer;
  105961. private static _GetFloatAsUIntRGBAArrayBuffer;
  105962. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105963. private static _GetRGBAArrayBuffer;
  105964. private static _ExtractLongWordOrder;
  105965. private static _GetRGBArrayBuffer;
  105966. private static _GetLuminanceArrayBuffer;
  105967. /**
  105968. * Uploads DDS Levels to a Babylon Texture
  105969. * @hidden
  105970. */
  105971. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105972. }
  105973. interface Engine {
  105974. /**
  105975. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105976. * @param rootUrl defines the url where the file to load is located
  105977. * @param scene defines the current scene
  105978. * @param lodScale defines scale to apply to the mip map selection
  105979. * @param lodOffset defines offset to apply to the mip map selection
  105980. * @param onLoad defines an optional callback raised when the texture is loaded
  105981. * @param onError defines an optional callback raised if there is an issue to load the texture
  105982. * @param format defines the format of the data
  105983. * @param forcedExtension defines the extension to use to pick the right loader
  105984. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105985. * @returns the cube texture as an InternalTexture
  105986. */
  105987. 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;
  105988. }
  105989. }
  105990. declare module BABYLON {
  105991. /**
  105992. * Implementation of the DDS Texture Loader.
  105993. * @hidden
  105994. */
  105995. export class _DDSTextureLoader implements IInternalTextureLoader {
  105996. /**
  105997. * Defines wether the loader supports cascade loading the different faces.
  105998. */
  105999. readonly supportCascades: boolean;
  106000. /**
  106001. * This returns if the loader support the current file information.
  106002. * @param extension defines the file extension of the file being loaded
  106003. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106004. * @param fallback defines the fallback internal texture if any
  106005. * @param isBase64 defines whether the texture is encoded as a base64
  106006. * @param isBuffer defines whether the texture data are stored as a buffer
  106007. * @returns true if the loader can load the specified file
  106008. */
  106009. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106010. /**
  106011. * Transform the url before loading if required.
  106012. * @param rootUrl the url of the texture
  106013. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106014. * @returns the transformed texture
  106015. */
  106016. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106017. /**
  106018. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106019. * @param rootUrl the url of the texture
  106020. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106021. * @returns the fallback texture
  106022. */
  106023. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106024. /**
  106025. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106026. * @param data contains the texture data
  106027. * @param texture defines the BabylonJS internal texture
  106028. * @param createPolynomials will be true if polynomials have been requested
  106029. * @param onLoad defines the callback to trigger once the texture is ready
  106030. * @param onError defines the callback to trigger in case of error
  106031. */
  106032. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106033. /**
  106034. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106035. * @param data contains the texture data
  106036. * @param texture defines the BabylonJS internal texture
  106037. * @param callback defines the method to call once ready to upload
  106038. */
  106039. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106040. }
  106041. }
  106042. declare module BABYLON {
  106043. /** @hidden */
  106044. export var rgbdEncodePixelShader: {
  106045. name: string;
  106046. shader: string;
  106047. };
  106048. }
  106049. declare module BABYLON {
  106050. /**
  106051. * Raw texture data and descriptor sufficient for WebGL texture upload
  106052. */
  106053. export interface EnvironmentTextureInfo {
  106054. /**
  106055. * Version of the environment map
  106056. */
  106057. version: number;
  106058. /**
  106059. * Width of image
  106060. */
  106061. width: number;
  106062. /**
  106063. * Irradiance information stored in the file.
  106064. */
  106065. irradiance: any;
  106066. /**
  106067. * Specular information stored in the file.
  106068. */
  106069. specular: any;
  106070. }
  106071. /**
  106072. * Sets of helpers addressing the serialization and deserialization of environment texture
  106073. * stored in a BabylonJS env file.
  106074. * Those files are usually stored as .env files.
  106075. */
  106076. export class EnvironmentTextureTools {
  106077. /**
  106078. * Magic number identifying the env file.
  106079. */
  106080. private static _MagicBytes;
  106081. /**
  106082. * Gets the environment info from an env file.
  106083. * @param data The array buffer containing the .env bytes.
  106084. * @returns the environment file info (the json header) if successfully parsed.
  106085. */
  106086. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  106087. /**
  106088. * Creates an environment texture from a loaded cube texture.
  106089. * @param texture defines the cube texture to convert in env file
  106090. * @return a promise containing the environment data if succesfull.
  106091. */
  106092. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  106093. /**
  106094. * Creates a JSON representation of the spherical data.
  106095. * @param texture defines the texture containing the polynomials
  106096. * @return the JSON representation of the spherical info
  106097. */
  106098. private static _CreateEnvTextureIrradiance;
  106099. /**
  106100. * Uploads the texture info contained in the env file to the GPU.
  106101. * @param texture defines the internal texture to upload to
  106102. * @param arrayBuffer defines the buffer cotaining the data to load
  106103. * @param info defines the texture info retrieved through the GetEnvInfo method
  106104. * @returns a promise
  106105. */
  106106. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  106107. /**
  106108. * Uploads the levels of image data to the GPU.
  106109. * @param texture defines the internal texture to upload to
  106110. * @param imageData defines the array buffer views of image data [mipmap][face]
  106111. * @returns a promise
  106112. */
  106113. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  106114. /**
  106115. * Uploads spherical polynomials information to the texture.
  106116. * @param texture defines the texture we are trying to upload the information to
  106117. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  106118. */
  106119. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  106120. /** @hidden */
  106121. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106122. }
  106123. }
  106124. declare module BABYLON {
  106125. /**
  106126. * Implementation of the ENV Texture Loader.
  106127. * @hidden
  106128. */
  106129. export class _ENVTextureLoader implements IInternalTextureLoader {
  106130. /**
  106131. * Defines wether the loader supports cascade loading the different faces.
  106132. */
  106133. readonly supportCascades: boolean;
  106134. /**
  106135. * This returns if the loader support the current file information.
  106136. * @param extension defines the file extension of the file being loaded
  106137. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106138. * @param fallback defines the fallback internal texture if any
  106139. * @param isBase64 defines whether the texture is encoded as a base64
  106140. * @param isBuffer defines whether the texture data are stored as a buffer
  106141. * @returns true if the loader can load the specified file
  106142. */
  106143. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106144. /**
  106145. * Transform the url before loading if required.
  106146. * @param rootUrl the url of the texture
  106147. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106148. * @returns the transformed texture
  106149. */
  106150. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106151. /**
  106152. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106153. * @param rootUrl the url of the texture
  106154. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106155. * @returns the fallback texture
  106156. */
  106157. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106158. /**
  106159. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106160. * @param data contains the texture data
  106161. * @param texture defines the BabylonJS internal texture
  106162. * @param createPolynomials will be true if polynomials have been requested
  106163. * @param onLoad defines the callback to trigger once the texture is ready
  106164. * @param onError defines the callback to trigger in case of error
  106165. */
  106166. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106167. /**
  106168. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106169. * @param data contains the texture data
  106170. * @param texture defines the BabylonJS internal texture
  106171. * @param callback defines the method to call once ready to upload
  106172. */
  106173. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106174. }
  106175. }
  106176. declare module BABYLON {
  106177. /**
  106178. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106179. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106180. */
  106181. export class KhronosTextureContainer {
  106182. /** contents of the KTX container file */
  106183. arrayBuffer: any;
  106184. private static HEADER_LEN;
  106185. private static COMPRESSED_2D;
  106186. private static COMPRESSED_3D;
  106187. private static TEX_2D;
  106188. private static TEX_3D;
  106189. /**
  106190. * Gets the openGL type
  106191. */
  106192. glType: number;
  106193. /**
  106194. * Gets the openGL type size
  106195. */
  106196. glTypeSize: number;
  106197. /**
  106198. * Gets the openGL format
  106199. */
  106200. glFormat: number;
  106201. /**
  106202. * Gets the openGL internal format
  106203. */
  106204. glInternalFormat: number;
  106205. /**
  106206. * Gets the base internal format
  106207. */
  106208. glBaseInternalFormat: number;
  106209. /**
  106210. * Gets image width in pixel
  106211. */
  106212. pixelWidth: number;
  106213. /**
  106214. * Gets image height in pixel
  106215. */
  106216. pixelHeight: number;
  106217. /**
  106218. * Gets image depth in pixels
  106219. */
  106220. pixelDepth: number;
  106221. /**
  106222. * Gets the number of array elements
  106223. */
  106224. numberOfArrayElements: number;
  106225. /**
  106226. * Gets the number of faces
  106227. */
  106228. numberOfFaces: number;
  106229. /**
  106230. * Gets the number of mipmap levels
  106231. */
  106232. numberOfMipmapLevels: number;
  106233. /**
  106234. * Gets the bytes of key value data
  106235. */
  106236. bytesOfKeyValueData: number;
  106237. /**
  106238. * Gets the load type
  106239. */
  106240. loadType: number;
  106241. /**
  106242. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  106243. */
  106244. isInvalid: boolean;
  106245. /**
  106246. * Creates a new KhronosTextureContainer
  106247. * @param arrayBuffer contents of the KTX container file
  106248. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  106249. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  106250. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  106251. */
  106252. constructor(
  106253. /** contents of the KTX container file */
  106254. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  106255. /**
  106256. * Uploads KTX content to a Babylon Texture.
  106257. * It is assumed that the texture has already been created & is currently bound
  106258. * @hidden
  106259. */
  106260. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  106261. private _upload2DCompressedLevels;
  106262. }
  106263. }
  106264. declare module BABYLON {
  106265. /**
  106266. * Implementation of the KTX Texture Loader.
  106267. * @hidden
  106268. */
  106269. export class _KTXTextureLoader implements IInternalTextureLoader {
  106270. /**
  106271. * Defines wether the loader supports cascade loading the different faces.
  106272. */
  106273. readonly supportCascades: boolean;
  106274. /**
  106275. * This returns if the loader support the current file information.
  106276. * @param extension defines the file extension of the file being loaded
  106277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106278. * @param fallback defines the fallback internal texture if any
  106279. * @param isBase64 defines whether the texture is encoded as a base64
  106280. * @param isBuffer defines whether the texture data are stored as a buffer
  106281. * @returns true if the loader can load the specified file
  106282. */
  106283. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106284. /**
  106285. * Transform the url before loading if required.
  106286. * @param rootUrl the url of the texture
  106287. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106288. * @returns the transformed texture
  106289. */
  106290. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106291. /**
  106292. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106293. * @param rootUrl the url of the texture
  106294. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106295. * @returns the fallback texture
  106296. */
  106297. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106298. /**
  106299. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106300. * @param data contains the texture data
  106301. * @param texture defines the BabylonJS internal texture
  106302. * @param createPolynomials will be true if polynomials have been requested
  106303. * @param onLoad defines the callback to trigger once the texture is ready
  106304. * @param onError defines the callback to trigger in case of error
  106305. */
  106306. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106307. /**
  106308. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106309. * @param data contains the texture data
  106310. * @param texture defines the BabylonJS internal texture
  106311. * @param callback defines the method to call once ready to upload
  106312. */
  106313. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  106314. }
  106315. }
  106316. declare module BABYLON {
  106317. /** @hidden */
  106318. export var _forceSceneHelpersToBundle: boolean;
  106319. interface Scene {
  106320. /**
  106321. * Creates a default light for the scene.
  106322. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  106323. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  106324. */
  106325. createDefaultLight(replace?: boolean): void;
  106326. /**
  106327. * Creates a default camera for the scene.
  106328. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  106329. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106330. * @param replace has default false, when true replaces the active camera in the scene
  106331. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  106332. */
  106333. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106334. /**
  106335. * Creates a default camera and a default light.
  106336. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  106337. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106338. * @param replace has the default false, when true replaces the active camera/light in the scene
  106339. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  106340. */
  106341. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106342. /**
  106343. * Creates a new sky box
  106344. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  106345. * @param environmentTexture defines the texture to use as environment texture
  106346. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  106347. * @param scale defines the overall scale of the skybox
  106348. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  106349. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  106350. * @returns a new mesh holding the sky box
  106351. */
  106352. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  106353. /**
  106354. * Creates a new environment
  106355. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  106356. * @param options defines the options you can use to configure the environment
  106357. * @returns the new EnvironmentHelper
  106358. */
  106359. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  106360. /**
  106361. * Creates a new VREXperienceHelper
  106362. * @see http://doc.babylonjs.com/how_to/webvr_helper
  106363. * @param webVROptions defines the options used to create the new VREXperienceHelper
  106364. * @returns a new VREXperienceHelper
  106365. */
  106366. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  106367. /**
  106368. * Creates a new XREXperienceHelper
  106369. * @see http://doc.babylonjs.com/how_to/webxr
  106370. * @returns a promise for a new XREXperienceHelper
  106371. */
  106372. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  106373. }
  106374. }
  106375. declare module BABYLON {
  106376. /**
  106377. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  106378. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  106379. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  106380. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106381. */
  106382. export class VideoDome extends TransformNode {
  106383. /**
  106384. * Define the video source as a Monoscopic panoramic 360 video.
  106385. */
  106386. static readonly MODE_MONOSCOPIC: number;
  106387. /**
  106388. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106389. */
  106390. static readonly MODE_TOPBOTTOM: number;
  106391. /**
  106392. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106393. */
  106394. static readonly MODE_SIDEBYSIDE: number;
  106395. private _useDirectMapping;
  106396. /**
  106397. * The video texture being displayed on the sphere
  106398. */
  106399. protected _videoTexture: VideoTexture;
  106400. /**
  106401. * Gets the video texture being displayed on the sphere
  106402. */
  106403. readonly videoTexture: VideoTexture;
  106404. /**
  106405. * The skybox material
  106406. */
  106407. protected _material: BackgroundMaterial;
  106408. /**
  106409. * The surface used for the skybox
  106410. */
  106411. protected _mesh: Mesh;
  106412. /**
  106413. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106414. * Also see the options.resolution property.
  106415. */
  106416. fovMultiplier: number;
  106417. private _videoMode;
  106418. /**
  106419. * Gets or set the current video mode for the video. It can be:
  106420. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  106421. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106422. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106423. */
  106424. videoMode: number;
  106425. /**
  106426. * Oberserver used in Stereoscopic VR Mode.
  106427. */
  106428. private _onBeforeCameraRenderObserver;
  106429. /**
  106430. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  106431. * @param name Element's name, child elements will append suffixes for their own names.
  106432. * @param urlsOrVideo defines the url(s) or the video element to use
  106433. * @param options An object containing optional or exposed sub element properties
  106434. */
  106435. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  106436. resolution?: number;
  106437. clickToPlay?: boolean;
  106438. autoPlay?: boolean;
  106439. loop?: boolean;
  106440. size?: number;
  106441. poster?: string;
  106442. faceForward?: boolean;
  106443. useDirectMapping?: boolean;
  106444. }, scene: Scene);
  106445. private _changeVideoMode;
  106446. /**
  106447. * Releases resources associated with this node.
  106448. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106449. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106450. */
  106451. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106452. }
  106453. }
  106454. declare module BABYLON {
  106455. /**
  106456. * This class can be used to get instrumentation data from a Babylon engine
  106457. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106458. */
  106459. export class EngineInstrumentation implements IDisposable {
  106460. /**
  106461. * Define the instrumented engine.
  106462. */
  106463. engine: Engine;
  106464. private _captureGPUFrameTime;
  106465. private _gpuFrameTimeToken;
  106466. private _gpuFrameTime;
  106467. private _captureShaderCompilationTime;
  106468. private _shaderCompilationTime;
  106469. private _onBeginFrameObserver;
  106470. private _onEndFrameObserver;
  106471. private _onBeforeShaderCompilationObserver;
  106472. private _onAfterShaderCompilationObserver;
  106473. /**
  106474. * Gets the perf counter used for GPU frame time
  106475. */
  106476. readonly gpuFrameTimeCounter: PerfCounter;
  106477. /**
  106478. * Gets the GPU frame time capture status
  106479. */
  106480. /**
  106481. * Enable or disable the GPU frame time capture
  106482. */
  106483. captureGPUFrameTime: boolean;
  106484. /**
  106485. * Gets the perf counter used for shader compilation time
  106486. */
  106487. readonly shaderCompilationTimeCounter: PerfCounter;
  106488. /**
  106489. * Gets the shader compilation time capture status
  106490. */
  106491. /**
  106492. * Enable or disable the shader compilation time capture
  106493. */
  106494. captureShaderCompilationTime: boolean;
  106495. /**
  106496. * Instantiates a new engine instrumentation.
  106497. * This class can be used to get instrumentation data from a Babylon engine
  106498. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106499. * @param engine Defines the engine to instrument
  106500. */
  106501. constructor(
  106502. /**
  106503. * Define the instrumented engine.
  106504. */
  106505. engine: Engine);
  106506. /**
  106507. * Dispose and release associated resources.
  106508. */
  106509. dispose(): void;
  106510. }
  106511. }
  106512. declare module BABYLON {
  106513. /**
  106514. * This class can be used to get instrumentation data from a Babylon engine
  106515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106516. */
  106517. export class SceneInstrumentation implements IDisposable {
  106518. /**
  106519. * Defines the scene to instrument
  106520. */
  106521. scene: Scene;
  106522. private _captureActiveMeshesEvaluationTime;
  106523. private _activeMeshesEvaluationTime;
  106524. private _captureRenderTargetsRenderTime;
  106525. private _renderTargetsRenderTime;
  106526. private _captureFrameTime;
  106527. private _frameTime;
  106528. private _captureRenderTime;
  106529. private _renderTime;
  106530. private _captureInterFrameTime;
  106531. private _interFrameTime;
  106532. private _captureParticlesRenderTime;
  106533. private _particlesRenderTime;
  106534. private _captureSpritesRenderTime;
  106535. private _spritesRenderTime;
  106536. private _capturePhysicsTime;
  106537. private _physicsTime;
  106538. private _captureAnimationsTime;
  106539. private _animationsTime;
  106540. private _captureCameraRenderTime;
  106541. private _cameraRenderTime;
  106542. private _onBeforeActiveMeshesEvaluationObserver;
  106543. private _onAfterActiveMeshesEvaluationObserver;
  106544. private _onBeforeRenderTargetsRenderObserver;
  106545. private _onAfterRenderTargetsRenderObserver;
  106546. private _onAfterRenderObserver;
  106547. private _onBeforeDrawPhaseObserver;
  106548. private _onAfterDrawPhaseObserver;
  106549. private _onBeforeAnimationsObserver;
  106550. private _onBeforeParticlesRenderingObserver;
  106551. private _onAfterParticlesRenderingObserver;
  106552. private _onBeforeSpritesRenderingObserver;
  106553. private _onAfterSpritesRenderingObserver;
  106554. private _onBeforePhysicsObserver;
  106555. private _onAfterPhysicsObserver;
  106556. private _onAfterAnimationsObserver;
  106557. private _onBeforeCameraRenderObserver;
  106558. private _onAfterCameraRenderObserver;
  106559. /**
  106560. * Gets the perf counter used for active meshes evaluation time
  106561. */
  106562. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106563. /**
  106564. * Gets the active meshes evaluation time capture status
  106565. */
  106566. /**
  106567. * Enable or disable the active meshes evaluation time capture
  106568. */
  106569. captureActiveMeshesEvaluationTime: boolean;
  106570. /**
  106571. * Gets the perf counter used for render targets render time
  106572. */
  106573. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106574. /**
  106575. * Gets the render targets render time capture status
  106576. */
  106577. /**
  106578. * Enable or disable the render targets render time capture
  106579. */
  106580. captureRenderTargetsRenderTime: boolean;
  106581. /**
  106582. * Gets the perf counter used for particles render time
  106583. */
  106584. readonly particlesRenderTimeCounter: PerfCounter;
  106585. /**
  106586. * Gets the particles render time capture status
  106587. */
  106588. /**
  106589. * Enable or disable the particles render time capture
  106590. */
  106591. captureParticlesRenderTime: boolean;
  106592. /**
  106593. * Gets the perf counter used for sprites render time
  106594. */
  106595. readonly spritesRenderTimeCounter: PerfCounter;
  106596. /**
  106597. * Gets the sprites render time capture status
  106598. */
  106599. /**
  106600. * Enable or disable the sprites render time capture
  106601. */
  106602. captureSpritesRenderTime: boolean;
  106603. /**
  106604. * Gets the perf counter used for physics time
  106605. */
  106606. readonly physicsTimeCounter: PerfCounter;
  106607. /**
  106608. * Gets the physics time capture status
  106609. */
  106610. /**
  106611. * Enable or disable the physics time capture
  106612. */
  106613. capturePhysicsTime: boolean;
  106614. /**
  106615. * Gets the perf counter used for animations time
  106616. */
  106617. readonly animationsTimeCounter: PerfCounter;
  106618. /**
  106619. * Gets the animations time capture status
  106620. */
  106621. /**
  106622. * Enable or disable the animations time capture
  106623. */
  106624. captureAnimationsTime: boolean;
  106625. /**
  106626. * Gets the perf counter used for frame time capture
  106627. */
  106628. readonly frameTimeCounter: PerfCounter;
  106629. /**
  106630. * Gets the frame time capture status
  106631. */
  106632. /**
  106633. * Enable or disable the frame time capture
  106634. */
  106635. captureFrameTime: boolean;
  106636. /**
  106637. * Gets the perf counter used for inter-frames time capture
  106638. */
  106639. readonly interFrameTimeCounter: PerfCounter;
  106640. /**
  106641. * Gets the inter-frames time capture status
  106642. */
  106643. /**
  106644. * Enable or disable the inter-frames time capture
  106645. */
  106646. captureInterFrameTime: boolean;
  106647. /**
  106648. * Gets the perf counter used for render time capture
  106649. */
  106650. readonly renderTimeCounter: PerfCounter;
  106651. /**
  106652. * Gets the render time capture status
  106653. */
  106654. /**
  106655. * Enable or disable the render time capture
  106656. */
  106657. captureRenderTime: boolean;
  106658. /**
  106659. * Gets the perf counter used for camera render time capture
  106660. */
  106661. readonly cameraRenderTimeCounter: PerfCounter;
  106662. /**
  106663. * Gets the camera render time capture status
  106664. */
  106665. /**
  106666. * Enable or disable the camera render time capture
  106667. */
  106668. captureCameraRenderTime: boolean;
  106669. /**
  106670. * Gets the perf counter used for draw calls
  106671. */
  106672. readonly drawCallsCounter: PerfCounter;
  106673. /**
  106674. * Instantiates a new scene instrumentation.
  106675. * This class can be used to get instrumentation data from a Babylon engine
  106676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106677. * @param scene Defines the scene to instrument
  106678. */
  106679. constructor(
  106680. /**
  106681. * Defines the scene to instrument
  106682. */
  106683. scene: Scene);
  106684. /**
  106685. * Dispose and release associated resources.
  106686. */
  106687. dispose(): void;
  106688. }
  106689. }
  106690. declare module BABYLON {
  106691. /** @hidden */
  106692. export var glowMapGenerationPixelShader: {
  106693. name: string;
  106694. shader: string;
  106695. };
  106696. }
  106697. declare module BABYLON {
  106698. /** @hidden */
  106699. export var glowMapGenerationVertexShader: {
  106700. name: string;
  106701. shader: string;
  106702. };
  106703. }
  106704. declare module BABYLON {
  106705. /**
  106706. * Effect layer options. This helps customizing the behaviour
  106707. * of the effect layer.
  106708. */
  106709. export interface IEffectLayerOptions {
  106710. /**
  106711. * Multiplication factor apply to the canvas size to compute the render target size
  106712. * used to generated the objects (the smaller the faster).
  106713. */
  106714. mainTextureRatio: number;
  106715. /**
  106716. * Enforces a fixed size texture to ensure effect stability across devices.
  106717. */
  106718. mainTextureFixedSize?: number;
  106719. /**
  106720. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106721. */
  106722. alphaBlendingMode: number;
  106723. /**
  106724. * The camera attached to the layer.
  106725. */
  106726. camera: Nullable<Camera>;
  106727. /**
  106728. * The rendering group to draw the layer in.
  106729. */
  106730. renderingGroupId: number;
  106731. }
  106732. /**
  106733. * The effect layer Helps adding post process effect blended with the main pass.
  106734. *
  106735. * This can be for instance use to generate glow or higlight effects on the scene.
  106736. *
  106737. * The effect layer class can not be used directly and is intented to inherited from to be
  106738. * customized per effects.
  106739. */
  106740. export abstract class EffectLayer {
  106741. private _vertexBuffers;
  106742. private _indexBuffer;
  106743. private _cachedDefines;
  106744. private _effectLayerMapGenerationEffect;
  106745. private _effectLayerOptions;
  106746. private _mergeEffect;
  106747. protected _scene: Scene;
  106748. protected _engine: Engine;
  106749. protected _maxSize: number;
  106750. protected _mainTextureDesiredSize: ISize;
  106751. protected _mainTexture: RenderTargetTexture;
  106752. protected _shouldRender: boolean;
  106753. protected _postProcesses: PostProcess[];
  106754. protected _textures: BaseTexture[];
  106755. protected _emissiveTextureAndColor: {
  106756. texture: Nullable<BaseTexture>;
  106757. color: Color4;
  106758. };
  106759. /**
  106760. * The name of the layer
  106761. */
  106762. name: string;
  106763. /**
  106764. * The clear color of the texture used to generate the glow map.
  106765. */
  106766. neutralColor: Color4;
  106767. /**
  106768. * Specifies wether the highlight layer is enabled or not.
  106769. */
  106770. isEnabled: boolean;
  106771. /**
  106772. * Gets the camera attached to the layer.
  106773. */
  106774. readonly camera: Nullable<Camera>;
  106775. /**
  106776. * Gets the rendering group id the layer should render in.
  106777. */
  106778. readonly renderingGroupId: number;
  106779. /**
  106780. * An event triggered when the effect layer has been disposed.
  106781. */
  106782. onDisposeObservable: Observable<EffectLayer>;
  106783. /**
  106784. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106785. */
  106786. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106787. /**
  106788. * An event triggered when the generated texture is being merged in the scene.
  106789. */
  106790. onBeforeComposeObservable: Observable<EffectLayer>;
  106791. /**
  106792. * An event triggered when the generated texture has been merged in the scene.
  106793. */
  106794. onAfterComposeObservable: Observable<EffectLayer>;
  106795. /**
  106796. * An event triggered when the efffect layer changes its size.
  106797. */
  106798. onSizeChangedObservable: Observable<EffectLayer>;
  106799. /** @hidden */
  106800. static _SceneComponentInitialization: (scene: Scene) => void;
  106801. /**
  106802. * Instantiates a new effect Layer and references it in the scene.
  106803. * @param name The name of the layer
  106804. * @param scene The scene to use the layer in
  106805. */
  106806. constructor(
  106807. /** The Friendly of the effect in the scene */
  106808. name: string, scene: Scene);
  106809. /**
  106810. * Get the effect name of the layer.
  106811. * @return The effect name
  106812. */
  106813. abstract getEffectName(): string;
  106814. /**
  106815. * Checks for the readiness of the element composing the layer.
  106816. * @param subMesh the mesh to check for
  106817. * @param useInstances specify wether or not to use instances to render the mesh
  106818. * @return true if ready otherwise, false
  106819. */
  106820. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106821. /**
  106822. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106823. * @returns true if the effect requires stencil during the main canvas render pass.
  106824. */
  106825. abstract needStencil(): boolean;
  106826. /**
  106827. * Create the merge effect. This is the shader use to blit the information back
  106828. * to the main canvas at the end of the scene rendering.
  106829. * @returns The effect containing the shader used to merge the effect on the main canvas
  106830. */
  106831. protected abstract _createMergeEffect(): Effect;
  106832. /**
  106833. * Creates the render target textures and post processes used in the effect layer.
  106834. */
  106835. protected abstract _createTextureAndPostProcesses(): void;
  106836. /**
  106837. * Implementation specific of rendering the generating effect on the main canvas.
  106838. * @param effect The effect used to render through
  106839. */
  106840. protected abstract _internalRender(effect: Effect): void;
  106841. /**
  106842. * Sets the required values for both the emissive texture and and the main color.
  106843. */
  106844. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106845. /**
  106846. * Free any resources and references associated to a mesh.
  106847. * Internal use
  106848. * @param mesh The mesh to free.
  106849. */
  106850. abstract _disposeMesh(mesh: Mesh): void;
  106851. /**
  106852. * Serializes this layer (Glow or Highlight for example)
  106853. * @returns a serialized layer object
  106854. */
  106855. abstract serialize?(): any;
  106856. /**
  106857. * Initializes the effect layer with the required options.
  106858. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106859. */
  106860. protected _init(options: Partial<IEffectLayerOptions>): void;
  106861. /**
  106862. * Generates the index buffer of the full screen quad blending to the main canvas.
  106863. */
  106864. private _generateIndexBuffer;
  106865. /**
  106866. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106867. */
  106868. private _generateVertexBuffer;
  106869. /**
  106870. * Sets the main texture desired size which is the closest power of two
  106871. * of the engine canvas size.
  106872. */
  106873. private _setMainTextureSize;
  106874. /**
  106875. * Creates the main texture for the effect layer.
  106876. */
  106877. protected _createMainTexture(): void;
  106878. /**
  106879. * Adds specific effects defines.
  106880. * @param defines The defines to add specifics to.
  106881. */
  106882. protected _addCustomEffectDefines(defines: string[]): void;
  106883. /**
  106884. * Checks for the readiness of the element composing the layer.
  106885. * @param subMesh the mesh to check for
  106886. * @param useInstances specify wether or not to use instances to render the mesh
  106887. * @param emissiveTexture the associated emissive texture used to generate the glow
  106888. * @return true if ready otherwise, false
  106889. */
  106890. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106891. /**
  106892. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106893. */
  106894. render(): void;
  106895. /**
  106896. * Determine if a given mesh will be used in the current effect.
  106897. * @param mesh mesh to test
  106898. * @returns true if the mesh will be used
  106899. */
  106900. hasMesh(mesh: AbstractMesh): boolean;
  106901. /**
  106902. * Returns true if the layer contains information to display, otherwise false.
  106903. * @returns true if the glow layer should be rendered
  106904. */
  106905. shouldRender(): boolean;
  106906. /**
  106907. * Returns true if the mesh should render, otherwise false.
  106908. * @param mesh The mesh to render
  106909. * @returns true if it should render otherwise false
  106910. */
  106911. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106912. /**
  106913. * Returns true if the mesh can be rendered, otherwise false.
  106914. * @param mesh The mesh to render
  106915. * @param material The material used on the mesh
  106916. * @returns true if it can be rendered otherwise false
  106917. */
  106918. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106919. /**
  106920. * Returns true if the mesh should render, otherwise false.
  106921. * @param mesh The mesh to render
  106922. * @returns true if it should render otherwise false
  106923. */
  106924. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106925. /**
  106926. * Renders the submesh passed in parameter to the generation map.
  106927. */
  106928. protected _renderSubMesh(subMesh: SubMesh): void;
  106929. /**
  106930. * Rebuild the required buffers.
  106931. * @hidden Internal use only.
  106932. */
  106933. _rebuild(): void;
  106934. /**
  106935. * Dispose only the render target textures and post process.
  106936. */
  106937. private _disposeTextureAndPostProcesses;
  106938. /**
  106939. * Dispose the highlight layer and free resources.
  106940. */
  106941. dispose(): void;
  106942. /**
  106943. * Gets the class name of the effect layer
  106944. * @returns the string with the class name of the effect layer
  106945. */
  106946. getClassName(): string;
  106947. /**
  106948. * Creates an effect layer from parsed effect layer data
  106949. * @param parsedEffectLayer defines effect layer data
  106950. * @param scene defines the current scene
  106951. * @param rootUrl defines the root URL containing the effect layer information
  106952. * @returns a parsed effect Layer
  106953. */
  106954. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106955. }
  106956. }
  106957. declare module BABYLON {
  106958. interface AbstractScene {
  106959. /**
  106960. * The list of effect layers (highlights/glow) added to the scene
  106961. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106962. * @see http://doc.babylonjs.com/how_to/glow_layer
  106963. */
  106964. effectLayers: Array<EffectLayer>;
  106965. /**
  106966. * Removes the given effect layer from this scene.
  106967. * @param toRemove defines the effect layer to remove
  106968. * @returns the index of the removed effect layer
  106969. */
  106970. removeEffectLayer(toRemove: EffectLayer): number;
  106971. /**
  106972. * Adds the given effect layer to this scene
  106973. * @param newEffectLayer defines the effect layer to add
  106974. */
  106975. addEffectLayer(newEffectLayer: EffectLayer): void;
  106976. }
  106977. /**
  106978. * Defines the layer scene component responsible to manage any effect layers
  106979. * in a given scene.
  106980. */
  106981. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106982. /**
  106983. * The component name helpfull to identify the component in the list of scene components.
  106984. */
  106985. readonly name: string;
  106986. /**
  106987. * The scene the component belongs to.
  106988. */
  106989. scene: Scene;
  106990. private _engine;
  106991. private _renderEffects;
  106992. private _needStencil;
  106993. private _previousStencilState;
  106994. /**
  106995. * Creates a new instance of the component for the given scene
  106996. * @param scene Defines the scene to register the component in
  106997. */
  106998. constructor(scene: Scene);
  106999. /**
  107000. * Registers the component in a given scene
  107001. */
  107002. register(): void;
  107003. /**
  107004. * Rebuilds the elements related to this component in case of
  107005. * context lost for instance.
  107006. */
  107007. rebuild(): void;
  107008. /**
  107009. * Serializes the component data to the specified json object
  107010. * @param serializationObject The object to serialize to
  107011. */
  107012. serialize(serializationObject: any): void;
  107013. /**
  107014. * Adds all the element from the container to the scene
  107015. * @param container the container holding the elements
  107016. */
  107017. addFromContainer(container: AbstractScene): void;
  107018. /**
  107019. * Removes all the elements in the container from the scene
  107020. * @param container contains the elements to remove
  107021. * @param dispose if the removed element should be disposed (default: false)
  107022. */
  107023. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107024. /**
  107025. * Disposes the component and the associated ressources.
  107026. */
  107027. dispose(): void;
  107028. private _isReadyForMesh;
  107029. private _renderMainTexture;
  107030. private _setStencil;
  107031. private _setStencilBack;
  107032. private _draw;
  107033. private _drawCamera;
  107034. private _drawRenderingGroup;
  107035. }
  107036. }
  107037. declare module BABYLON {
  107038. /** @hidden */
  107039. export var glowMapMergePixelShader: {
  107040. name: string;
  107041. shader: string;
  107042. };
  107043. }
  107044. declare module BABYLON {
  107045. /** @hidden */
  107046. export var glowMapMergeVertexShader: {
  107047. name: string;
  107048. shader: string;
  107049. };
  107050. }
  107051. declare module BABYLON {
  107052. interface AbstractScene {
  107053. /**
  107054. * Return a the first highlight layer of the scene with a given name.
  107055. * @param name The name of the highlight layer to look for.
  107056. * @return The highlight layer if found otherwise null.
  107057. */
  107058. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  107059. }
  107060. /**
  107061. * Glow layer options. This helps customizing the behaviour
  107062. * of the glow layer.
  107063. */
  107064. export interface IGlowLayerOptions {
  107065. /**
  107066. * Multiplication factor apply to the canvas size to compute the render target size
  107067. * used to generated the glowing objects (the smaller the faster).
  107068. */
  107069. mainTextureRatio: number;
  107070. /**
  107071. * Enforces a fixed size texture to ensure resize independant blur.
  107072. */
  107073. mainTextureFixedSize?: number;
  107074. /**
  107075. * How big is the kernel of the blur texture.
  107076. */
  107077. blurKernelSize: number;
  107078. /**
  107079. * The camera attached to the layer.
  107080. */
  107081. camera: Nullable<Camera>;
  107082. /**
  107083. * Enable MSAA by chosing the number of samples.
  107084. */
  107085. mainTextureSamples?: number;
  107086. /**
  107087. * The rendering group to draw the layer in.
  107088. */
  107089. renderingGroupId: number;
  107090. }
  107091. /**
  107092. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  107093. *
  107094. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107095. * glowy meshes to your scene.
  107096. *
  107097. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  107098. */
  107099. export class GlowLayer extends EffectLayer {
  107100. /**
  107101. * Effect Name of the layer.
  107102. */
  107103. static readonly EffectName: string;
  107104. /**
  107105. * The default blur kernel size used for the glow.
  107106. */
  107107. static DefaultBlurKernelSize: number;
  107108. /**
  107109. * The default texture size ratio used for the glow.
  107110. */
  107111. static DefaultTextureRatio: number;
  107112. /**
  107113. * Sets the kernel size of the blur.
  107114. */
  107115. /**
  107116. * Gets the kernel size of the blur.
  107117. */
  107118. blurKernelSize: number;
  107119. /**
  107120. * Sets the glow intensity.
  107121. */
  107122. /**
  107123. * Gets the glow intensity.
  107124. */
  107125. intensity: number;
  107126. private _options;
  107127. private _intensity;
  107128. private _horizontalBlurPostprocess1;
  107129. private _verticalBlurPostprocess1;
  107130. private _horizontalBlurPostprocess2;
  107131. private _verticalBlurPostprocess2;
  107132. private _blurTexture1;
  107133. private _blurTexture2;
  107134. private _postProcesses1;
  107135. private _postProcesses2;
  107136. private _includedOnlyMeshes;
  107137. private _excludedMeshes;
  107138. /**
  107139. * Callback used to let the user override the color selection on a per mesh basis
  107140. */
  107141. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  107142. /**
  107143. * Callback used to let the user override the texture selection on a per mesh basis
  107144. */
  107145. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  107146. /**
  107147. * Instantiates a new glow Layer and references it to the scene.
  107148. * @param name The name of the layer
  107149. * @param scene The scene to use the layer in
  107150. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  107151. */
  107152. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  107153. /**
  107154. * Get the effect name of the layer.
  107155. * @return The effect name
  107156. */
  107157. getEffectName(): string;
  107158. /**
  107159. * Create the merge effect. This is the shader use to blit the information back
  107160. * to the main canvas at the end of the scene rendering.
  107161. */
  107162. protected _createMergeEffect(): Effect;
  107163. /**
  107164. * Creates the render target textures and post processes used in the glow layer.
  107165. */
  107166. protected _createTextureAndPostProcesses(): void;
  107167. /**
  107168. * Checks for the readiness of the element composing the layer.
  107169. * @param subMesh the mesh to check for
  107170. * @param useInstances specify wether or not to use instances to render the mesh
  107171. * @param emissiveTexture the associated emissive texture used to generate the glow
  107172. * @return true if ready otherwise, false
  107173. */
  107174. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107175. /**
  107176. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107177. */
  107178. needStencil(): boolean;
  107179. /**
  107180. * Returns true if the mesh can be rendered, otherwise false.
  107181. * @param mesh The mesh to render
  107182. * @param material The material used on the mesh
  107183. * @returns true if it can be rendered otherwise false
  107184. */
  107185. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107186. /**
  107187. * Implementation specific of rendering the generating effect on the main canvas.
  107188. * @param effect The effect used to render through
  107189. */
  107190. protected _internalRender(effect: Effect): void;
  107191. /**
  107192. * Sets the required values for both the emissive texture and and the main color.
  107193. */
  107194. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107195. /**
  107196. * Returns true if the mesh should render, otherwise false.
  107197. * @param mesh The mesh to render
  107198. * @returns true if it should render otherwise false
  107199. */
  107200. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107201. /**
  107202. * Adds specific effects defines.
  107203. * @param defines The defines to add specifics to.
  107204. */
  107205. protected _addCustomEffectDefines(defines: string[]): void;
  107206. /**
  107207. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  107208. * @param mesh The mesh to exclude from the glow layer
  107209. */
  107210. addExcludedMesh(mesh: Mesh): void;
  107211. /**
  107212. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  107213. * @param mesh The mesh to remove
  107214. */
  107215. removeExcludedMesh(mesh: Mesh): void;
  107216. /**
  107217. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  107218. * @param mesh The mesh to include in the glow layer
  107219. */
  107220. addIncludedOnlyMesh(mesh: Mesh): void;
  107221. /**
  107222. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  107223. * @param mesh The mesh to remove
  107224. */
  107225. removeIncludedOnlyMesh(mesh: Mesh): void;
  107226. /**
  107227. * Determine if a given mesh will be used in the glow layer
  107228. * @param mesh The mesh to test
  107229. * @returns true if the mesh will be highlighted by the current glow layer
  107230. */
  107231. hasMesh(mesh: AbstractMesh): boolean;
  107232. /**
  107233. * Free any resources and references associated to a mesh.
  107234. * Internal use
  107235. * @param mesh The mesh to free.
  107236. * @hidden
  107237. */
  107238. _disposeMesh(mesh: Mesh): void;
  107239. /**
  107240. * Gets the class name of the effect layer
  107241. * @returns the string with the class name of the effect layer
  107242. */
  107243. getClassName(): string;
  107244. /**
  107245. * Serializes this glow layer
  107246. * @returns a serialized glow layer object
  107247. */
  107248. serialize(): any;
  107249. /**
  107250. * Creates a Glow Layer from parsed glow layer data
  107251. * @param parsedGlowLayer defines glow layer data
  107252. * @param scene defines the current scene
  107253. * @param rootUrl defines the root URL containing the glow layer information
  107254. * @returns a parsed Glow Layer
  107255. */
  107256. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  107257. }
  107258. }
  107259. declare module BABYLON {
  107260. /** @hidden */
  107261. export var glowBlurPostProcessPixelShader: {
  107262. name: string;
  107263. shader: string;
  107264. };
  107265. }
  107266. declare module BABYLON {
  107267. interface AbstractScene {
  107268. /**
  107269. * Return a the first highlight layer of the scene with a given name.
  107270. * @param name The name of the highlight layer to look for.
  107271. * @return The highlight layer if found otherwise null.
  107272. */
  107273. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  107274. }
  107275. /**
  107276. * Highlight layer options. This helps customizing the behaviour
  107277. * of the highlight layer.
  107278. */
  107279. export interface IHighlightLayerOptions {
  107280. /**
  107281. * Multiplication factor apply to the canvas size to compute the render target size
  107282. * used to generated the glowing objects (the smaller the faster).
  107283. */
  107284. mainTextureRatio: number;
  107285. /**
  107286. * Enforces a fixed size texture to ensure resize independant blur.
  107287. */
  107288. mainTextureFixedSize?: number;
  107289. /**
  107290. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  107291. * of the picture to blur (the smaller the faster).
  107292. */
  107293. blurTextureSizeRatio: number;
  107294. /**
  107295. * How big in texel of the blur texture is the vertical blur.
  107296. */
  107297. blurVerticalSize: number;
  107298. /**
  107299. * How big in texel of the blur texture is the horizontal blur.
  107300. */
  107301. blurHorizontalSize: number;
  107302. /**
  107303. * Alpha blending mode used to apply the blur. Default is combine.
  107304. */
  107305. alphaBlendingMode: number;
  107306. /**
  107307. * The camera attached to the layer.
  107308. */
  107309. camera: Nullable<Camera>;
  107310. /**
  107311. * Should we display highlight as a solid stroke?
  107312. */
  107313. isStroke?: boolean;
  107314. /**
  107315. * The rendering group to draw the layer in.
  107316. */
  107317. renderingGroupId: number;
  107318. }
  107319. /**
  107320. * The highlight layer Helps adding a glow effect around a mesh.
  107321. *
  107322. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107323. * glowy meshes to your scene.
  107324. *
  107325. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  107326. */
  107327. export class HighlightLayer extends EffectLayer {
  107328. name: string;
  107329. /**
  107330. * Effect Name of the highlight layer.
  107331. */
  107332. static readonly EffectName: string;
  107333. /**
  107334. * The neutral color used during the preparation of the glow effect.
  107335. * This is black by default as the blend operation is a blend operation.
  107336. */
  107337. static NeutralColor: Color4;
  107338. /**
  107339. * Stencil value used for glowing meshes.
  107340. */
  107341. static GlowingMeshStencilReference: number;
  107342. /**
  107343. * Stencil value used for the other meshes in the scene.
  107344. */
  107345. static NormalMeshStencilReference: number;
  107346. /**
  107347. * Specifies whether or not the inner glow is ACTIVE in the layer.
  107348. */
  107349. innerGlow: boolean;
  107350. /**
  107351. * Specifies whether or not the outer glow is ACTIVE in the layer.
  107352. */
  107353. outerGlow: boolean;
  107354. /**
  107355. * Specifies the horizontal size of the blur.
  107356. */
  107357. /**
  107358. * Gets the horizontal size of the blur.
  107359. */
  107360. blurHorizontalSize: number;
  107361. /**
  107362. * Specifies the vertical size of the blur.
  107363. */
  107364. /**
  107365. * Gets the vertical size of the blur.
  107366. */
  107367. blurVerticalSize: number;
  107368. /**
  107369. * An event triggered when the highlight layer is being blurred.
  107370. */
  107371. onBeforeBlurObservable: Observable<HighlightLayer>;
  107372. /**
  107373. * An event triggered when the highlight layer has been blurred.
  107374. */
  107375. onAfterBlurObservable: Observable<HighlightLayer>;
  107376. private _instanceGlowingMeshStencilReference;
  107377. private _options;
  107378. private _downSamplePostprocess;
  107379. private _horizontalBlurPostprocess;
  107380. private _verticalBlurPostprocess;
  107381. private _blurTexture;
  107382. private _meshes;
  107383. private _excludedMeshes;
  107384. /**
  107385. * Instantiates a new highlight Layer and references it to the scene..
  107386. * @param name The name of the layer
  107387. * @param scene The scene to use the layer in
  107388. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  107389. */
  107390. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  107391. /**
  107392. * Get the effect name of the layer.
  107393. * @return The effect name
  107394. */
  107395. getEffectName(): string;
  107396. /**
  107397. * Create the merge effect. This is the shader use to blit the information back
  107398. * to the main canvas at the end of the scene rendering.
  107399. */
  107400. protected _createMergeEffect(): Effect;
  107401. /**
  107402. * Creates the render target textures and post processes used in the highlight layer.
  107403. */
  107404. protected _createTextureAndPostProcesses(): void;
  107405. /**
  107406. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107407. */
  107408. needStencil(): boolean;
  107409. /**
  107410. * Checks for the readiness of the element composing the layer.
  107411. * @param subMesh the mesh to check for
  107412. * @param useInstances specify wether or not to use instances to render the mesh
  107413. * @param emissiveTexture the associated emissive texture used to generate the glow
  107414. * @return true if ready otherwise, false
  107415. */
  107416. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107417. /**
  107418. * Implementation specific of rendering the generating effect on the main canvas.
  107419. * @param effect The effect used to render through
  107420. */
  107421. protected _internalRender(effect: Effect): void;
  107422. /**
  107423. * Returns true if the layer contains information to display, otherwise false.
  107424. */
  107425. shouldRender(): boolean;
  107426. /**
  107427. * Returns true if the mesh should render, otherwise false.
  107428. * @param mesh The mesh to render
  107429. * @returns true if it should render otherwise false
  107430. */
  107431. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107432. /**
  107433. * Sets the required values for both the emissive texture and and the main color.
  107434. */
  107435. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107436. /**
  107437. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  107438. * @param mesh The mesh to exclude from the highlight layer
  107439. */
  107440. addExcludedMesh(mesh: Mesh): void;
  107441. /**
  107442. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  107443. * @param mesh The mesh to highlight
  107444. */
  107445. removeExcludedMesh(mesh: Mesh): void;
  107446. /**
  107447. * Determine if a given mesh will be highlighted by the current HighlightLayer
  107448. * @param mesh mesh to test
  107449. * @returns true if the mesh will be highlighted by the current HighlightLayer
  107450. */
  107451. hasMesh(mesh: AbstractMesh): boolean;
  107452. /**
  107453. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  107454. * @param mesh The mesh to highlight
  107455. * @param color The color of the highlight
  107456. * @param glowEmissiveOnly Extract the glow from the emissive texture
  107457. */
  107458. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  107459. /**
  107460. * Remove a mesh from the highlight layer in order to make it stop glowing.
  107461. * @param mesh The mesh to highlight
  107462. */
  107463. removeMesh(mesh: Mesh): void;
  107464. /**
  107465. * Force the stencil to the normal expected value for none glowing parts
  107466. */
  107467. private _defaultStencilReference;
  107468. /**
  107469. * Free any resources and references associated to a mesh.
  107470. * Internal use
  107471. * @param mesh The mesh to free.
  107472. * @hidden
  107473. */
  107474. _disposeMesh(mesh: Mesh): void;
  107475. /**
  107476. * Dispose the highlight layer and free resources.
  107477. */
  107478. dispose(): void;
  107479. /**
  107480. * Gets the class name of the effect layer
  107481. * @returns the string with the class name of the effect layer
  107482. */
  107483. getClassName(): string;
  107484. /**
  107485. * Serializes this Highlight layer
  107486. * @returns a serialized Highlight layer object
  107487. */
  107488. serialize(): any;
  107489. /**
  107490. * Creates a Highlight layer from parsed Highlight layer data
  107491. * @param parsedHightlightLayer defines the Highlight layer data
  107492. * @param scene defines the current scene
  107493. * @param rootUrl defines the root URL containing the Highlight layer information
  107494. * @returns a parsed Highlight layer
  107495. */
  107496. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  107497. }
  107498. }
  107499. declare module BABYLON {
  107500. /** @hidden */
  107501. export var lensFlarePixelShader: {
  107502. name: string;
  107503. shader: string;
  107504. };
  107505. }
  107506. declare module BABYLON {
  107507. /** @hidden */
  107508. export var lensFlareVertexShader: {
  107509. name: string;
  107510. shader: string;
  107511. };
  107512. }
  107513. declare module BABYLON {
  107514. /**
  107515. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107516. * It is usually composed of several `lensFlare`.
  107517. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107518. */
  107519. export class LensFlareSystem {
  107520. /**
  107521. * Define the name of the lens flare system
  107522. */
  107523. name: string;
  107524. /**
  107525. * List of lens flares used in this system.
  107526. */
  107527. lensFlares: LensFlare[];
  107528. /**
  107529. * Define a limit from the border the lens flare can be visible.
  107530. */
  107531. borderLimit: number;
  107532. /**
  107533. * Define a viewport border we do not want to see the lens flare in.
  107534. */
  107535. viewportBorder: number;
  107536. /**
  107537. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107538. */
  107539. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107540. /**
  107541. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107542. */
  107543. layerMask: number;
  107544. /**
  107545. * Define the id of the lens flare system in the scene.
  107546. * (equal to name by default)
  107547. */
  107548. id: string;
  107549. private _scene;
  107550. private _emitter;
  107551. private _vertexBuffers;
  107552. private _indexBuffer;
  107553. private _effect;
  107554. private _positionX;
  107555. private _positionY;
  107556. private _isEnabled;
  107557. /** @hidden */
  107558. static _SceneComponentInitialization: (scene: Scene) => void;
  107559. /**
  107560. * Instantiates a lens flare system.
  107561. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107562. * It is usually composed of several `lensFlare`.
  107563. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107564. * @param name Define the name of the lens flare system in the scene
  107565. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107566. * @param scene Define the scene the lens flare system belongs to
  107567. */
  107568. constructor(
  107569. /**
  107570. * Define the name of the lens flare system
  107571. */
  107572. name: string, emitter: any, scene: Scene);
  107573. /**
  107574. * Define if the lens flare system is enabled.
  107575. */
  107576. isEnabled: boolean;
  107577. /**
  107578. * Get the scene the effects belongs to.
  107579. * @returns the scene holding the lens flare system
  107580. */
  107581. getScene(): Scene;
  107582. /**
  107583. * Get the emitter of the lens flare system.
  107584. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107585. * @returns the emitter of the lens flare system
  107586. */
  107587. getEmitter(): any;
  107588. /**
  107589. * Set the emitter of the lens flare system.
  107590. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107591. * @param newEmitter Define the new emitter of the system
  107592. */
  107593. setEmitter(newEmitter: any): void;
  107594. /**
  107595. * Get the lens flare system emitter position.
  107596. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107597. * @returns the position
  107598. */
  107599. getEmitterPosition(): Vector3;
  107600. /**
  107601. * @hidden
  107602. */
  107603. computeEffectivePosition(globalViewport: Viewport): boolean;
  107604. /** @hidden */
  107605. _isVisible(): boolean;
  107606. /**
  107607. * @hidden
  107608. */
  107609. render(): boolean;
  107610. /**
  107611. * Dispose and release the lens flare with its associated resources.
  107612. */
  107613. dispose(): void;
  107614. /**
  107615. * Parse a lens flare system from a JSON repressentation
  107616. * @param parsedLensFlareSystem Define the JSON to parse
  107617. * @param scene Define the scene the parsed system should be instantiated in
  107618. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107619. * @returns the parsed system
  107620. */
  107621. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107622. /**
  107623. * Serialize the current Lens Flare System into a JSON representation.
  107624. * @returns the serialized JSON
  107625. */
  107626. serialize(): any;
  107627. }
  107628. }
  107629. declare module BABYLON {
  107630. /**
  107631. * This represents one of the lens effect in a `lensFlareSystem`.
  107632. * It controls one of the indiviual texture used in the effect.
  107633. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107634. */
  107635. export class LensFlare {
  107636. /**
  107637. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107638. */
  107639. size: number;
  107640. /**
  107641. * 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.
  107642. */
  107643. position: number;
  107644. /**
  107645. * Define the lens color.
  107646. */
  107647. color: Color3;
  107648. /**
  107649. * Define the lens texture.
  107650. */
  107651. texture: Nullable<Texture>;
  107652. /**
  107653. * Define the alpha mode to render this particular lens.
  107654. */
  107655. alphaMode: number;
  107656. private _system;
  107657. /**
  107658. * Creates a new Lens Flare.
  107659. * This represents one of the lens effect in a `lensFlareSystem`.
  107660. * It controls one of the indiviual texture used in the effect.
  107661. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107662. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107663. * @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.
  107664. * @param color Define the lens color
  107665. * @param imgUrl Define the lens texture url
  107666. * @param system Define the `lensFlareSystem` this flare is part of
  107667. * @returns The newly created Lens Flare
  107668. */
  107669. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107670. /**
  107671. * Instantiates a new Lens Flare.
  107672. * This represents one of the lens effect in a `lensFlareSystem`.
  107673. * It controls one of the indiviual texture used in the effect.
  107674. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107675. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107676. * @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.
  107677. * @param color Define the lens color
  107678. * @param imgUrl Define the lens texture url
  107679. * @param system Define the `lensFlareSystem` this flare is part of
  107680. */
  107681. constructor(
  107682. /**
  107683. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107684. */
  107685. size: number,
  107686. /**
  107687. * 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.
  107688. */
  107689. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107690. /**
  107691. * Dispose and release the lens flare with its associated resources.
  107692. */
  107693. dispose(): void;
  107694. }
  107695. }
  107696. declare module BABYLON {
  107697. interface AbstractScene {
  107698. /**
  107699. * The list of lens flare system added to the scene
  107700. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107701. */
  107702. lensFlareSystems: Array<LensFlareSystem>;
  107703. /**
  107704. * Removes the given lens flare system from this scene.
  107705. * @param toRemove The lens flare system to remove
  107706. * @returns The index of the removed lens flare system
  107707. */
  107708. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107709. /**
  107710. * Adds the given lens flare system to this scene
  107711. * @param newLensFlareSystem The lens flare system to add
  107712. */
  107713. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107714. /**
  107715. * Gets a lens flare system using its name
  107716. * @param name defines the name to look for
  107717. * @returns the lens flare system or null if not found
  107718. */
  107719. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107720. /**
  107721. * Gets a lens flare system using its id
  107722. * @param id defines the id to look for
  107723. * @returns the lens flare system or null if not found
  107724. */
  107725. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107726. }
  107727. /**
  107728. * Defines the lens flare scene component responsible to manage any lens flares
  107729. * in a given scene.
  107730. */
  107731. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107732. /**
  107733. * The component name helpfull to identify the component in the list of scene components.
  107734. */
  107735. readonly name: string;
  107736. /**
  107737. * The scene the component belongs to.
  107738. */
  107739. scene: Scene;
  107740. /**
  107741. * Creates a new instance of the component for the given scene
  107742. * @param scene Defines the scene to register the component in
  107743. */
  107744. constructor(scene: Scene);
  107745. /**
  107746. * Registers the component in a given scene
  107747. */
  107748. register(): void;
  107749. /**
  107750. * Rebuilds the elements related to this component in case of
  107751. * context lost for instance.
  107752. */
  107753. rebuild(): void;
  107754. /**
  107755. * Adds all the element from the container to the scene
  107756. * @param container the container holding the elements
  107757. */
  107758. addFromContainer(container: AbstractScene): void;
  107759. /**
  107760. * Removes all the elements in the container from the scene
  107761. * @param container contains the elements to remove
  107762. * @param dispose if the removed element should be disposed (default: false)
  107763. */
  107764. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107765. /**
  107766. * Serializes the component data to the specified json object
  107767. * @param serializationObject The object to serialize to
  107768. */
  107769. serialize(serializationObject: any): void;
  107770. /**
  107771. * Disposes the component and the associated ressources.
  107772. */
  107773. dispose(): void;
  107774. private _draw;
  107775. }
  107776. }
  107777. declare module BABYLON {
  107778. /**
  107779. * Defines the shadow generator component responsible to manage any shadow generators
  107780. * in a given scene.
  107781. */
  107782. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107783. /**
  107784. * The component name helpfull to identify the component in the list of scene components.
  107785. */
  107786. readonly name: string;
  107787. /**
  107788. * The scene the component belongs to.
  107789. */
  107790. scene: Scene;
  107791. /**
  107792. * Creates a new instance of the component for the given scene
  107793. * @param scene Defines the scene to register the component in
  107794. */
  107795. constructor(scene: Scene);
  107796. /**
  107797. * Registers the component in a given scene
  107798. */
  107799. register(): void;
  107800. /**
  107801. * Rebuilds the elements related to this component in case of
  107802. * context lost for instance.
  107803. */
  107804. rebuild(): void;
  107805. /**
  107806. * Serializes the component data to the specified json object
  107807. * @param serializationObject The object to serialize to
  107808. */
  107809. serialize(serializationObject: any): void;
  107810. /**
  107811. * Adds all the element from the container to the scene
  107812. * @param container the container holding the elements
  107813. */
  107814. addFromContainer(container: AbstractScene): void;
  107815. /**
  107816. * Removes all the elements in the container from the scene
  107817. * @param container contains the elements to remove
  107818. * @param dispose if the removed element should be disposed (default: false)
  107819. */
  107820. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107821. /**
  107822. * Rebuilds the elements related to this component in case of
  107823. * context lost for instance.
  107824. */
  107825. dispose(): void;
  107826. private _gatherRenderTargets;
  107827. }
  107828. }
  107829. declare module BABYLON {
  107830. /**
  107831. * A point light is a light defined by an unique point in world space.
  107832. * The light is emitted in every direction from this point.
  107833. * A good example of a point light is a standard light bulb.
  107834. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107835. */
  107836. export class PointLight extends ShadowLight {
  107837. private _shadowAngle;
  107838. /**
  107839. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107840. * This specifies what angle the shadow will use to be created.
  107841. *
  107842. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107843. */
  107844. /**
  107845. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107846. * This specifies what angle the shadow will use to be created.
  107847. *
  107848. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107849. */
  107850. shadowAngle: number;
  107851. /**
  107852. * Gets the direction if it has been set.
  107853. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107854. */
  107855. /**
  107856. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107857. */
  107858. direction: Vector3;
  107859. /**
  107860. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107861. * A PointLight emits the light in every direction.
  107862. * It can cast shadows.
  107863. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107864. * ```javascript
  107865. * var pointLight = new PointLight("pl", camera.position, scene);
  107866. * ```
  107867. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107868. * @param name The light friendly name
  107869. * @param position The position of the point light in the scene
  107870. * @param scene The scene the lights belongs to
  107871. */
  107872. constructor(name: string, position: Vector3, scene: Scene);
  107873. /**
  107874. * Returns the string "PointLight"
  107875. * @returns the class name
  107876. */
  107877. getClassName(): string;
  107878. /**
  107879. * Returns the integer 0.
  107880. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107881. */
  107882. getTypeID(): number;
  107883. /**
  107884. * Specifies wether or not the shadowmap should be a cube texture.
  107885. * @returns true if the shadowmap needs to be a cube texture.
  107886. */
  107887. needCube(): boolean;
  107888. /**
  107889. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107890. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107891. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107892. */
  107893. getShadowDirection(faceIndex?: number): Vector3;
  107894. /**
  107895. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107896. * - fov = PI / 2
  107897. * - aspect ratio : 1.0
  107898. * - z-near and far equal to the active camera minZ and maxZ.
  107899. * Returns the PointLight.
  107900. */
  107901. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107902. protected _buildUniformLayout(): void;
  107903. /**
  107904. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107905. * @param effect The effect to update
  107906. * @param lightIndex The index of the light in the effect to update
  107907. * @returns The point light
  107908. */
  107909. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107910. /**
  107911. * Prepares the list of defines specific to the light type.
  107912. * @param defines the list of defines
  107913. * @param lightIndex defines the index of the light for the effect
  107914. */
  107915. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107916. }
  107917. }
  107918. declare module BABYLON {
  107919. /**
  107920. * Header information of HDR texture files.
  107921. */
  107922. export interface HDRInfo {
  107923. /**
  107924. * The height of the texture in pixels.
  107925. */
  107926. height: number;
  107927. /**
  107928. * The width of the texture in pixels.
  107929. */
  107930. width: number;
  107931. /**
  107932. * The index of the beginning of the data in the binary file.
  107933. */
  107934. dataPosition: number;
  107935. }
  107936. /**
  107937. * This groups tools to convert HDR texture to native colors array.
  107938. */
  107939. export class HDRTools {
  107940. private static Ldexp;
  107941. private static Rgbe2float;
  107942. private static readStringLine;
  107943. /**
  107944. * Reads header information from an RGBE texture stored in a native array.
  107945. * More information on this format are available here:
  107946. * https://en.wikipedia.org/wiki/RGBE_image_format
  107947. *
  107948. * @param uint8array The binary file stored in native array.
  107949. * @return The header information.
  107950. */
  107951. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107952. /**
  107953. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107954. * This RGBE texture needs to store the information as a panorama.
  107955. *
  107956. * More information on this format are available here:
  107957. * https://en.wikipedia.org/wiki/RGBE_image_format
  107958. *
  107959. * @param buffer The binary file stored in an array buffer.
  107960. * @param size The expected size of the extracted cubemap.
  107961. * @return The Cube Map information.
  107962. */
  107963. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107964. /**
  107965. * Returns the pixels data extracted from an RGBE texture.
  107966. * This pixels will be stored left to right up to down in the R G B order in one array.
  107967. *
  107968. * More information on this format are available here:
  107969. * https://en.wikipedia.org/wiki/RGBE_image_format
  107970. *
  107971. * @param uint8array The binary file stored in an array buffer.
  107972. * @param hdrInfo The header information of the file.
  107973. * @return The pixels data in RGB right to left up to down order.
  107974. */
  107975. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107976. private static RGBE_ReadPixels_RLE;
  107977. }
  107978. }
  107979. declare module BABYLON {
  107980. /**
  107981. * This represents a texture coming from an HDR input.
  107982. *
  107983. * The only supported format is currently panorama picture stored in RGBE format.
  107984. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107985. */
  107986. export class HDRCubeTexture extends BaseTexture {
  107987. private static _facesMapping;
  107988. private _generateHarmonics;
  107989. private _noMipmap;
  107990. private _textureMatrix;
  107991. private _size;
  107992. private _onLoad;
  107993. private _onError;
  107994. /**
  107995. * The texture URL.
  107996. */
  107997. url: string;
  107998. /**
  107999. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  108000. */
  108001. coordinatesMode: number;
  108002. protected _isBlocking: boolean;
  108003. /**
  108004. * Sets wether or not the texture is blocking during loading.
  108005. */
  108006. /**
  108007. * Gets wether or not the texture is blocking during loading.
  108008. */
  108009. isBlocking: boolean;
  108010. protected _rotationY: number;
  108011. /**
  108012. * Sets texture matrix rotation angle around Y axis in radians.
  108013. */
  108014. /**
  108015. * Gets texture matrix rotation angle around Y axis radians.
  108016. */
  108017. rotationY: number;
  108018. /**
  108019. * Gets or sets the center of the bounding box associated with the cube texture
  108020. * It must define where the camera used to render the texture was set
  108021. */
  108022. boundingBoxPosition: Vector3;
  108023. private _boundingBoxSize;
  108024. /**
  108025. * Gets or sets the size of the bounding box associated with the cube texture
  108026. * When defined, the cubemap will switch to local mode
  108027. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  108028. * @example https://www.babylonjs-playground.com/#RNASML
  108029. */
  108030. boundingBoxSize: Vector3;
  108031. /**
  108032. * Instantiates an HDRTexture from the following parameters.
  108033. *
  108034. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  108035. * @param scene The scene the texture will be used in
  108036. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108037. * @param noMipmap Forces to not generate the mipmap if true
  108038. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  108039. * @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)
  108040. * @param reserved Reserved flag for internal use.
  108041. */
  108042. 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>);
  108043. /**
  108044. * Get the current class name of the texture useful for serialization or dynamic coding.
  108045. * @returns "HDRCubeTexture"
  108046. */
  108047. getClassName(): string;
  108048. /**
  108049. * Occurs when the file is raw .hdr file.
  108050. */
  108051. private loadTexture;
  108052. clone(): HDRCubeTexture;
  108053. delayLoad(): void;
  108054. /**
  108055. * Get the texture reflection matrix used to rotate/transform the reflection.
  108056. * @returns the reflection matrix
  108057. */
  108058. getReflectionTextureMatrix(): Matrix;
  108059. /**
  108060. * Set the texture reflection matrix used to rotate/transform the reflection.
  108061. * @param value Define the reflection matrix to set
  108062. */
  108063. setReflectionTextureMatrix(value: Matrix): void;
  108064. /**
  108065. * Parses a JSON representation of an HDR Texture in order to create the texture
  108066. * @param parsedTexture Define the JSON representation
  108067. * @param scene Define the scene the texture should be created in
  108068. * @param rootUrl Define the root url in case we need to load relative dependencies
  108069. * @returns the newly created texture after parsing
  108070. */
  108071. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  108072. serialize(): any;
  108073. }
  108074. }
  108075. declare module BABYLON {
  108076. /**
  108077. * Class used to control physics engine
  108078. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108079. */
  108080. export class PhysicsEngine implements IPhysicsEngine {
  108081. private _physicsPlugin;
  108082. /**
  108083. * Global value used to control the smallest number supported by the simulation
  108084. */
  108085. static Epsilon: number;
  108086. private _impostors;
  108087. private _joints;
  108088. /**
  108089. * Gets the gravity vector used by the simulation
  108090. */
  108091. gravity: Vector3;
  108092. /**
  108093. * Factory used to create the default physics plugin.
  108094. * @returns The default physics plugin
  108095. */
  108096. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  108097. /**
  108098. * Creates a new Physics Engine
  108099. * @param gravity defines the gravity vector used by the simulation
  108100. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  108101. */
  108102. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  108103. /**
  108104. * Sets the gravity vector used by the simulation
  108105. * @param gravity defines the gravity vector to use
  108106. */
  108107. setGravity(gravity: Vector3): void;
  108108. /**
  108109. * Set the time step of the physics engine.
  108110. * Default is 1/60.
  108111. * To slow it down, enter 1/600 for example.
  108112. * To speed it up, 1/30
  108113. * @param newTimeStep defines the new timestep to apply to this world.
  108114. */
  108115. setTimeStep(newTimeStep?: number): void;
  108116. /**
  108117. * Get the time step of the physics engine.
  108118. * @returns the current time step
  108119. */
  108120. getTimeStep(): number;
  108121. /**
  108122. * Release all resources
  108123. */
  108124. dispose(): void;
  108125. /**
  108126. * Gets the name of the current physics plugin
  108127. * @returns the name of the plugin
  108128. */
  108129. getPhysicsPluginName(): string;
  108130. /**
  108131. * Adding a new impostor for the impostor tracking.
  108132. * This will be done by the impostor itself.
  108133. * @param impostor the impostor to add
  108134. */
  108135. addImpostor(impostor: PhysicsImpostor): void;
  108136. /**
  108137. * Remove an impostor from the engine.
  108138. * This impostor and its mesh will not longer be updated by the physics engine.
  108139. * @param impostor the impostor to remove
  108140. */
  108141. removeImpostor(impostor: PhysicsImpostor): void;
  108142. /**
  108143. * Add a joint to the physics engine
  108144. * @param mainImpostor defines the main impostor to which the joint is added.
  108145. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108146. * @param joint defines the joint that will connect both impostors.
  108147. */
  108148. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108149. /**
  108150. * Removes a joint from the simulation
  108151. * @param mainImpostor defines the impostor used with the joint
  108152. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108153. * @param joint defines the joint to remove
  108154. */
  108155. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108156. /**
  108157. * Called by the scene. No need to call it.
  108158. * @param delta defines the timespam between frames
  108159. */
  108160. _step(delta: number): void;
  108161. /**
  108162. * Gets the current plugin used to run the simulation
  108163. * @returns current plugin
  108164. */
  108165. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108166. /**
  108167. * Gets the list of physic impostors
  108168. * @returns an array of PhysicsImpostor
  108169. */
  108170. getImpostors(): Array<PhysicsImpostor>;
  108171. /**
  108172. * Gets the impostor for a physics enabled object
  108173. * @param object defines the object impersonated by the impostor
  108174. * @returns the PhysicsImpostor or null if not found
  108175. */
  108176. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108177. /**
  108178. * Gets the impostor for a physics body object
  108179. * @param body defines physics body used by the impostor
  108180. * @returns the PhysicsImpostor or null if not found
  108181. */
  108182. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108183. /**
  108184. * Does a raycast in the physics world
  108185. * @param from when should the ray start?
  108186. * @param to when should the ray end?
  108187. * @returns PhysicsRaycastResult
  108188. */
  108189. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108190. }
  108191. }
  108192. declare module BABYLON {
  108193. /** @hidden */
  108194. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  108195. private _useDeltaForWorldStep;
  108196. world: any;
  108197. name: string;
  108198. private _physicsMaterials;
  108199. private _fixedTimeStep;
  108200. private _cannonRaycastResult;
  108201. private _raycastResult;
  108202. private _removeAfterStep;
  108203. BJSCANNON: any;
  108204. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  108205. setGravity(gravity: Vector3): void;
  108206. setTimeStep(timeStep: number): void;
  108207. getTimeStep(): number;
  108208. executeStep(delta: number): void;
  108209. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108210. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108211. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108212. private _processChildMeshes;
  108213. removePhysicsBody(impostor: PhysicsImpostor): void;
  108214. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108215. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108216. private _addMaterial;
  108217. private _checkWithEpsilon;
  108218. private _createShape;
  108219. private _createHeightmap;
  108220. private _minus90X;
  108221. private _plus90X;
  108222. private _tmpPosition;
  108223. private _tmpDeltaPosition;
  108224. private _tmpUnityRotation;
  108225. private _updatePhysicsBodyTransformation;
  108226. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108227. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108228. isSupported(): boolean;
  108229. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108230. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108231. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108232. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108233. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108234. getBodyMass(impostor: PhysicsImpostor): number;
  108235. getBodyFriction(impostor: PhysicsImpostor): number;
  108236. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108237. getBodyRestitution(impostor: PhysicsImpostor): number;
  108238. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108239. sleepBody(impostor: PhysicsImpostor): void;
  108240. wakeUpBody(impostor: PhysicsImpostor): void;
  108241. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  108242. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108243. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108244. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108245. getRadius(impostor: PhysicsImpostor): number;
  108246. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108247. dispose(): void;
  108248. private _extendNamespace;
  108249. /**
  108250. * Does a raycast in the physics world
  108251. * @param from when should the ray start?
  108252. * @param to when should the ray end?
  108253. * @returns PhysicsRaycastResult
  108254. */
  108255. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108256. }
  108257. }
  108258. declare module BABYLON {
  108259. /** @hidden */
  108260. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  108261. world: any;
  108262. name: string;
  108263. BJSOIMO: any;
  108264. private _raycastResult;
  108265. constructor(iterations?: number, oimoInjection?: any);
  108266. setGravity(gravity: Vector3): void;
  108267. setTimeStep(timeStep: number): void;
  108268. getTimeStep(): number;
  108269. private _tmpImpostorsArray;
  108270. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108271. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108272. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108273. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108274. private _tmpPositionVector;
  108275. removePhysicsBody(impostor: PhysicsImpostor): void;
  108276. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108277. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108278. isSupported(): boolean;
  108279. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108280. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108281. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108282. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108283. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108284. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108285. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108286. getBodyMass(impostor: PhysicsImpostor): number;
  108287. getBodyFriction(impostor: PhysicsImpostor): number;
  108288. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108289. getBodyRestitution(impostor: PhysicsImpostor): number;
  108290. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108291. sleepBody(impostor: PhysicsImpostor): void;
  108292. wakeUpBody(impostor: PhysicsImpostor): void;
  108293. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108294. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  108295. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  108296. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108297. getRadius(impostor: PhysicsImpostor): number;
  108298. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108299. dispose(): void;
  108300. /**
  108301. * Does a raycast in the physics world
  108302. * @param from when should the ray start?
  108303. * @param to when should the ray end?
  108304. * @returns PhysicsRaycastResult
  108305. */
  108306. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108307. }
  108308. }
  108309. declare module BABYLON {
  108310. /**
  108311. * Class containing static functions to help procedurally build meshes
  108312. */
  108313. export class RibbonBuilder {
  108314. /**
  108315. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108316. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108317. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108318. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108319. * * 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
  108320. * * 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
  108321. * * 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
  108322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108323. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108324. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108325. * * 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
  108326. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108327. * * 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
  108328. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108330. * @param name defines the name of the mesh
  108331. * @param options defines the options used to create the mesh
  108332. * @param scene defines the hosting scene
  108333. * @returns the ribbon mesh
  108334. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108335. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108336. */
  108337. static CreateRibbon(name: string, options: {
  108338. pathArray: Vector3[][];
  108339. closeArray?: boolean;
  108340. closePath?: boolean;
  108341. offset?: number;
  108342. updatable?: boolean;
  108343. sideOrientation?: number;
  108344. frontUVs?: Vector4;
  108345. backUVs?: Vector4;
  108346. instance?: Mesh;
  108347. invertUV?: boolean;
  108348. uvs?: Vector2[];
  108349. colors?: Color4[];
  108350. }, scene?: Nullable<Scene>): Mesh;
  108351. }
  108352. }
  108353. declare module BABYLON {
  108354. /**
  108355. * Class containing static functions to help procedurally build meshes
  108356. */
  108357. export class ShapeBuilder {
  108358. /**
  108359. * 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.
  108360. * * 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.
  108361. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108362. * * 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.
  108363. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  108364. * * 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
  108365. * * 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
  108366. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  108367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108369. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108371. * @param name defines the name of the mesh
  108372. * @param options defines the options used to create the mesh
  108373. * @param scene defines the hosting scene
  108374. * @returns the extruded shape mesh
  108375. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108376. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108377. */
  108378. static ExtrudeShape(name: string, options: {
  108379. shape: Vector3[];
  108380. path: Vector3[];
  108381. scale?: number;
  108382. rotation?: number;
  108383. cap?: number;
  108384. updatable?: boolean;
  108385. sideOrientation?: number;
  108386. frontUVs?: Vector4;
  108387. backUVs?: Vector4;
  108388. instance?: Mesh;
  108389. invertUV?: boolean;
  108390. }, scene?: Nullable<Scene>): Mesh;
  108391. /**
  108392. * Creates an custom extruded shape mesh.
  108393. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  108394. * * 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.
  108395. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108396. * * 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
  108397. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  108398. * * 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
  108399. * * It must returns a float value that will be the scale value applied to the shape on each path point
  108400. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108401. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  108402. * * 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
  108403. * * 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
  108404. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  108405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108407. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108409. * @param name defines the name of the mesh
  108410. * @param options defines the options used to create the mesh
  108411. * @param scene defines the hosting scene
  108412. * @returns the custom extruded shape mesh
  108413. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  108414. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108415. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108416. */
  108417. static ExtrudeShapeCustom(name: string, options: {
  108418. shape: Vector3[];
  108419. path: Vector3[];
  108420. scaleFunction?: any;
  108421. rotationFunction?: any;
  108422. ribbonCloseArray?: boolean;
  108423. ribbonClosePath?: boolean;
  108424. cap?: number;
  108425. updatable?: boolean;
  108426. sideOrientation?: number;
  108427. frontUVs?: Vector4;
  108428. backUVs?: Vector4;
  108429. instance?: Mesh;
  108430. invertUV?: boolean;
  108431. }, scene?: Nullable<Scene>): Mesh;
  108432. private static _ExtrudeShapeGeneric;
  108433. }
  108434. }
  108435. declare module BABYLON {
  108436. /**
  108437. * AmmoJS Physics plugin
  108438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108439. * @see https://github.com/kripken/ammo.js/
  108440. */
  108441. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108442. private _useDeltaForWorldStep;
  108443. /**
  108444. * Reference to the Ammo library
  108445. */
  108446. bjsAMMO: any;
  108447. /**
  108448. * Created ammoJS world which physics bodies are added to
  108449. */
  108450. world: any;
  108451. /**
  108452. * Name of the plugin
  108453. */
  108454. name: string;
  108455. private _timeStep;
  108456. private _fixedTimeStep;
  108457. private _maxSteps;
  108458. private _tmpQuaternion;
  108459. private _tmpAmmoTransform;
  108460. private _tmpAmmoQuaternion;
  108461. private _tmpAmmoConcreteContactResultCallback;
  108462. private _collisionConfiguration;
  108463. private _dispatcher;
  108464. private _overlappingPairCache;
  108465. private _solver;
  108466. private _softBodySolver;
  108467. private _tmpAmmoVectorA;
  108468. private _tmpAmmoVectorB;
  108469. private _tmpAmmoVectorC;
  108470. private _tmpAmmoVectorD;
  108471. private _tmpContactCallbackResult;
  108472. private _tmpAmmoVectorRCA;
  108473. private _tmpAmmoVectorRCB;
  108474. private _raycastResult;
  108475. private static readonly DISABLE_COLLISION_FLAG;
  108476. private static readonly KINEMATIC_FLAG;
  108477. private static readonly DISABLE_DEACTIVATION_FLAG;
  108478. /**
  108479. * Initializes the ammoJS plugin
  108480. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108481. * @param ammoInjection can be used to inject your own ammo reference
  108482. */
  108483. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108484. /**
  108485. * Sets the gravity of the physics world (m/(s^2))
  108486. * @param gravity Gravity to set
  108487. */
  108488. setGravity(gravity: Vector3): void;
  108489. /**
  108490. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108491. * @param timeStep timestep to use in seconds
  108492. */
  108493. setTimeStep(timeStep: number): void;
  108494. /**
  108495. * 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)
  108496. * @param fixedTimeStep fixedTimeStep to use in seconds
  108497. */
  108498. setFixedTimeStep(fixedTimeStep: number): void;
  108499. /**
  108500. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108501. * @param maxSteps the maximum number of steps by the physics engine per frame
  108502. */
  108503. setMaxSteps(maxSteps: number): void;
  108504. /**
  108505. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108506. * @returns the current timestep in seconds
  108507. */
  108508. getTimeStep(): number;
  108509. private _isImpostorInContact;
  108510. private _isImpostorPairInContact;
  108511. private _stepSimulation;
  108512. /**
  108513. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108514. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108515. * After the step the babylon meshes are set to the position of the physics imposters
  108516. * @param delta amount of time to step forward
  108517. * @param impostors array of imposters to update before/after the step
  108518. */
  108519. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108520. /**
  108521. * Update babylon mesh to match physics world object
  108522. * @param impostor imposter to match
  108523. */
  108524. private _afterSoftStep;
  108525. /**
  108526. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108527. * @param impostor imposter to match
  108528. */
  108529. private _ropeStep;
  108530. /**
  108531. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108532. * @param impostor imposter to match
  108533. */
  108534. private _softbodyOrClothStep;
  108535. private _tmpVector;
  108536. private _tmpMatrix;
  108537. /**
  108538. * Applies an impulse on the imposter
  108539. * @param impostor imposter to apply impulse to
  108540. * @param force amount of force to be applied to the imposter
  108541. * @param contactPoint the location to apply the impulse on the imposter
  108542. */
  108543. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108544. /**
  108545. * Applies a force on the imposter
  108546. * @param impostor imposter to apply force
  108547. * @param force amount of force to be applied to the imposter
  108548. * @param contactPoint the location to apply the force on the imposter
  108549. */
  108550. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108551. /**
  108552. * Creates a physics body using the plugin
  108553. * @param impostor the imposter to create the physics body on
  108554. */
  108555. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108556. /**
  108557. * Removes the physics body from the imposter and disposes of the body's memory
  108558. * @param impostor imposter to remove the physics body from
  108559. */
  108560. removePhysicsBody(impostor: PhysicsImpostor): void;
  108561. /**
  108562. * Generates a joint
  108563. * @param impostorJoint the imposter joint to create the joint with
  108564. */
  108565. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108566. /**
  108567. * Removes a joint
  108568. * @param impostorJoint the imposter joint to remove the joint from
  108569. */
  108570. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108571. private _addMeshVerts;
  108572. /**
  108573. * Initialise the soft body vertices to match its object's (mesh) vertices
  108574. * Softbody vertices (nodes) are in world space and to match this
  108575. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108576. * @param impostor to create the softbody for
  108577. */
  108578. private _softVertexData;
  108579. /**
  108580. * Create an impostor's soft body
  108581. * @param impostor to create the softbody for
  108582. */
  108583. private _createSoftbody;
  108584. /**
  108585. * Create cloth for an impostor
  108586. * @param impostor to create the softbody for
  108587. */
  108588. private _createCloth;
  108589. /**
  108590. * Create rope for an impostor
  108591. * @param impostor to create the softbody for
  108592. */
  108593. private _createRope;
  108594. private _addHullVerts;
  108595. private _createShape;
  108596. /**
  108597. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108598. * @param impostor imposter containing the physics body and babylon object
  108599. */
  108600. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108601. /**
  108602. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108603. * @param impostor imposter containing the physics body and babylon object
  108604. * @param newPosition new position
  108605. * @param newRotation new rotation
  108606. */
  108607. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108608. /**
  108609. * If this plugin is supported
  108610. * @returns true if its supported
  108611. */
  108612. isSupported(): boolean;
  108613. /**
  108614. * Sets the linear velocity of the physics body
  108615. * @param impostor imposter to set the velocity on
  108616. * @param velocity velocity to set
  108617. */
  108618. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108619. /**
  108620. * Sets the angular velocity of the physics body
  108621. * @param impostor imposter to set the velocity on
  108622. * @param velocity velocity to set
  108623. */
  108624. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108625. /**
  108626. * gets the linear velocity
  108627. * @param impostor imposter to get linear velocity from
  108628. * @returns linear velocity
  108629. */
  108630. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108631. /**
  108632. * gets the angular velocity
  108633. * @param impostor imposter to get angular velocity from
  108634. * @returns angular velocity
  108635. */
  108636. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108637. /**
  108638. * Sets the mass of physics body
  108639. * @param impostor imposter to set the mass on
  108640. * @param mass mass to set
  108641. */
  108642. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108643. /**
  108644. * Gets the mass of the physics body
  108645. * @param impostor imposter to get the mass from
  108646. * @returns mass
  108647. */
  108648. getBodyMass(impostor: PhysicsImpostor): number;
  108649. /**
  108650. * Gets friction of the impostor
  108651. * @param impostor impostor to get friction from
  108652. * @returns friction value
  108653. */
  108654. getBodyFriction(impostor: PhysicsImpostor): number;
  108655. /**
  108656. * Sets friction of the impostor
  108657. * @param impostor impostor to set friction on
  108658. * @param friction friction value
  108659. */
  108660. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108661. /**
  108662. * Gets restitution of the impostor
  108663. * @param impostor impostor to get restitution from
  108664. * @returns restitution value
  108665. */
  108666. getBodyRestitution(impostor: PhysicsImpostor): number;
  108667. /**
  108668. * Sets resitution of the impostor
  108669. * @param impostor impostor to set resitution on
  108670. * @param restitution resitution value
  108671. */
  108672. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108673. /**
  108674. * Gets pressure inside the impostor
  108675. * @param impostor impostor to get pressure from
  108676. * @returns pressure value
  108677. */
  108678. getBodyPressure(impostor: PhysicsImpostor): number;
  108679. /**
  108680. * Sets pressure inside a soft body impostor
  108681. * Cloth and rope must remain 0 pressure
  108682. * @param impostor impostor to set pressure on
  108683. * @param pressure pressure value
  108684. */
  108685. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108686. /**
  108687. * Gets stiffness of the impostor
  108688. * @param impostor impostor to get stiffness from
  108689. * @returns pressure value
  108690. */
  108691. getBodyStiffness(impostor: PhysicsImpostor): number;
  108692. /**
  108693. * Sets stiffness of the impostor
  108694. * @param impostor impostor to set stiffness on
  108695. * @param stiffness stiffness value from 0 to 1
  108696. */
  108697. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108698. /**
  108699. * Gets velocityIterations of the impostor
  108700. * @param impostor impostor to get velocity iterations from
  108701. * @returns velocityIterations value
  108702. */
  108703. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108704. /**
  108705. * Sets velocityIterations of the impostor
  108706. * @param impostor impostor to set velocity iterations on
  108707. * @param velocityIterations velocityIterations value
  108708. */
  108709. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108710. /**
  108711. * Gets positionIterations of the impostor
  108712. * @param impostor impostor to get position iterations from
  108713. * @returns positionIterations value
  108714. */
  108715. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108716. /**
  108717. * Sets positionIterations of the impostor
  108718. * @param impostor impostor to set position on
  108719. * @param positionIterations positionIterations value
  108720. */
  108721. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108722. /**
  108723. * Append an anchor to a cloth object
  108724. * @param impostor is the cloth impostor to add anchor to
  108725. * @param otherImpostor is the rigid impostor to anchor to
  108726. * @param width ratio across width from 0 to 1
  108727. * @param height ratio up height from 0 to 1
  108728. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108729. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108730. */
  108731. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108732. /**
  108733. * Append an hook to a rope object
  108734. * @param impostor is the rope impostor to add hook to
  108735. * @param otherImpostor is the rigid impostor to hook to
  108736. * @param length ratio along the rope from 0 to 1
  108737. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108738. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108739. */
  108740. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108741. /**
  108742. * Sleeps the physics body and stops it from being active
  108743. * @param impostor impostor to sleep
  108744. */
  108745. sleepBody(impostor: PhysicsImpostor): void;
  108746. /**
  108747. * Activates the physics body
  108748. * @param impostor impostor to activate
  108749. */
  108750. wakeUpBody(impostor: PhysicsImpostor): void;
  108751. /**
  108752. * Updates the distance parameters of the joint
  108753. * @param joint joint to update
  108754. * @param maxDistance maximum distance of the joint
  108755. * @param minDistance minimum distance of the joint
  108756. */
  108757. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108758. /**
  108759. * Sets a motor on the joint
  108760. * @param joint joint to set motor on
  108761. * @param speed speed of the motor
  108762. * @param maxForce maximum force of the motor
  108763. * @param motorIndex index of the motor
  108764. */
  108765. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108766. /**
  108767. * Sets the motors limit
  108768. * @param joint joint to set limit on
  108769. * @param upperLimit upper limit
  108770. * @param lowerLimit lower limit
  108771. */
  108772. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108773. /**
  108774. * Syncs the position and rotation of a mesh with the impostor
  108775. * @param mesh mesh to sync
  108776. * @param impostor impostor to update the mesh with
  108777. */
  108778. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108779. /**
  108780. * Gets the radius of the impostor
  108781. * @param impostor impostor to get radius from
  108782. * @returns the radius
  108783. */
  108784. getRadius(impostor: PhysicsImpostor): number;
  108785. /**
  108786. * Gets the box size of the impostor
  108787. * @param impostor impostor to get box size from
  108788. * @param result the resulting box size
  108789. */
  108790. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108791. /**
  108792. * Disposes of the impostor
  108793. */
  108794. dispose(): void;
  108795. /**
  108796. * Does a raycast in the physics world
  108797. * @param from when should the ray start?
  108798. * @param to when should the ray end?
  108799. * @returns PhysicsRaycastResult
  108800. */
  108801. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108802. }
  108803. }
  108804. declare module BABYLON {
  108805. interface AbstractScene {
  108806. /**
  108807. * The list of reflection probes added to the scene
  108808. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108809. */
  108810. reflectionProbes: Array<ReflectionProbe>;
  108811. /**
  108812. * Removes the given reflection probe from this scene.
  108813. * @param toRemove The reflection probe to remove
  108814. * @returns The index of the removed reflection probe
  108815. */
  108816. removeReflectionProbe(toRemove: ReflectionProbe): number;
  108817. /**
  108818. * Adds the given reflection probe to this scene.
  108819. * @param newReflectionProbe The reflection probe to add
  108820. */
  108821. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  108822. }
  108823. /**
  108824. * Class used to generate realtime reflection / refraction cube textures
  108825. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108826. */
  108827. export class ReflectionProbe {
  108828. /** defines the name of the probe */
  108829. name: string;
  108830. private _scene;
  108831. private _renderTargetTexture;
  108832. private _projectionMatrix;
  108833. private _viewMatrix;
  108834. private _target;
  108835. private _add;
  108836. private _attachedMesh;
  108837. private _invertYAxis;
  108838. /** Gets or sets probe position (center of the cube map) */
  108839. position: Vector3;
  108840. /**
  108841. * Creates a new reflection probe
  108842. * @param name defines the name of the probe
  108843. * @param size defines the texture resolution (for each face)
  108844. * @param scene defines the hosting scene
  108845. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  108846. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  108847. */
  108848. constructor(
  108849. /** defines the name of the probe */
  108850. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  108851. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  108852. samples: number;
  108853. /** Gets or sets the refresh rate to use (on every frame by default) */
  108854. refreshRate: number;
  108855. /**
  108856. * Gets the hosting scene
  108857. * @returns a Scene
  108858. */
  108859. getScene(): Scene;
  108860. /** Gets the internal CubeTexture used to render to */
  108861. readonly cubeTexture: RenderTargetTexture;
  108862. /** Gets the list of meshes to render */
  108863. readonly renderList: Nullable<AbstractMesh[]>;
  108864. /**
  108865. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108866. * @param mesh defines the mesh to attach to
  108867. */
  108868. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108869. /**
  108870. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108871. * @param renderingGroupId The rendering group id corresponding to its index
  108872. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108873. */
  108874. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108875. /**
  108876. * Clean all associated resources
  108877. */
  108878. dispose(): void;
  108879. /**
  108880. * Converts the reflection probe information to a readable string for debug purpose.
  108881. * @param fullDetails Supports for multiple levels of logging within scene loading
  108882. * @returns the human readable reflection probe info
  108883. */
  108884. toString(fullDetails?: boolean): string;
  108885. /**
  108886. * Get the class name of the relfection probe.
  108887. * @returns "ReflectionProbe"
  108888. */
  108889. getClassName(): string;
  108890. /**
  108891. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108892. * @returns The JSON representation of the texture
  108893. */
  108894. serialize(): any;
  108895. /**
  108896. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108897. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108898. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108899. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108900. * @returns The parsed reflection probe if successful
  108901. */
  108902. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108903. }
  108904. }
  108905. declare module BABYLON {
  108906. /** @hidden */
  108907. export var _BabylonLoaderRegistered: boolean;
  108908. }
  108909. declare module BABYLON {
  108910. /**
  108911. * The Physically based simple base material of BJS.
  108912. *
  108913. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108914. * It is used as the base class for both the specGloss and metalRough conventions.
  108915. */
  108916. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108917. /**
  108918. * Number of Simultaneous lights allowed on the material.
  108919. */
  108920. maxSimultaneousLights: number;
  108921. /**
  108922. * If sets to true, disables all the lights affecting the material.
  108923. */
  108924. disableLighting: boolean;
  108925. /**
  108926. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108927. */
  108928. environmentTexture: BaseTexture;
  108929. /**
  108930. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108931. */
  108932. invertNormalMapX: boolean;
  108933. /**
  108934. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108935. */
  108936. invertNormalMapY: boolean;
  108937. /**
  108938. * Normal map used in the model.
  108939. */
  108940. normalTexture: BaseTexture;
  108941. /**
  108942. * Emissivie color used to self-illuminate the model.
  108943. */
  108944. emissiveColor: Color3;
  108945. /**
  108946. * Emissivie texture used to self-illuminate the model.
  108947. */
  108948. emissiveTexture: BaseTexture;
  108949. /**
  108950. * Occlusion Channel Strenght.
  108951. */
  108952. occlusionStrength: number;
  108953. /**
  108954. * Occlusion Texture of the material (adding extra occlusion effects).
  108955. */
  108956. occlusionTexture: BaseTexture;
  108957. /**
  108958. * Defines the alpha limits in alpha test mode.
  108959. */
  108960. alphaCutOff: number;
  108961. /**
  108962. * Gets the current double sided mode.
  108963. */
  108964. /**
  108965. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108966. */
  108967. doubleSided: boolean;
  108968. /**
  108969. * Stores the pre-calculated light information of a mesh in a texture.
  108970. */
  108971. lightmapTexture: BaseTexture;
  108972. /**
  108973. * If true, the light map contains occlusion information instead of lighting info.
  108974. */
  108975. useLightmapAsShadowmap: boolean;
  108976. /**
  108977. * Instantiates a new PBRMaterial instance.
  108978. *
  108979. * @param name The material name
  108980. * @param scene The scene the material will be use in.
  108981. */
  108982. constructor(name: string, scene: Scene);
  108983. getClassName(): string;
  108984. }
  108985. }
  108986. declare module BABYLON {
  108987. /**
  108988. * The PBR material of BJS following the metal roughness convention.
  108989. *
  108990. * This fits to the PBR convention in the GLTF definition:
  108991. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  108992. */
  108993. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  108994. /**
  108995. * The base color has two different interpretations depending on the value of metalness.
  108996. * When the material is a metal, the base color is the specific measured reflectance value
  108997. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  108998. * of the material.
  108999. */
  109000. baseColor: Color3;
  109001. /**
  109002. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  109003. * well as opacity information in the alpha channel.
  109004. */
  109005. baseTexture: BaseTexture;
  109006. /**
  109007. * Specifies the metallic scalar value of the material.
  109008. * Can also be used to scale the metalness values of the metallic texture.
  109009. */
  109010. metallic: number;
  109011. /**
  109012. * Specifies the roughness scalar value of the material.
  109013. * Can also be used to scale the roughness values of the metallic texture.
  109014. */
  109015. roughness: number;
  109016. /**
  109017. * Texture containing both the metallic value in the B channel and the
  109018. * roughness value in the G channel to keep better precision.
  109019. */
  109020. metallicRoughnessTexture: BaseTexture;
  109021. /**
  109022. * Instantiates a new PBRMetalRoughnessMaterial instance.
  109023. *
  109024. * @param name The material name
  109025. * @param scene The scene the material will be use in.
  109026. */
  109027. constructor(name: string, scene: Scene);
  109028. /**
  109029. * Return the currrent class name of the material.
  109030. */
  109031. getClassName(): string;
  109032. /**
  109033. * Makes a duplicate of the current material.
  109034. * @param name - name to use for the new material.
  109035. */
  109036. clone(name: string): PBRMetallicRoughnessMaterial;
  109037. /**
  109038. * Serialize the material to a parsable JSON object.
  109039. */
  109040. serialize(): any;
  109041. /**
  109042. * Parses a JSON object correponding to the serialize function.
  109043. */
  109044. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  109045. }
  109046. }
  109047. declare module BABYLON {
  109048. /**
  109049. * The PBR material of BJS following the specular glossiness convention.
  109050. *
  109051. * This fits to the PBR convention in the GLTF definition:
  109052. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  109053. */
  109054. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  109055. /**
  109056. * Specifies the diffuse color of the material.
  109057. */
  109058. diffuseColor: Color3;
  109059. /**
  109060. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  109061. * channel.
  109062. */
  109063. diffuseTexture: BaseTexture;
  109064. /**
  109065. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  109066. */
  109067. specularColor: Color3;
  109068. /**
  109069. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  109070. */
  109071. glossiness: number;
  109072. /**
  109073. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  109074. */
  109075. specularGlossinessTexture: BaseTexture;
  109076. /**
  109077. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  109078. *
  109079. * @param name The material name
  109080. * @param scene The scene the material will be use in.
  109081. */
  109082. constructor(name: string, scene: Scene);
  109083. /**
  109084. * Return the currrent class name of the material.
  109085. */
  109086. getClassName(): string;
  109087. /**
  109088. * Makes a duplicate of the current material.
  109089. * @param name - name to use for the new material.
  109090. */
  109091. clone(name: string): PBRSpecularGlossinessMaterial;
  109092. /**
  109093. * Serialize the material to a parsable JSON object.
  109094. */
  109095. serialize(): any;
  109096. /**
  109097. * Parses a JSON object correponding to the serialize function.
  109098. */
  109099. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  109100. }
  109101. }
  109102. declare module BABYLON {
  109103. /**
  109104. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  109105. * It can help converting any input color in a desired output one. This can then be used to create effects
  109106. * from sepia, black and white to sixties or futuristic rendering...
  109107. *
  109108. * The only supported format is currently 3dl.
  109109. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  109110. */
  109111. export class ColorGradingTexture extends BaseTexture {
  109112. /**
  109113. * The current texture matrix. (will always be identity in color grading texture)
  109114. */
  109115. private _textureMatrix;
  109116. /**
  109117. * The texture URL.
  109118. */
  109119. url: string;
  109120. /**
  109121. * Empty line regex stored for GC.
  109122. */
  109123. private static _noneEmptyLineRegex;
  109124. private _engine;
  109125. /**
  109126. * Instantiates a ColorGradingTexture from the following parameters.
  109127. *
  109128. * @param url The location of the color gradind data (currently only supporting 3dl)
  109129. * @param scene The scene the texture will be used in
  109130. */
  109131. constructor(url: string, scene: Scene);
  109132. /**
  109133. * Returns the texture matrix used in most of the material.
  109134. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  109135. */
  109136. getTextureMatrix(): Matrix;
  109137. /**
  109138. * Occurs when the file being loaded is a .3dl LUT file.
  109139. */
  109140. private load3dlTexture;
  109141. /**
  109142. * Starts the loading process of the texture.
  109143. */
  109144. private loadTexture;
  109145. /**
  109146. * Clones the color gradind texture.
  109147. */
  109148. clone(): ColorGradingTexture;
  109149. /**
  109150. * Called during delayed load for textures.
  109151. */
  109152. delayLoad(): void;
  109153. /**
  109154. * Parses a color grading texture serialized by Babylon.
  109155. * @param parsedTexture The texture information being parsedTexture
  109156. * @param scene The scene to load the texture in
  109157. * @param rootUrl The root url of the data assets to load
  109158. * @return A color gradind texture
  109159. */
  109160. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  109161. /**
  109162. * Serializes the LUT texture to json format.
  109163. */
  109164. serialize(): any;
  109165. }
  109166. }
  109167. declare module BABYLON {
  109168. /**
  109169. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  109170. */
  109171. export class EquiRectangularCubeTexture extends BaseTexture {
  109172. /** The six faces of the cube. */
  109173. private static _FacesMapping;
  109174. private _noMipmap;
  109175. private _onLoad;
  109176. private _onError;
  109177. /** The size of the cubemap. */
  109178. private _size;
  109179. /** The buffer of the image. */
  109180. private _buffer;
  109181. /** The width of the input image. */
  109182. private _width;
  109183. /** The height of the input image. */
  109184. private _height;
  109185. /** The URL to the image. */
  109186. url: string;
  109187. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  109188. coordinatesMode: number;
  109189. /**
  109190. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  109191. * @param url The location of the image
  109192. * @param scene The scene the texture will be used in
  109193. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  109194. * @param noMipmap Forces to not generate the mipmap if true
  109195. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  109196. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  109197. * @param onLoad — defines a callback called when texture is loaded
  109198. * @param onError — defines a callback called if there is an error
  109199. */
  109200. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  109201. /**
  109202. * Load the image data, by putting the image on a canvas and extracting its buffer.
  109203. */
  109204. private loadImage;
  109205. /**
  109206. * Convert the image buffer into a cubemap and create a CubeTexture.
  109207. */
  109208. private loadTexture;
  109209. /**
  109210. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  109211. * @param buffer The ArrayBuffer that should be converted.
  109212. * @returns The buffer as Float32Array.
  109213. */
  109214. private getFloat32ArrayFromArrayBuffer;
  109215. /**
  109216. * Get the current class name of the texture useful for serialization or dynamic coding.
  109217. * @returns "EquiRectangularCubeTexture"
  109218. */
  109219. getClassName(): string;
  109220. /**
  109221. * Create a clone of the current EquiRectangularCubeTexture and return it.
  109222. * @returns A clone of the current EquiRectangularCubeTexture.
  109223. */
  109224. clone(): EquiRectangularCubeTexture;
  109225. }
  109226. }
  109227. declare module BABYLON {
  109228. /**
  109229. * Based on jsTGALoader - Javascript loader for TGA file
  109230. * By Vincent Thibault
  109231. * @see http://blog.robrowser.com/javascript-tga-loader.html
  109232. */
  109233. export class TGATools {
  109234. private static _TYPE_INDEXED;
  109235. private static _TYPE_RGB;
  109236. private static _TYPE_GREY;
  109237. private static _TYPE_RLE_INDEXED;
  109238. private static _TYPE_RLE_RGB;
  109239. private static _TYPE_RLE_GREY;
  109240. private static _ORIGIN_MASK;
  109241. private static _ORIGIN_SHIFT;
  109242. private static _ORIGIN_BL;
  109243. private static _ORIGIN_BR;
  109244. private static _ORIGIN_UL;
  109245. private static _ORIGIN_UR;
  109246. /**
  109247. * Gets the header of a TGA file
  109248. * @param data defines the TGA data
  109249. * @returns the header
  109250. */
  109251. static GetTGAHeader(data: Uint8Array): any;
  109252. /**
  109253. * Uploads TGA content to a Babylon Texture
  109254. * @hidden
  109255. */
  109256. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  109257. /** @hidden */
  109258. 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;
  109259. /** @hidden */
  109260. 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;
  109261. /** @hidden */
  109262. 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;
  109263. /** @hidden */
  109264. 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;
  109265. /** @hidden */
  109266. 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;
  109267. /** @hidden */
  109268. 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;
  109269. }
  109270. }
  109271. declare module BABYLON {
  109272. /**
  109273. * Implementation of the TGA Texture Loader.
  109274. * @hidden
  109275. */
  109276. export class _TGATextureLoader implements IInternalTextureLoader {
  109277. /**
  109278. * Defines wether the loader supports cascade loading the different faces.
  109279. */
  109280. readonly supportCascades: boolean;
  109281. /**
  109282. * This returns if the loader support the current file information.
  109283. * @param extension defines the file extension of the file being loaded
  109284. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109285. * @param fallback defines the fallback internal texture if any
  109286. * @param isBase64 defines whether the texture is encoded as a base64
  109287. * @param isBuffer defines whether the texture data are stored as a buffer
  109288. * @returns true if the loader can load the specified file
  109289. */
  109290. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109291. /**
  109292. * Transform the url before loading if required.
  109293. * @param rootUrl the url of the texture
  109294. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109295. * @returns the transformed texture
  109296. */
  109297. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109298. /**
  109299. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109300. * @param rootUrl the url of the texture
  109301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109302. * @returns the fallback texture
  109303. */
  109304. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109305. /**
  109306. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109307. * @param data contains the texture data
  109308. * @param texture defines the BabylonJS internal texture
  109309. * @param createPolynomials will be true if polynomials have been requested
  109310. * @param onLoad defines the callback to trigger once the texture is ready
  109311. * @param onError defines the callback to trigger in case of error
  109312. */
  109313. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109314. /**
  109315. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109316. * @param data contains the texture data
  109317. * @param texture defines the BabylonJS internal texture
  109318. * @param callback defines the method to call once ready to upload
  109319. */
  109320. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109321. }
  109322. }
  109323. declare module BABYLON {
  109324. /**
  109325. * 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.
  109326. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109327. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109328. */
  109329. export class CustomProceduralTexture extends ProceduralTexture {
  109330. private _animate;
  109331. private _time;
  109332. private _config;
  109333. private _texturePath;
  109334. /**
  109335. * Instantiates a new Custom Procedural Texture.
  109336. * 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.
  109337. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109338. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109339. * @param name Define the name of the texture
  109340. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  109341. * @param size Define the size of the texture to create
  109342. * @param scene Define the scene the texture belongs to
  109343. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  109344. * @param generateMipMaps Define if the texture should creates mip maps or not
  109345. */
  109346. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109347. private _loadJson;
  109348. /**
  109349. * Is the texture ready to be used ? (rendered at least once)
  109350. * @returns true if ready, otherwise, false.
  109351. */
  109352. isReady(): boolean;
  109353. /**
  109354. * Render the texture to its associated render target.
  109355. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  109356. */
  109357. render(useCameraPostProcess?: boolean): void;
  109358. /**
  109359. * Update the list of dependant textures samplers in the shader.
  109360. */
  109361. updateTextures(): void;
  109362. /**
  109363. * Update the uniform values of the procedural texture in the shader.
  109364. */
  109365. updateShaderUniforms(): void;
  109366. /**
  109367. * Define if the texture animates or not.
  109368. */
  109369. animate: boolean;
  109370. }
  109371. }
  109372. declare module BABYLON {
  109373. /** @hidden */
  109374. export var noisePixelShader: {
  109375. name: string;
  109376. shader: string;
  109377. };
  109378. }
  109379. declare module BABYLON {
  109380. /**
  109381. * Class used to generate noise procedural textures
  109382. */
  109383. export class NoiseProceduralTexture extends ProceduralTexture {
  109384. private _time;
  109385. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  109386. brightness: number;
  109387. /** Defines the number of octaves to process */
  109388. octaves: number;
  109389. /** Defines the level of persistence (0.8 by default) */
  109390. persistence: number;
  109391. /** Gets or sets animation speed factor (default is 1) */
  109392. animationSpeedFactor: number;
  109393. /**
  109394. * Creates a new NoiseProceduralTexture
  109395. * @param name defines the name fo the texture
  109396. * @param size defines the size of the texture (default is 256)
  109397. * @param scene defines the hosting scene
  109398. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  109399. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  109400. */
  109401. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109402. private _updateShaderUniforms;
  109403. protected _getDefines(): string;
  109404. /** Generate the current state of the procedural texture */
  109405. render(useCameraPostProcess?: boolean): void;
  109406. /**
  109407. * Serializes this noise procedural texture
  109408. * @returns a serialized noise procedural texture object
  109409. */
  109410. serialize(): any;
  109411. /**
  109412. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  109413. * @param parsedTexture defines parsed texture data
  109414. * @param scene defines the current scene
  109415. * @param rootUrl defines the root URL containing noise procedural texture information
  109416. * @returns a parsed NoiseProceduralTexture
  109417. */
  109418. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  109419. }
  109420. }
  109421. declare module BABYLON {
  109422. /**
  109423. * Raw cube texture where the raw buffers are passed in
  109424. */
  109425. export class RawCubeTexture extends CubeTexture {
  109426. /**
  109427. * Creates a cube texture where the raw buffers are passed in.
  109428. * @param scene defines the scene the texture is attached to
  109429. * @param data defines the array of data to use to create each face
  109430. * @param size defines the size of the textures
  109431. * @param format defines the format of the data
  109432. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  109433. * @param generateMipMaps defines if the engine should generate the mip levels
  109434. * @param invertY defines if data must be stored with Y axis inverted
  109435. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  109436. * @param compression defines the compression used (null by default)
  109437. */
  109438. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  109439. /**
  109440. * Updates the raw cube texture.
  109441. * @param data defines the data to store
  109442. * @param format defines the data format
  109443. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109444. * @param invertY defines if data must be stored with Y axis inverted
  109445. * @param compression defines the compression used (null by default)
  109446. * @param level defines which level of the texture to update
  109447. */
  109448. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  109449. /**
  109450. * Updates a raw cube texture with RGBD encoded data.
  109451. * @param data defines the array of data [mipmap][face] to use to create each face
  109452. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  109453. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109454. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109455. * @returns a promsie that resolves when the operation is complete
  109456. */
  109457. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  109458. /**
  109459. * Clones the raw cube texture.
  109460. * @return a new cube texture
  109461. */
  109462. clone(): CubeTexture;
  109463. /** @hidden */
  109464. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109465. }
  109466. }
  109467. declare module BABYLON {
  109468. /**
  109469. * Class used to store 3D textures containing user data
  109470. */
  109471. export class RawTexture3D extends Texture {
  109472. /** Gets or sets the texture format to use */
  109473. format: number;
  109474. private _engine;
  109475. /**
  109476. * Create a new RawTexture3D
  109477. * @param data defines the data of the texture
  109478. * @param width defines the width of the texture
  109479. * @param height defines the height of the texture
  109480. * @param depth defines the depth of the texture
  109481. * @param format defines the texture format to use
  109482. * @param scene defines the hosting scene
  109483. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  109484. * @param invertY defines if texture must be stored with Y axis inverted
  109485. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109486. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  109487. */
  109488. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  109489. /** Gets or sets the texture format to use */
  109490. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  109491. /**
  109492. * Update the texture with new data
  109493. * @param data defines the data to store in the texture
  109494. */
  109495. update(data: ArrayBufferView): void;
  109496. }
  109497. }
  109498. declare module BABYLON {
  109499. /**
  109500. * Creates a refraction texture used by refraction channel of the standard material.
  109501. * It is like a mirror but to see through a material.
  109502. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109503. */
  109504. export class RefractionTexture extends RenderTargetTexture {
  109505. /**
  109506. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  109507. * 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.
  109508. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109509. */
  109510. refractionPlane: Plane;
  109511. /**
  109512. * Define how deep under the surface we should see.
  109513. */
  109514. depth: number;
  109515. /**
  109516. * Creates a refraction texture used by refraction channel of the standard material.
  109517. * It is like a mirror but to see through a material.
  109518. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109519. * @param name Define the texture name
  109520. * @param size Define the size of the underlying texture
  109521. * @param scene Define the scene the refraction belongs to
  109522. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109523. */
  109524. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109525. /**
  109526. * Clone the refraction texture.
  109527. * @returns the cloned texture
  109528. */
  109529. clone(): RefractionTexture;
  109530. /**
  109531. * Serialize the texture to a JSON representation you could use in Parse later on
  109532. * @returns the serialized JSON representation
  109533. */
  109534. serialize(): any;
  109535. }
  109536. }
  109537. declare module BABYLON {
  109538. /**
  109539. * Defines the options related to the creation of an HtmlElementTexture
  109540. */
  109541. export interface IHtmlElementTextureOptions {
  109542. /**
  109543. * Defines wether mip maps should be created or not.
  109544. */
  109545. generateMipMaps?: boolean;
  109546. /**
  109547. * Defines the sampling mode of the texture.
  109548. */
  109549. samplingMode?: number;
  109550. /**
  109551. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109552. */
  109553. engine: Nullable<Engine>;
  109554. /**
  109555. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109556. */
  109557. scene: Nullable<Scene>;
  109558. }
  109559. /**
  109560. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109561. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109562. * is automatically managed.
  109563. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109564. * in your application.
  109565. *
  109566. * As the update is not automatic, you need to call them manually.
  109567. */
  109568. export class HtmlElementTexture extends BaseTexture {
  109569. /**
  109570. * The texture URL.
  109571. */
  109572. element: HTMLVideoElement | HTMLCanvasElement;
  109573. private static readonly DefaultOptions;
  109574. private _textureMatrix;
  109575. private _engine;
  109576. private _isVideo;
  109577. private _generateMipMaps;
  109578. private _samplingMode;
  109579. /**
  109580. * Instantiates a HtmlElementTexture from the following parameters.
  109581. *
  109582. * @param name Defines the name of the texture
  109583. * @param element Defines the video or canvas the texture is filled with
  109584. * @param options Defines the other none mandatory texture creation options
  109585. */
  109586. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109587. private _createInternalTexture;
  109588. /**
  109589. * Returns the texture matrix used in most of the material.
  109590. */
  109591. getTextureMatrix(): Matrix;
  109592. /**
  109593. * Updates the content of the texture.
  109594. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109595. */
  109596. update(invertY?: Nullable<boolean>): void;
  109597. }
  109598. }
  109599. declare module BABYLON {
  109600. /**
  109601. * Helper class to push actions to a pool of workers.
  109602. */
  109603. export class WorkerPool implements IDisposable {
  109604. private _workerInfos;
  109605. private _pendingActions;
  109606. /**
  109607. * Constructor
  109608. * @param workers Array of workers to use for actions
  109609. */
  109610. constructor(workers: Array<Worker>);
  109611. /**
  109612. * Terminates all workers and clears any pending actions.
  109613. */
  109614. dispose(): void;
  109615. /**
  109616. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109617. * pended until a worker has completed its action.
  109618. * @param action The action to perform. Call onComplete when the action is complete.
  109619. */
  109620. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109621. private _execute;
  109622. }
  109623. }
  109624. declare module BABYLON {
  109625. /**
  109626. * Configuration for Draco compression
  109627. */
  109628. export interface IDracoCompressionConfiguration {
  109629. /**
  109630. * Configuration for the decoder.
  109631. */
  109632. decoder?: {
  109633. /**
  109634. * The url to the WebAssembly module.
  109635. */
  109636. wasmUrl?: string;
  109637. /**
  109638. * The url to the WebAssembly binary.
  109639. */
  109640. wasmBinaryUrl?: string;
  109641. /**
  109642. * The url to the fallback JavaScript module.
  109643. */
  109644. fallbackUrl?: string;
  109645. };
  109646. }
  109647. /**
  109648. * Draco compression (https://google.github.io/draco/)
  109649. *
  109650. * This class wraps the Draco module.
  109651. *
  109652. * **Encoder**
  109653. *
  109654. * The encoder is not currently implemented.
  109655. *
  109656. * **Decoder**
  109657. *
  109658. * 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.
  109659. *
  109660. * To update the configuration, use the following code:
  109661. * ```javascript
  109662. * DracoCompression.Configuration = {
  109663. * decoder: {
  109664. * wasmUrl: "<url to the WebAssembly library>",
  109665. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109666. * fallbackUrl: "<url to the fallback JavaScript library>",
  109667. * }
  109668. * };
  109669. * ```
  109670. *
  109671. * 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.
  109672. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109673. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  109674. *
  109675. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  109676. * ```javascript
  109677. * var dracoCompression = new DracoCompression();
  109678. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  109679. * [VertexBuffer.PositionKind]: 0
  109680. * });
  109681. * ```
  109682. *
  109683. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109684. */
  109685. export class DracoCompression implements IDisposable {
  109686. private _workerPoolPromise;
  109687. /**
  109688. * The configuration. Defaults to the following urls:
  109689. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109690. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109691. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109692. */
  109693. static Configuration: IDracoCompressionConfiguration;
  109694. /**
  109695. * Returns true if the decoder is available.
  109696. */
  109697. static readonly DecoderAvailable: boolean;
  109698. /**
  109699. * Default number of workers to create when creating the draco compression object.
  109700. */
  109701. static DefaultNumWorkers: number;
  109702. private static GetDefaultNumWorkers;
  109703. /**
  109704. * Constructor
  109705. * @param numWorkers The number of workers for async operations
  109706. */
  109707. constructor(numWorkers?: number);
  109708. /**
  109709. * Stop all async operations and release resources.
  109710. */
  109711. dispose(): void;
  109712. /**
  109713. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109714. * @returns a promise that resolves when ready
  109715. */
  109716. whenReadyAsync(): Promise<void>;
  109717. /**
  109718. * Decode Draco compressed mesh data to vertex data.
  109719. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109720. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109721. * @returns A promise that resolves with the decoded vertex data
  109722. */
  109723. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109724. [kind: string]: number;
  109725. }): Promise<VertexData>;
  109726. /**
  109727. * The worker function that gets converted to a blob url to pass into a worker.
  109728. */
  109729. private static _Worker;
  109730. private _loadDecoderWasmBinaryAsync;
  109731. }
  109732. }
  109733. declare module BABYLON {
  109734. /**
  109735. * Class for building Constructive Solid Geometry
  109736. */
  109737. export class CSG {
  109738. private polygons;
  109739. /**
  109740. * The world matrix
  109741. */
  109742. matrix: Matrix;
  109743. /**
  109744. * Stores the position
  109745. */
  109746. position: Vector3;
  109747. /**
  109748. * Stores the rotation
  109749. */
  109750. rotation: Vector3;
  109751. /**
  109752. * Stores the rotation quaternion
  109753. */
  109754. rotationQuaternion: Nullable<Quaternion>;
  109755. /**
  109756. * Stores the scaling vector
  109757. */
  109758. scaling: Vector3;
  109759. /**
  109760. * Convert the Mesh to CSG
  109761. * @param mesh The Mesh to convert to CSG
  109762. * @returns A new CSG from the Mesh
  109763. */
  109764. static FromMesh(mesh: Mesh): CSG;
  109765. /**
  109766. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109767. * @param polygons Polygons used to construct a CSG solid
  109768. */
  109769. private static FromPolygons;
  109770. /**
  109771. * Clones, or makes a deep copy, of the CSG
  109772. * @returns A new CSG
  109773. */
  109774. clone(): CSG;
  109775. /**
  109776. * Unions this CSG with another CSG
  109777. * @param csg The CSG to union against this CSG
  109778. * @returns The unioned CSG
  109779. */
  109780. union(csg: CSG): CSG;
  109781. /**
  109782. * Unions this CSG with another CSG in place
  109783. * @param csg The CSG to union against this CSG
  109784. */
  109785. unionInPlace(csg: CSG): void;
  109786. /**
  109787. * Subtracts this CSG with another CSG
  109788. * @param csg The CSG to subtract against this CSG
  109789. * @returns A new CSG
  109790. */
  109791. subtract(csg: CSG): CSG;
  109792. /**
  109793. * Subtracts this CSG with another CSG in place
  109794. * @param csg The CSG to subtact against this CSG
  109795. */
  109796. subtractInPlace(csg: CSG): void;
  109797. /**
  109798. * Intersect this CSG with another CSG
  109799. * @param csg The CSG to intersect against this CSG
  109800. * @returns A new CSG
  109801. */
  109802. intersect(csg: CSG): CSG;
  109803. /**
  109804. * Intersects this CSG with another CSG in place
  109805. * @param csg The CSG to intersect against this CSG
  109806. */
  109807. intersectInPlace(csg: CSG): void;
  109808. /**
  109809. * Return a new CSG solid with solid and empty space switched. This solid is
  109810. * not modified.
  109811. * @returns A new CSG solid with solid and empty space switched
  109812. */
  109813. inverse(): CSG;
  109814. /**
  109815. * Inverses the CSG in place
  109816. */
  109817. inverseInPlace(): void;
  109818. /**
  109819. * This is used to keep meshes transformations so they can be restored
  109820. * when we build back a Babylon Mesh
  109821. * NB : All CSG operations are performed in world coordinates
  109822. * @param csg The CSG to copy the transform attributes from
  109823. * @returns This CSG
  109824. */
  109825. copyTransformAttributes(csg: CSG): CSG;
  109826. /**
  109827. * Build Raw mesh from CSG
  109828. * Coordinates here are in world space
  109829. * @param name The name of the mesh geometry
  109830. * @param scene The Scene
  109831. * @param keepSubMeshes Specifies if the submeshes should be kept
  109832. * @returns A new Mesh
  109833. */
  109834. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  109835. /**
  109836. * Build Mesh from CSG taking material and transforms into account
  109837. * @param name The name of the Mesh
  109838. * @param material The material of the Mesh
  109839. * @param scene The Scene
  109840. * @param keepSubMeshes Specifies if submeshes should be kept
  109841. * @returns The new Mesh
  109842. */
  109843. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  109844. }
  109845. }
  109846. declare module BABYLON {
  109847. /**
  109848. * Class used to create a trail following a mesh
  109849. */
  109850. export class TrailMesh extends Mesh {
  109851. private _generator;
  109852. private _autoStart;
  109853. private _running;
  109854. private _diameter;
  109855. private _length;
  109856. private _sectionPolygonPointsCount;
  109857. private _sectionVectors;
  109858. private _sectionNormalVectors;
  109859. private _beforeRenderObserver;
  109860. /**
  109861. * @constructor
  109862. * @param name The value used by scene.getMeshByName() to do a lookup.
  109863. * @param generator The mesh to generate a trail.
  109864. * @param scene The scene to add this mesh to.
  109865. * @param diameter Diameter of trailing mesh. Default is 1.
  109866. * @param length Length of trailing mesh. Default is 60.
  109867. * @param autoStart Automatically start trailing mesh. Default true.
  109868. */
  109869. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  109870. /**
  109871. * "TrailMesh"
  109872. * @returns "TrailMesh"
  109873. */
  109874. getClassName(): string;
  109875. private _createMesh;
  109876. /**
  109877. * Start trailing mesh.
  109878. */
  109879. start(): void;
  109880. /**
  109881. * Stop trailing mesh.
  109882. */
  109883. stop(): void;
  109884. /**
  109885. * Update trailing mesh geometry.
  109886. */
  109887. update(): void;
  109888. /**
  109889. * Returns a new TrailMesh object.
  109890. * @param name is a string, the name given to the new mesh
  109891. * @param newGenerator use new generator object for cloned trail mesh
  109892. * @returns a new mesh
  109893. */
  109894. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  109895. /**
  109896. * Serializes this trail mesh
  109897. * @param serializationObject object to write serialization to
  109898. */
  109899. serialize(serializationObject: any): void;
  109900. /**
  109901. * Parses a serialized trail mesh
  109902. * @param parsedMesh the serialized mesh
  109903. * @param scene the scene to create the trail mesh in
  109904. * @returns the created trail mesh
  109905. */
  109906. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  109907. }
  109908. }
  109909. declare module BABYLON {
  109910. /**
  109911. * Class containing static functions to help procedurally build meshes
  109912. */
  109913. export class TorusKnotBuilder {
  109914. /**
  109915. * Creates a torus knot mesh
  109916. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109917. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109918. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109919. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109923. * @param name defines the name of the mesh
  109924. * @param options defines the options used to create the mesh
  109925. * @param scene defines the hosting scene
  109926. * @returns the torus knot mesh
  109927. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109928. */
  109929. static CreateTorusKnot(name: string, options: {
  109930. radius?: number;
  109931. tube?: number;
  109932. radialSegments?: number;
  109933. tubularSegments?: number;
  109934. p?: number;
  109935. q?: number;
  109936. updatable?: boolean;
  109937. sideOrientation?: number;
  109938. frontUVs?: Vector4;
  109939. backUVs?: Vector4;
  109940. }, scene: any): Mesh;
  109941. }
  109942. }
  109943. declare module BABYLON {
  109944. /**
  109945. * Polygon
  109946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109947. */
  109948. export class Polygon {
  109949. /**
  109950. * Creates a rectangle
  109951. * @param xmin bottom X coord
  109952. * @param ymin bottom Y coord
  109953. * @param xmax top X coord
  109954. * @param ymax top Y coord
  109955. * @returns points that make the resulting rectation
  109956. */
  109957. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109958. /**
  109959. * Creates a circle
  109960. * @param radius radius of circle
  109961. * @param cx scale in x
  109962. * @param cy scale in y
  109963. * @param numberOfSides number of sides that make up the circle
  109964. * @returns points that make the resulting circle
  109965. */
  109966. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109967. /**
  109968. * Creates a polygon from input string
  109969. * @param input Input polygon data
  109970. * @returns the parsed points
  109971. */
  109972. static Parse(input: string): Vector2[];
  109973. /**
  109974. * Starts building a polygon from x and y coordinates
  109975. * @param x x coordinate
  109976. * @param y y coordinate
  109977. * @returns the started path2
  109978. */
  109979. static StartingAt(x: number, y: number): Path2;
  109980. }
  109981. /**
  109982. * Builds a polygon
  109983. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  109984. */
  109985. export class PolygonMeshBuilder {
  109986. private _points;
  109987. private _outlinepoints;
  109988. private _holes;
  109989. private _name;
  109990. private _scene;
  109991. private _epoints;
  109992. private _eholes;
  109993. private _addToepoint;
  109994. /**
  109995. * Babylon reference to the earcut plugin.
  109996. */
  109997. bjsEarcut: any;
  109998. /**
  109999. * Creates a PolygonMeshBuilder
  110000. * @param name name of the builder
  110001. * @param contours Path of the polygon
  110002. * @param scene scene to add to when creating the mesh
  110003. * @param earcutInjection can be used to inject your own earcut reference
  110004. */
  110005. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  110006. /**
  110007. * Adds a whole within the polygon
  110008. * @param hole Array of points defining the hole
  110009. * @returns this
  110010. */
  110011. addHole(hole: Vector2[]): PolygonMeshBuilder;
  110012. /**
  110013. * Creates the polygon
  110014. * @param updatable If the mesh should be updatable
  110015. * @param depth The depth of the mesh created
  110016. * @returns the created mesh
  110017. */
  110018. build(updatable?: boolean, depth?: number): Mesh;
  110019. /**
  110020. * Creates the polygon
  110021. * @param depth The depth of the mesh created
  110022. * @returns the created VertexData
  110023. */
  110024. buildVertexData(depth?: number): VertexData;
  110025. /**
  110026. * Adds a side to the polygon
  110027. * @param positions points that make the polygon
  110028. * @param normals normals of the polygon
  110029. * @param uvs uvs of the polygon
  110030. * @param indices indices of the polygon
  110031. * @param bounds bounds of the polygon
  110032. * @param points points of the polygon
  110033. * @param depth depth of the polygon
  110034. * @param flip flip of the polygon
  110035. */
  110036. private addSide;
  110037. }
  110038. }
  110039. declare module BABYLON {
  110040. /**
  110041. * Class containing static functions to help procedurally build meshes
  110042. */
  110043. export class PolygonBuilder {
  110044. /**
  110045. * Creates a polygon mesh
  110046. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110047. * * 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
  110048. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110050. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110051. * * Remember you can only change the shape positions, not their number when updating a polygon
  110052. * @param name defines the name of the mesh
  110053. * @param options defines the options used to create the mesh
  110054. * @param scene defines the hosting scene
  110055. * @param earcutInjection can be used to inject your own earcut reference
  110056. * @returns the polygon mesh
  110057. */
  110058. static CreatePolygon(name: string, options: {
  110059. shape: Vector3[];
  110060. holes?: Vector3[][];
  110061. depth?: number;
  110062. faceUV?: Vector4[];
  110063. faceColors?: Color4[];
  110064. updatable?: boolean;
  110065. sideOrientation?: number;
  110066. frontUVs?: Vector4;
  110067. backUVs?: Vector4;
  110068. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110069. /**
  110070. * Creates an extruded polygon mesh, with depth in the Y direction.
  110071. * * 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)
  110072. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110073. * @param name defines the name of the mesh
  110074. * @param options defines the options used to create the mesh
  110075. * @param scene defines the hosting scene
  110076. * @param earcutInjection can be used to inject your own earcut reference
  110077. * @returns the polygon mesh
  110078. */
  110079. static ExtrudePolygon(name: string, options: {
  110080. shape: Vector3[];
  110081. holes?: Vector3[][];
  110082. depth?: number;
  110083. faceUV?: Vector4[];
  110084. faceColors?: Color4[];
  110085. updatable?: boolean;
  110086. sideOrientation?: number;
  110087. frontUVs?: Vector4;
  110088. backUVs?: Vector4;
  110089. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110090. }
  110091. }
  110092. declare module BABYLON {
  110093. /**
  110094. * Class containing static functions to help procedurally build meshes
  110095. */
  110096. export class LatheBuilder {
  110097. /**
  110098. * Creates lathe mesh.
  110099. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110100. * * 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
  110101. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110102. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110103. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110104. * * 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
  110105. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110106. * * 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
  110107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110109. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110111. * @param name defines the name of the mesh
  110112. * @param options defines the options used to create the mesh
  110113. * @param scene defines the hosting scene
  110114. * @returns the lathe mesh
  110115. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110116. */
  110117. static CreateLathe(name: string, options: {
  110118. shape: Vector3[];
  110119. radius?: number;
  110120. tessellation?: number;
  110121. clip?: number;
  110122. arc?: number;
  110123. closed?: boolean;
  110124. updatable?: boolean;
  110125. sideOrientation?: number;
  110126. frontUVs?: Vector4;
  110127. backUVs?: Vector4;
  110128. cap?: number;
  110129. invertUV?: boolean;
  110130. }, scene?: Nullable<Scene>): Mesh;
  110131. }
  110132. }
  110133. declare module BABYLON {
  110134. /**
  110135. * Class containing static functions to help procedurally build meshes
  110136. */
  110137. export class TubeBuilder {
  110138. /**
  110139. * Creates a tube mesh.
  110140. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110141. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110142. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110143. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110144. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110145. * * 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)
  110146. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110147. * * 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
  110148. * * 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
  110149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110151. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110153. * @param name defines the name of the mesh
  110154. * @param options defines the options used to create the mesh
  110155. * @param scene defines the hosting scene
  110156. * @returns the tube mesh
  110157. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110158. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110159. */
  110160. static CreateTube(name: string, options: {
  110161. path: Vector3[];
  110162. radius?: number;
  110163. tessellation?: number;
  110164. radiusFunction?: {
  110165. (i: number, distance: number): number;
  110166. };
  110167. cap?: number;
  110168. arc?: number;
  110169. updatable?: boolean;
  110170. sideOrientation?: number;
  110171. frontUVs?: Vector4;
  110172. backUVs?: Vector4;
  110173. instance?: Mesh;
  110174. invertUV?: boolean;
  110175. }, scene?: Nullable<Scene>): Mesh;
  110176. }
  110177. }
  110178. declare module BABYLON {
  110179. /**
  110180. * Class containing static functions to help procedurally build meshes
  110181. */
  110182. export class IcoSphereBuilder {
  110183. /**
  110184. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110185. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110186. * * 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`)
  110187. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110188. * * 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
  110189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110192. * @param name defines the name of the mesh
  110193. * @param options defines the options used to create the mesh
  110194. * @param scene defines the hosting scene
  110195. * @returns the icosahedron mesh
  110196. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110197. */
  110198. static CreateIcoSphere(name: string, options: {
  110199. radius?: number;
  110200. radiusX?: number;
  110201. radiusY?: number;
  110202. radiusZ?: number;
  110203. flat?: boolean;
  110204. subdivisions?: number;
  110205. sideOrientation?: number;
  110206. frontUVs?: Vector4;
  110207. backUVs?: Vector4;
  110208. updatable?: boolean;
  110209. }, scene?: Nullable<Scene>): Mesh;
  110210. }
  110211. }
  110212. declare module BABYLON {
  110213. /**
  110214. * Class containing static functions to help procedurally build meshes
  110215. */
  110216. export class DecalBuilder {
  110217. /**
  110218. * Creates a decal mesh.
  110219. * 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
  110220. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110221. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110222. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110223. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110224. * @param name defines the name of the mesh
  110225. * @param sourceMesh defines the mesh where the decal must be applied
  110226. * @param options defines the options used to create the mesh
  110227. * @param scene defines the hosting scene
  110228. * @returns the decal mesh
  110229. * @see https://doc.babylonjs.com/how_to/decals
  110230. */
  110231. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110232. position?: Vector3;
  110233. normal?: Vector3;
  110234. size?: Vector3;
  110235. angle?: number;
  110236. }): Mesh;
  110237. }
  110238. }
  110239. declare module BABYLON {
  110240. /**
  110241. * Class containing static functions to help procedurally build meshes
  110242. */
  110243. export class MeshBuilder {
  110244. /**
  110245. * Creates a box mesh
  110246. * * The parameter `size` sets the size (float) of each box side (default 1)
  110247. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110248. * * 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)
  110249. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110253. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110254. * @param name defines the name of the mesh
  110255. * @param options defines the options used to create the mesh
  110256. * @param scene defines the hosting scene
  110257. * @returns the box mesh
  110258. */
  110259. static CreateBox(name: string, options: {
  110260. size?: number;
  110261. width?: number;
  110262. height?: number;
  110263. depth?: number;
  110264. faceUV?: Vector4[];
  110265. faceColors?: Color4[];
  110266. sideOrientation?: number;
  110267. frontUVs?: Vector4;
  110268. backUVs?: Vector4;
  110269. updatable?: boolean;
  110270. }, scene?: Nullable<Scene>): Mesh;
  110271. /**
  110272. * Creates a sphere mesh
  110273. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110274. * * 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`)
  110275. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110276. * * 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
  110277. * * 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)
  110278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110281. * @param name defines the name of the mesh
  110282. * @param options defines the options used to create the mesh
  110283. * @param scene defines the hosting scene
  110284. * @returns the sphere mesh
  110285. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110286. */
  110287. static CreateSphere(name: string, options: {
  110288. segments?: number;
  110289. diameter?: number;
  110290. diameterX?: number;
  110291. diameterY?: number;
  110292. diameterZ?: number;
  110293. arc?: number;
  110294. slice?: number;
  110295. sideOrientation?: number;
  110296. frontUVs?: Vector4;
  110297. backUVs?: Vector4;
  110298. updatable?: boolean;
  110299. }, scene?: Nullable<Scene>): Mesh;
  110300. /**
  110301. * Creates a plane polygonal mesh. By default, this is a disc
  110302. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110303. * * 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
  110304. * * 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
  110305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110306. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110308. * @param name defines the name of the mesh
  110309. * @param options defines the options used to create the mesh
  110310. * @param scene defines the hosting scene
  110311. * @returns the plane polygonal mesh
  110312. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110313. */
  110314. static CreateDisc(name: string, options: {
  110315. radius?: number;
  110316. tessellation?: number;
  110317. arc?: number;
  110318. updatable?: boolean;
  110319. sideOrientation?: number;
  110320. frontUVs?: Vector4;
  110321. backUVs?: Vector4;
  110322. }, scene?: Nullable<Scene>): Mesh;
  110323. /**
  110324. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110325. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110326. * * 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`)
  110327. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110328. * * 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
  110329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110332. * @param name defines the name of the mesh
  110333. * @param options defines the options used to create the mesh
  110334. * @param scene defines the hosting scene
  110335. * @returns the icosahedron mesh
  110336. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110337. */
  110338. static CreateIcoSphere(name: string, options: {
  110339. radius?: number;
  110340. radiusX?: number;
  110341. radiusY?: number;
  110342. radiusZ?: number;
  110343. flat?: boolean;
  110344. subdivisions?: number;
  110345. sideOrientation?: number;
  110346. frontUVs?: Vector4;
  110347. backUVs?: Vector4;
  110348. updatable?: boolean;
  110349. }, scene?: Nullable<Scene>): Mesh;
  110350. /**
  110351. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110352. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110353. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110354. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110355. * * 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
  110356. * * 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
  110357. * * 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
  110358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110360. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110361. * * 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
  110362. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110363. * * 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
  110364. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110366. * @param name defines the name of the mesh
  110367. * @param options defines the options used to create the mesh
  110368. * @param scene defines the hosting scene
  110369. * @returns the ribbon mesh
  110370. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110371. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110372. */
  110373. static CreateRibbon(name: string, options: {
  110374. pathArray: Vector3[][];
  110375. closeArray?: boolean;
  110376. closePath?: boolean;
  110377. offset?: number;
  110378. updatable?: boolean;
  110379. sideOrientation?: number;
  110380. frontUVs?: Vector4;
  110381. backUVs?: Vector4;
  110382. instance?: Mesh;
  110383. invertUV?: boolean;
  110384. uvs?: Vector2[];
  110385. colors?: Color4[];
  110386. }, scene?: Nullable<Scene>): Mesh;
  110387. /**
  110388. * Creates a cylinder or a cone mesh
  110389. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110390. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110391. * * 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.
  110392. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110393. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110394. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110395. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110396. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110397. * * 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).
  110398. * * 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
  110399. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110400. * * 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
  110401. * * 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.
  110402. * * If `enclose` is false, a ring surface is one element.
  110403. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110404. * * 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
  110405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110408. * @param name defines the name of the mesh
  110409. * @param options defines the options used to create the mesh
  110410. * @param scene defines the hosting scene
  110411. * @returns the cylinder mesh
  110412. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110413. */
  110414. static CreateCylinder(name: string, options: {
  110415. height?: number;
  110416. diameterTop?: number;
  110417. diameterBottom?: number;
  110418. diameter?: number;
  110419. tessellation?: number;
  110420. subdivisions?: number;
  110421. arc?: number;
  110422. faceColors?: Color4[];
  110423. faceUV?: Vector4[];
  110424. updatable?: boolean;
  110425. hasRings?: boolean;
  110426. enclose?: boolean;
  110427. sideOrientation?: number;
  110428. frontUVs?: Vector4;
  110429. backUVs?: Vector4;
  110430. }, scene?: Nullable<Scene>): Mesh;
  110431. /**
  110432. * Creates a torus mesh
  110433. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110434. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110435. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110439. * @param name defines the name of the mesh
  110440. * @param options defines the options used to create the mesh
  110441. * @param scene defines the hosting scene
  110442. * @returns the torus mesh
  110443. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110444. */
  110445. static CreateTorus(name: string, options: {
  110446. diameter?: number;
  110447. thickness?: number;
  110448. tessellation?: number;
  110449. updatable?: boolean;
  110450. sideOrientation?: number;
  110451. frontUVs?: Vector4;
  110452. backUVs?: Vector4;
  110453. }, scene?: Nullable<Scene>): Mesh;
  110454. /**
  110455. * Creates a torus knot mesh
  110456. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110457. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110458. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110459. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110463. * @param name defines the name of the mesh
  110464. * @param options defines the options used to create the mesh
  110465. * @param scene defines the hosting scene
  110466. * @returns the torus knot mesh
  110467. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110468. */
  110469. static CreateTorusKnot(name: string, options: {
  110470. radius?: number;
  110471. tube?: number;
  110472. radialSegments?: number;
  110473. tubularSegments?: number;
  110474. p?: number;
  110475. q?: number;
  110476. updatable?: boolean;
  110477. sideOrientation?: number;
  110478. frontUVs?: Vector4;
  110479. backUVs?: Vector4;
  110480. }, scene?: Nullable<Scene>): Mesh;
  110481. /**
  110482. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110483. * * 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
  110484. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110485. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110486. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110487. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110488. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110489. * * 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
  110490. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110493. * @param name defines the name of the new line system
  110494. * @param options defines the options used to create the line system
  110495. * @param scene defines the hosting scene
  110496. * @returns a new line system mesh
  110497. */
  110498. static CreateLineSystem(name: string, options: {
  110499. lines: Vector3[][];
  110500. updatable?: boolean;
  110501. instance?: Nullable<LinesMesh>;
  110502. colors?: Nullable<Color4[][]>;
  110503. useVertexAlpha?: boolean;
  110504. }, scene: Nullable<Scene>): LinesMesh;
  110505. /**
  110506. * Creates a line mesh
  110507. * 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
  110508. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110509. * * The parameter `points` is an array successive Vector3
  110510. * * 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
  110511. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110512. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110513. * * When updating an instance, remember that only point positions can change, not the number of points
  110514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110516. * @param name defines the name of the new line system
  110517. * @param options defines the options used to create the line system
  110518. * @param scene defines the hosting scene
  110519. * @returns a new line mesh
  110520. */
  110521. static CreateLines(name: string, options: {
  110522. points: Vector3[];
  110523. updatable?: boolean;
  110524. instance?: Nullable<LinesMesh>;
  110525. colors?: Color4[];
  110526. useVertexAlpha?: boolean;
  110527. }, scene?: Nullable<Scene>): LinesMesh;
  110528. /**
  110529. * Creates a dashed line mesh
  110530. * * 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
  110531. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110532. * * The parameter `points` is an array successive Vector3
  110533. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110534. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110535. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110536. * * 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
  110537. * * When updating an instance, remember that only point positions can change, not the number of points
  110538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110539. * @param name defines the name of the mesh
  110540. * @param options defines the options used to create the mesh
  110541. * @param scene defines the hosting scene
  110542. * @returns the dashed line mesh
  110543. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110544. */
  110545. static CreateDashedLines(name: string, options: {
  110546. points: Vector3[];
  110547. dashSize?: number;
  110548. gapSize?: number;
  110549. dashNb?: number;
  110550. updatable?: boolean;
  110551. instance?: LinesMesh;
  110552. }, scene?: Nullable<Scene>): LinesMesh;
  110553. /**
  110554. * 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.
  110555. * * 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.
  110556. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110557. * * 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.
  110558. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110559. * * 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
  110560. * * 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
  110561. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110566. * @param name defines the name of the mesh
  110567. * @param options defines the options used to create the mesh
  110568. * @param scene defines the hosting scene
  110569. * @returns the extruded shape mesh
  110570. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110572. */
  110573. static ExtrudeShape(name: string, options: {
  110574. shape: Vector3[];
  110575. path: Vector3[];
  110576. scale?: number;
  110577. rotation?: number;
  110578. cap?: number;
  110579. updatable?: boolean;
  110580. sideOrientation?: number;
  110581. frontUVs?: Vector4;
  110582. backUVs?: Vector4;
  110583. instance?: Mesh;
  110584. invertUV?: boolean;
  110585. }, scene?: Nullable<Scene>): Mesh;
  110586. /**
  110587. * Creates an custom extruded shape mesh.
  110588. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110589. * * 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.
  110590. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110591. * * 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
  110592. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110593. * * 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
  110594. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110595. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110596. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110597. * * 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
  110598. * * 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
  110599. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110604. * @param name defines the name of the mesh
  110605. * @param options defines the options used to create the mesh
  110606. * @param scene defines the hosting scene
  110607. * @returns the custom extruded shape mesh
  110608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110609. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110611. */
  110612. static ExtrudeShapeCustom(name: string, options: {
  110613. shape: Vector3[];
  110614. path: Vector3[];
  110615. scaleFunction?: any;
  110616. rotationFunction?: any;
  110617. ribbonCloseArray?: boolean;
  110618. ribbonClosePath?: boolean;
  110619. cap?: number;
  110620. updatable?: boolean;
  110621. sideOrientation?: number;
  110622. frontUVs?: Vector4;
  110623. backUVs?: Vector4;
  110624. instance?: Mesh;
  110625. invertUV?: boolean;
  110626. }, scene?: Nullable<Scene>): Mesh;
  110627. /**
  110628. * Creates lathe mesh.
  110629. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110630. * * 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
  110631. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110632. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110633. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110634. * * 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
  110635. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110636. * * 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
  110637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110641. * @param name defines the name of the mesh
  110642. * @param options defines the options used to create the mesh
  110643. * @param scene defines the hosting scene
  110644. * @returns the lathe mesh
  110645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110646. */
  110647. static CreateLathe(name: string, options: {
  110648. shape: Vector3[];
  110649. radius?: number;
  110650. tessellation?: number;
  110651. clip?: number;
  110652. arc?: number;
  110653. closed?: boolean;
  110654. updatable?: boolean;
  110655. sideOrientation?: number;
  110656. frontUVs?: Vector4;
  110657. backUVs?: Vector4;
  110658. cap?: number;
  110659. invertUV?: boolean;
  110660. }, scene?: Nullable<Scene>): Mesh;
  110661. /**
  110662. * Creates a plane mesh
  110663. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110664. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110665. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110669. * @param name defines the name of the mesh
  110670. * @param options defines the options used to create the mesh
  110671. * @param scene defines the hosting scene
  110672. * @returns the plane mesh
  110673. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110674. */
  110675. static CreatePlane(name: string, options: {
  110676. size?: number;
  110677. width?: number;
  110678. height?: number;
  110679. sideOrientation?: number;
  110680. frontUVs?: Vector4;
  110681. backUVs?: Vector4;
  110682. updatable?: boolean;
  110683. sourcePlane?: Plane;
  110684. }, scene?: Nullable<Scene>): Mesh;
  110685. /**
  110686. * Creates a ground mesh
  110687. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110688. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110690. * @param name defines the name of the mesh
  110691. * @param options defines the options used to create the mesh
  110692. * @param scene defines the hosting scene
  110693. * @returns the ground mesh
  110694. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110695. */
  110696. static CreateGround(name: string, options: {
  110697. width?: number;
  110698. height?: number;
  110699. subdivisions?: number;
  110700. subdivisionsX?: number;
  110701. subdivisionsY?: number;
  110702. updatable?: boolean;
  110703. }, scene?: Nullable<Scene>): Mesh;
  110704. /**
  110705. * Creates a tiled ground mesh
  110706. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110707. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110708. * * 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
  110709. * * 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
  110710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110711. * @param name defines the name of the mesh
  110712. * @param options defines the options used to create the mesh
  110713. * @param scene defines the hosting scene
  110714. * @returns the tiled ground mesh
  110715. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110716. */
  110717. static CreateTiledGround(name: string, options: {
  110718. xmin: number;
  110719. zmin: number;
  110720. xmax: number;
  110721. zmax: number;
  110722. subdivisions?: {
  110723. w: number;
  110724. h: number;
  110725. };
  110726. precision?: {
  110727. w: number;
  110728. h: number;
  110729. };
  110730. updatable?: boolean;
  110731. }, scene?: Nullable<Scene>): Mesh;
  110732. /**
  110733. * Creates a ground mesh from a height map
  110734. * * The parameter `url` sets the URL of the height map image resource.
  110735. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110736. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110737. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110738. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110739. * * 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.
  110740. * * 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).
  110741. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110743. * @param name defines the name of the mesh
  110744. * @param url defines the url to the height map
  110745. * @param options defines the options used to create the mesh
  110746. * @param scene defines the hosting scene
  110747. * @returns the ground mesh
  110748. * @see https://doc.babylonjs.com/babylon101/height_map
  110749. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110750. */
  110751. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110752. width?: number;
  110753. height?: number;
  110754. subdivisions?: number;
  110755. minHeight?: number;
  110756. maxHeight?: number;
  110757. colorFilter?: Color3;
  110758. alphaFilter?: number;
  110759. updatable?: boolean;
  110760. onReady?: (mesh: GroundMesh) => void;
  110761. }, scene?: Nullable<Scene>): GroundMesh;
  110762. /**
  110763. * Creates a polygon mesh
  110764. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110765. * * 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
  110766. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110769. * * Remember you can only change the shape positions, not their number when updating a polygon
  110770. * @param name defines the name of the mesh
  110771. * @param options defines the options used to create the mesh
  110772. * @param scene defines the hosting scene
  110773. * @param earcutInjection can be used to inject your own earcut reference
  110774. * @returns the polygon mesh
  110775. */
  110776. static CreatePolygon(name: string, options: {
  110777. shape: Vector3[];
  110778. holes?: Vector3[][];
  110779. depth?: number;
  110780. faceUV?: Vector4[];
  110781. faceColors?: Color4[];
  110782. updatable?: boolean;
  110783. sideOrientation?: number;
  110784. frontUVs?: Vector4;
  110785. backUVs?: Vector4;
  110786. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110787. /**
  110788. * Creates an extruded polygon mesh, with depth in the Y direction.
  110789. * * 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)
  110790. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110791. * @param name defines the name of the mesh
  110792. * @param options defines the options used to create the mesh
  110793. * @param scene defines the hosting scene
  110794. * @param earcutInjection can be used to inject your own earcut reference
  110795. * @returns the polygon mesh
  110796. */
  110797. static ExtrudePolygon(name: string, options: {
  110798. shape: Vector3[];
  110799. holes?: Vector3[][];
  110800. depth?: number;
  110801. faceUV?: Vector4[];
  110802. faceColors?: Color4[];
  110803. updatable?: boolean;
  110804. sideOrientation?: number;
  110805. frontUVs?: Vector4;
  110806. backUVs?: Vector4;
  110807. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110808. /**
  110809. * Creates a tube mesh.
  110810. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110811. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110812. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110813. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110814. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110815. * * 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)
  110816. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110817. * * 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
  110818. * * 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
  110819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110821. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110823. * @param name defines the name of the mesh
  110824. * @param options defines the options used to create the mesh
  110825. * @param scene defines the hosting scene
  110826. * @returns the tube mesh
  110827. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110828. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110829. */
  110830. static CreateTube(name: string, options: {
  110831. path: Vector3[];
  110832. radius?: number;
  110833. tessellation?: number;
  110834. radiusFunction?: {
  110835. (i: number, distance: number): number;
  110836. };
  110837. cap?: number;
  110838. arc?: number;
  110839. updatable?: boolean;
  110840. sideOrientation?: number;
  110841. frontUVs?: Vector4;
  110842. backUVs?: Vector4;
  110843. instance?: Mesh;
  110844. invertUV?: boolean;
  110845. }, scene?: Nullable<Scene>): Mesh;
  110846. /**
  110847. * Creates a polyhedron mesh
  110848. * * 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
  110849. * * The parameter `size` (positive float, default 1) sets the polygon size
  110850. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110851. * * 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`
  110852. * * 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
  110853. * * 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)`)
  110854. * * 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
  110855. * * 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
  110856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110859. * @param name defines the name of the mesh
  110860. * @param options defines the options used to create the mesh
  110861. * @param scene defines the hosting scene
  110862. * @returns the polyhedron mesh
  110863. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110864. */
  110865. static CreatePolyhedron(name: string, options: {
  110866. type?: number;
  110867. size?: number;
  110868. sizeX?: number;
  110869. sizeY?: number;
  110870. sizeZ?: number;
  110871. custom?: any;
  110872. faceUV?: Vector4[];
  110873. faceColors?: Color4[];
  110874. flat?: boolean;
  110875. updatable?: boolean;
  110876. sideOrientation?: number;
  110877. frontUVs?: Vector4;
  110878. backUVs?: Vector4;
  110879. }, scene?: Nullable<Scene>): Mesh;
  110880. /**
  110881. * Creates a decal mesh.
  110882. * 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
  110883. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110884. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110885. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110886. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110887. * @param name defines the name of the mesh
  110888. * @param sourceMesh defines the mesh where the decal must be applied
  110889. * @param options defines the options used to create the mesh
  110890. * @param scene defines the hosting scene
  110891. * @returns the decal mesh
  110892. * @see https://doc.babylonjs.com/how_to/decals
  110893. */
  110894. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110895. position?: Vector3;
  110896. normal?: Vector3;
  110897. size?: Vector3;
  110898. angle?: number;
  110899. }): Mesh;
  110900. }
  110901. }
  110902. declare module BABYLON {
  110903. /**
  110904. * A simplifier interface for future simplification implementations
  110905. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110906. */
  110907. export interface ISimplifier {
  110908. /**
  110909. * Simplification of a given mesh according to the given settings.
  110910. * Since this requires computation, it is assumed that the function runs async.
  110911. * @param settings The settings of the simplification, including quality and distance
  110912. * @param successCallback A callback that will be called after the mesh was simplified.
  110913. * @param errorCallback in case of an error, this callback will be called. optional.
  110914. */
  110915. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  110916. }
  110917. /**
  110918. * Expected simplification settings.
  110919. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110920. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110921. */
  110922. export interface ISimplificationSettings {
  110923. /**
  110924. * Gets or sets the expected quality
  110925. */
  110926. quality: number;
  110927. /**
  110928. * Gets or sets the distance when this optimized version should be used
  110929. */
  110930. distance: number;
  110931. /**
  110932. * Gets an already optimized mesh
  110933. */
  110934. optimizeMesh?: boolean;
  110935. }
  110936. /**
  110937. * Class used to specify simplification options
  110938. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110939. */
  110940. export class SimplificationSettings implements ISimplificationSettings {
  110941. /** expected quality */
  110942. quality: number;
  110943. /** distance when this optimized version should be used */
  110944. distance: number;
  110945. /** already optimized mesh */
  110946. optimizeMesh?: boolean | undefined;
  110947. /**
  110948. * Creates a SimplificationSettings
  110949. * @param quality expected quality
  110950. * @param distance distance when this optimized version should be used
  110951. * @param optimizeMesh already optimized mesh
  110952. */
  110953. constructor(
  110954. /** expected quality */
  110955. quality: number,
  110956. /** distance when this optimized version should be used */
  110957. distance: number,
  110958. /** already optimized mesh */
  110959. optimizeMesh?: boolean | undefined);
  110960. }
  110961. /**
  110962. * Interface used to define a simplification task
  110963. */
  110964. export interface ISimplificationTask {
  110965. /**
  110966. * Array of settings
  110967. */
  110968. settings: Array<ISimplificationSettings>;
  110969. /**
  110970. * Simplification type
  110971. */
  110972. simplificationType: SimplificationType;
  110973. /**
  110974. * Mesh to simplify
  110975. */
  110976. mesh: Mesh;
  110977. /**
  110978. * Callback called on success
  110979. */
  110980. successCallback?: () => void;
  110981. /**
  110982. * Defines if parallel processing can be used
  110983. */
  110984. parallelProcessing: boolean;
  110985. }
  110986. /**
  110987. * Queue used to order the simplification tasks
  110988. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110989. */
  110990. export class SimplificationQueue {
  110991. private _simplificationArray;
  110992. /**
  110993. * Gets a boolean indicating that the process is still running
  110994. */
  110995. running: boolean;
  110996. /**
  110997. * Creates a new queue
  110998. */
  110999. constructor();
  111000. /**
  111001. * Adds a new simplification task
  111002. * @param task defines a task to add
  111003. */
  111004. addTask(task: ISimplificationTask): void;
  111005. /**
  111006. * Execute next task
  111007. */
  111008. executeNext(): void;
  111009. /**
  111010. * Execute a simplification task
  111011. * @param task defines the task to run
  111012. */
  111013. runSimplification(task: ISimplificationTask): void;
  111014. private getSimplifier;
  111015. }
  111016. /**
  111017. * The implemented types of simplification
  111018. * At the moment only Quadratic Error Decimation is implemented
  111019. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111020. */
  111021. export enum SimplificationType {
  111022. /** Quadratic error decimation */
  111023. QUADRATIC = 0
  111024. }
  111025. }
  111026. declare module BABYLON {
  111027. interface Scene {
  111028. /** @hidden (Backing field) */
  111029. _simplificationQueue: SimplificationQueue;
  111030. /**
  111031. * Gets or sets the simplification queue attached to the scene
  111032. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111033. */
  111034. simplificationQueue: SimplificationQueue;
  111035. }
  111036. interface Mesh {
  111037. /**
  111038. * Simplify the mesh according to the given array of settings.
  111039. * Function will return immediately and will simplify async
  111040. * @param settings a collection of simplification settings
  111041. * @param parallelProcessing should all levels calculate parallel or one after the other
  111042. * @param simplificationType the type of simplification to run
  111043. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  111044. * @returns the current mesh
  111045. */
  111046. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  111047. }
  111048. /**
  111049. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  111050. * created in a scene
  111051. */
  111052. export class SimplicationQueueSceneComponent implements ISceneComponent {
  111053. /**
  111054. * The component name helpfull to identify the component in the list of scene components.
  111055. */
  111056. readonly name: string;
  111057. /**
  111058. * The scene the component belongs to.
  111059. */
  111060. scene: Scene;
  111061. /**
  111062. * Creates a new instance of the component for the given scene
  111063. * @param scene Defines the scene to register the component in
  111064. */
  111065. constructor(scene: Scene);
  111066. /**
  111067. * Registers the component in a given scene
  111068. */
  111069. register(): void;
  111070. /**
  111071. * Rebuilds the elements related to this component in case of
  111072. * context lost for instance.
  111073. */
  111074. rebuild(): void;
  111075. /**
  111076. * Disposes the component and the associated ressources
  111077. */
  111078. dispose(): void;
  111079. private _beforeCameraUpdate;
  111080. }
  111081. }
  111082. declare module BABYLON {
  111083. /**
  111084. * Class used to enable access to IndexedDB
  111085. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  111086. */
  111087. export class Database implements IOfflineProvider {
  111088. private _callbackManifestChecked;
  111089. private _currentSceneUrl;
  111090. private _db;
  111091. private _enableSceneOffline;
  111092. private _enableTexturesOffline;
  111093. private _manifestVersionFound;
  111094. private _mustUpdateRessources;
  111095. private _hasReachedQuota;
  111096. private _isSupported;
  111097. private _idbFactory;
  111098. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  111099. private static IsUASupportingBlobStorage;
  111100. /**
  111101. * Gets a boolean indicating if Database storate is enabled (off by default)
  111102. */
  111103. static IDBStorageEnabled: boolean;
  111104. /**
  111105. * Gets a boolean indicating if scene must be saved in the database
  111106. */
  111107. readonly enableSceneOffline: boolean;
  111108. /**
  111109. * Gets a boolean indicating if textures must be saved in the database
  111110. */
  111111. readonly enableTexturesOffline: boolean;
  111112. /**
  111113. * Creates a new Database
  111114. * @param urlToScene defines the url to load the scene
  111115. * @param callbackManifestChecked defines the callback to use when manifest is checked
  111116. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  111117. */
  111118. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  111119. private static _ParseURL;
  111120. private static _ReturnFullUrlLocation;
  111121. private _checkManifestFile;
  111122. /**
  111123. * Open the database and make it available
  111124. * @param successCallback defines the callback to call on success
  111125. * @param errorCallback defines the callback to call on error
  111126. */
  111127. open(successCallback: () => void, errorCallback: () => void): void;
  111128. /**
  111129. * Loads an image from the database
  111130. * @param url defines the url to load from
  111131. * @param image defines the target DOM image
  111132. */
  111133. loadImage(url: string, image: HTMLImageElement): void;
  111134. private _loadImageFromDBAsync;
  111135. private _saveImageIntoDBAsync;
  111136. private _checkVersionFromDB;
  111137. private _loadVersionFromDBAsync;
  111138. private _saveVersionIntoDBAsync;
  111139. /**
  111140. * Loads a file from database
  111141. * @param url defines the URL to load from
  111142. * @param sceneLoaded defines a callback to call on success
  111143. * @param progressCallBack defines a callback to call when progress changed
  111144. * @param errorCallback defines a callback to call on error
  111145. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  111146. */
  111147. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  111148. private _loadFileAsync;
  111149. private _saveFileAsync;
  111150. /**
  111151. * Validates if xhr data is correct
  111152. * @param xhr defines the request to validate
  111153. * @param dataType defines the expected data type
  111154. * @returns true if data is correct
  111155. */
  111156. private static _ValidateXHRData;
  111157. }
  111158. }
  111159. declare module BABYLON {
  111160. /** @hidden */
  111161. export var gpuUpdateParticlesPixelShader: {
  111162. name: string;
  111163. shader: string;
  111164. };
  111165. }
  111166. declare module BABYLON {
  111167. /** @hidden */
  111168. export var gpuUpdateParticlesVertexShader: {
  111169. name: string;
  111170. shader: string;
  111171. };
  111172. }
  111173. declare module BABYLON {
  111174. /** @hidden */
  111175. export var clipPlaneFragmentDeclaration2: {
  111176. name: string;
  111177. shader: string;
  111178. };
  111179. }
  111180. declare module BABYLON {
  111181. /** @hidden */
  111182. export var gpuRenderParticlesPixelShader: {
  111183. name: string;
  111184. shader: string;
  111185. };
  111186. }
  111187. declare module BABYLON {
  111188. /** @hidden */
  111189. export var clipPlaneVertexDeclaration2: {
  111190. name: string;
  111191. shader: string;
  111192. };
  111193. }
  111194. declare module BABYLON {
  111195. /** @hidden */
  111196. export var gpuRenderParticlesVertexShader: {
  111197. name: string;
  111198. shader: string;
  111199. };
  111200. }
  111201. declare module BABYLON {
  111202. /**
  111203. * This represents a GPU particle system in Babylon
  111204. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  111205. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  111206. */
  111207. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  111208. /**
  111209. * The layer mask we are rendering the particles through.
  111210. */
  111211. layerMask: number;
  111212. private _capacity;
  111213. private _activeCount;
  111214. private _currentActiveCount;
  111215. private _accumulatedCount;
  111216. private _renderEffect;
  111217. private _updateEffect;
  111218. private _buffer0;
  111219. private _buffer1;
  111220. private _spriteBuffer;
  111221. private _updateVAO;
  111222. private _renderVAO;
  111223. private _targetIndex;
  111224. private _sourceBuffer;
  111225. private _targetBuffer;
  111226. private _engine;
  111227. private _currentRenderId;
  111228. private _started;
  111229. private _stopped;
  111230. private _timeDelta;
  111231. private _randomTexture;
  111232. private _randomTexture2;
  111233. private _attributesStrideSize;
  111234. private _updateEffectOptions;
  111235. private _randomTextureSize;
  111236. private _actualFrame;
  111237. private readonly _rawTextureWidth;
  111238. /**
  111239. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  111240. */
  111241. static readonly IsSupported: boolean;
  111242. /**
  111243. * An event triggered when the system is disposed.
  111244. */
  111245. onDisposeObservable: Observable<GPUParticleSystem>;
  111246. /**
  111247. * Gets the maximum number of particles active at the same time.
  111248. * @returns The max number of active particles.
  111249. */
  111250. getCapacity(): number;
  111251. /**
  111252. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  111253. * to override the particles.
  111254. */
  111255. forceDepthWrite: boolean;
  111256. /**
  111257. * Gets or set the number of active particles
  111258. */
  111259. activeParticleCount: number;
  111260. private _preWarmDone;
  111261. /**
  111262. * Is this system ready to be used/rendered
  111263. * @return true if the system is ready
  111264. */
  111265. isReady(): boolean;
  111266. /**
  111267. * Gets if the system has been started. (Note: this will still be true after stop is called)
  111268. * @returns True if it has been started, otherwise false.
  111269. */
  111270. isStarted(): boolean;
  111271. /**
  111272. * Starts the particle system and begins to emit
  111273. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  111274. */
  111275. start(delay?: number): void;
  111276. /**
  111277. * Stops the particle system.
  111278. */
  111279. stop(): void;
  111280. /**
  111281. * Remove all active particles
  111282. */
  111283. reset(): void;
  111284. /**
  111285. * Returns the string "GPUParticleSystem"
  111286. * @returns a string containing the class name
  111287. */
  111288. getClassName(): string;
  111289. private _colorGradientsTexture;
  111290. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  111291. /**
  111292. * Adds a new color gradient
  111293. * @param gradient defines the gradient to use (between 0 and 1)
  111294. * @param color1 defines the color to affect to the specified gradient
  111295. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  111296. * @returns the current particle system
  111297. */
  111298. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  111299. /**
  111300. * Remove a specific color gradient
  111301. * @param gradient defines the gradient to remove
  111302. * @returns the current particle system
  111303. */
  111304. removeColorGradient(gradient: number): GPUParticleSystem;
  111305. private _angularSpeedGradientsTexture;
  111306. private _sizeGradientsTexture;
  111307. private _velocityGradientsTexture;
  111308. private _limitVelocityGradientsTexture;
  111309. private _dragGradientsTexture;
  111310. private _addFactorGradient;
  111311. /**
  111312. * Adds a new size gradient
  111313. * @param gradient defines the gradient to use (between 0 and 1)
  111314. * @param factor defines the size factor to affect to the specified gradient
  111315. * @returns the current particle system
  111316. */
  111317. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  111318. /**
  111319. * Remove a specific size gradient
  111320. * @param gradient defines the gradient to remove
  111321. * @returns the current particle system
  111322. */
  111323. removeSizeGradient(gradient: number): GPUParticleSystem;
  111324. /**
  111325. * Adds a new angular speed gradient
  111326. * @param gradient defines the gradient to use (between 0 and 1)
  111327. * @param factor defines the angular speed to affect to the specified gradient
  111328. * @returns the current particle system
  111329. */
  111330. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  111331. /**
  111332. * Remove a specific angular speed gradient
  111333. * @param gradient defines the gradient to remove
  111334. * @returns the current particle system
  111335. */
  111336. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  111337. /**
  111338. * Adds a new velocity gradient
  111339. * @param gradient defines the gradient to use (between 0 and 1)
  111340. * @param factor defines the velocity to affect to the specified gradient
  111341. * @returns the current particle system
  111342. */
  111343. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111344. /**
  111345. * Remove a specific velocity gradient
  111346. * @param gradient defines the gradient to remove
  111347. * @returns the current particle system
  111348. */
  111349. removeVelocityGradient(gradient: number): GPUParticleSystem;
  111350. /**
  111351. * Adds a new limit velocity gradient
  111352. * @param gradient defines the gradient to use (between 0 and 1)
  111353. * @param factor defines the limit velocity value to affect to the specified gradient
  111354. * @returns the current particle system
  111355. */
  111356. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111357. /**
  111358. * Remove a specific limit velocity gradient
  111359. * @param gradient defines the gradient to remove
  111360. * @returns the current particle system
  111361. */
  111362. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  111363. /**
  111364. * Adds a new drag gradient
  111365. * @param gradient defines the gradient to use (between 0 and 1)
  111366. * @param factor defines the drag value to affect to the specified gradient
  111367. * @returns the current particle system
  111368. */
  111369. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  111370. /**
  111371. * Remove a specific drag gradient
  111372. * @param gradient defines the gradient to remove
  111373. * @returns the current particle system
  111374. */
  111375. removeDragGradient(gradient: number): GPUParticleSystem;
  111376. /**
  111377. * Not supported by GPUParticleSystem
  111378. * @param gradient defines the gradient to use (between 0 and 1)
  111379. * @param factor defines the emit rate value to affect to the specified gradient
  111380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111381. * @returns the current particle system
  111382. */
  111383. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111384. /**
  111385. * Not supported by GPUParticleSystem
  111386. * @param gradient defines the gradient to remove
  111387. * @returns the current particle system
  111388. */
  111389. removeEmitRateGradient(gradient: number): IParticleSystem;
  111390. /**
  111391. * Not supported by GPUParticleSystem
  111392. * @param gradient defines the gradient to use (between 0 and 1)
  111393. * @param factor defines the start size value to affect to the specified gradient
  111394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111395. * @returns the current particle system
  111396. */
  111397. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111398. /**
  111399. * Not supported by GPUParticleSystem
  111400. * @param gradient defines the gradient to remove
  111401. * @returns the current particle system
  111402. */
  111403. removeStartSizeGradient(gradient: number): IParticleSystem;
  111404. /**
  111405. * Not supported by GPUParticleSystem
  111406. * @param gradient defines the gradient to use (between 0 and 1)
  111407. * @param min defines the color remap minimal range
  111408. * @param max defines the color remap maximal range
  111409. * @returns the current particle system
  111410. */
  111411. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111412. /**
  111413. * Not supported by GPUParticleSystem
  111414. * @param gradient defines the gradient to remove
  111415. * @returns the current particle system
  111416. */
  111417. removeColorRemapGradient(): IParticleSystem;
  111418. /**
  111419. * Not supported by GPUParticleSystem
  111420. * @param gradient defines the gradient to use (between 0 and 1)
  111421. * @param min defines the alpha remap minimal range
  111422. * @param max defines the alpha remap maximal range
  111423. * @returns the current particle system
  111424. */
  111425. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111426. /**
  111427. * Not supported by GPUParticleSystem
  111428. * @param gradient defines the gradient to remove
  111429. * @returns the current particle system
  111430. */
  111431. removeAlphaRemapGradient(): IParticleSystem;
  111432. /**
  111433. * Not supported by GPUParticleSystem
  111434. * @param gradient defines the gradient to use (between 0 and 1)
  111435. * @param color defines the color to affect to the specified gradient
  111436. * @returns the current particle system
  111437. */
  111438. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  111439. /**
  111440. * Not supported by GPUParticleSystem
  111441. * @param gradient defines the gradient to remove
  111442. * @returns the current particle system
  111443. */
  111444. removeRampGradient(): IParticleSystem;
  111445. /**
  111446. * Not supported by GPUParticleSystem
  111447. * @returns the list of ramp gradients
  111448. */
  111449. getRampGradients(): Nullable<Array<Color3Gradient>>;
  111450. /**
  111451. * Not supported by GPUParticleSystem
  111452. * Gets or sets a boolean indicating that ramp gradients must be used
  111453. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  111454. */
  111455. useRampGradients: boolean;
  111456. /**
  111457. * Not supported by GPUParticleSystem
  111458. * @param gradient defines the gradient to use (between 0 and 1)
  111459. * @param factor defines the life time factor to affect to the specified gradient
  111460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111461. * @returns the current particle system
  111462. */
  111463. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111464. /**
  111465. * Not supported by GPUParticleSystem
  111466. * @param gradient defines the gradient to remove
  111467. * @returns the current particle system
  111468. */
  111469. removeLifeTimeGradient(gradient: number): IParticleSystem;
  111470. /**
  111471. * Instantiates a GPU particle system.
  111472. * 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.
  111473. * @param name The name of the particle system
  111474. * @param options The options used to create the system
  111475. * @param scene The scene the particle system belongs to
  111476. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  111477. */
  111478. constructor(name: string, options: Partial<{
  111479. capacity: number;
  111480. randomTextureSize: number;
  111481. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  111482. protected _reset(): void;
  111483. private _createUpdateVAO;
  111484. private _createRenderVAO;
  111485. private _initialize;
  111486. /** @hidden */
  111487. _recreateUpdateEffect(): void;
  111488. /** @hidden */
  111489. _recreateRenderEffect(): void;
  111490. /**
  111491. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111492. * @param preWarm defines if we are in the pre-warmimg phase
  111493. */
  111494. animate(preWarm?: boolean): void;
  111495. private _createFactorGradientTexture;
  111496. private _createSizeGradientTexture;
  111497. private _createAngularSpeedGradientTexture;
  111498. private _createVelocityGradientTexture;
  111499. private _createLimitVelocityGradientTexture;
  111500. private _createDragGradientTexture;
  111501. private _createColorGradientTexture;
  111502. /**
  111503. * Renders the particle system in its current state
  111504. * @param preWarm defines if the system should only update the particles but not render them
  111505. * @returns the current number of particles
  111506. */
  111507. render(preWarm?: boolean): number;
  111508. /**
  111509. * Rebuilds the particle system
  111510. */
  111511. rebuild(): void;
  111512. private _releaseBuffers;
  111513. private _releaseVAOs;
  111514. /**
  111515. * Disposes the particle system and free the associated resources
  111516. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111517. */
  111518. dispose(disposeTexture?: boolean): void;
  111519. /**
  111520. * Clones the particle system.
  111521. * @param name The name of the cloned object
  111522. * @param newEmitter The new emitter to use
  111523. * @returns the cloned particle system
  111524. */
  111525. clone(name: string, newEmitter: any): GPUParticleSystem;
  111526. /**
  111527. * Serializes the particle system to a JSON object.
  111528. * @returns the JSON object
  111529. */
  111530. serialize(): any;
  111531. /**
  111532. * Parses a JSON object to create a GPU particle system.
  111533. * @param parsedParticleSystem The JSON object to parse
  111534. * @param scene The scene to create the particle system in
  111535. * @param rootUrl The root url to use to load external dependencies like texture
  111536. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111537. * @returns the parsed GPU particle system
  111538. */
  111539. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111540. }
  111541. }
  111542. declare module BABYLON {
  111543. /**
  111544. * Represents a set of particle systems working together to create a specific effect
  111545. */
  111546. export class ParticleSystemSet implements IDisposable {
  111547. private _emitterCreationOptions;
  111548. private _emitterNode;
  111549. /**
  111550. * Gets the particle system list
  111551. */
  111552. systems: IParticleSystem[];
  111553. /**
  111554. * Gets the emitter node used with this set
  111555. */
  111556. readonly emitterNode: Nullable<TransformNode>;
  111557. /**
  111558. * Creates a new emitter mesh as a sphere
  111559. * @param options defines the options used to create the sphere
  111560. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111561. * @param scene defines the hosting scene
  111562. */
  111563. setEmitterAsSphere(options: {
  111564. diameter: number;
  111565. segments: number;
  111566. color: Color3;
  111567. }, renderingGroupId: number, scene: Scene): void;
  111568. /**
  111569. * Starts all particle systems of the set
  111570. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111571. */
  111572. start(emitter?: AbstractMesh): void;
  111573. /**
  111574. * Release all associated resources
  111575. */
  111576. dispose(): void;
  111577. /**
  111578. * Serialize the set into a JSON compatible object
  111579. * @returns a JSON compatible representation of the set
  111580. */
  111581. serialize(): any;
  111582. /**
  111583. * Parse a new ParticleSystemSet from a serialized source
  111584. * @param data defines a JSON compatible representation of the set
  111585. * @param scene defines the hosting scene
  111586. * @param gpu defines if we want GPU particles or CPU particles
  111587. * @returns a new ParticleSystemSet
  111588. */
  111589. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111590. }
  111591. }
  111592. declare module BABYLON {
  111593. /**
  111594. * This class is made for on one-liner static method to help creating particle system set.
  111595. */
  111596. export class ParticleHelper {
  111597. /**
  111598. * Gets or sets base Assets URL
  111599. */
  111600. static BaseAssetsUrl: string;
  111601. /**
  111602. * Create a default particle system that you can tweak
  111603. * @param emitter defines the emitter to use
  111604. * @param capacity defines the system capacity (default is 500 particles)
  111605. * @param scene defines the hosting scene
  111606. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111607. * @returns the new Particle system
  111608. */
  111609. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111610. /**
  111611. * This is the main static method (one-liner) of this helper to create different particle systems
  111612. * @param type This string represents the type to the particle system to create
  111613. * @param scene The scene where the particle system should live
  111614. * @param gpu If the system will use gpu
  111615. * @returns the ParticleSystemSet created
  111616. */
  111617. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111618. /**
  111619. * Static function used to export a particle system to a ParticleSystemSet variable.
  111620. * Please note that the emitter shape is not exported
  111621. * @param systems defines the particle systems to export
  111622. * @returns the created particle system set
  111623. */
  111624. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111625. }
  111626. }
  111627. declare module BABYLON {
  111628. interface Engine {
  111629. /**
  111630. * Create an effect to use with particle systems.
  111631. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111632. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111633. * @param uniformsNames defines a list of attribute names
  111634. * @param samplers defines an array of string used to represent textures
  111635. * @param defines defines the string containing the defines to use to compile the shaders
  111636. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111637. * @param onCompiled defines a function to call when the effect creation is successful
  111638. * @param onError defines a function to call when the effect creation has failed
  111639. * @returns the new Effect
  111640. */
  111641. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111642. }
  111643. interface Mesh {
  111644. /**
  111645. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111646. * @returns an array of IParticleSystem
  111647. */
  111648. getEmittedParticleSystems(): IParticleSystem[];
  111649. /**
  111650. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111651. * @returns an array of IParticleSystem
  111652. */
  111653. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111654. }
  111655. /**
  111656. * @hidden
  111657. */
  111658. export var _IDoNeedToBeInTheBuild: number;
  111659. }
  111660. declare module BABYLON {
  111661. interface Scene {
  111662. /** @hidden (Backing field) */
  111663. _physicsEngine: Nullable<IPhysicsEngine>;
  111664. /**
  111665. * Gets the current physics engine
  111666. * @returns a IPhysicsEngine or null if none attached
  111667. */
  111668. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111669. /**
  111670. * Enables physics to the current scene
  111671. * @param gravity defines the scene's gravity for the physics engine
  111672. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111673. * @return a boolean indicating if the physics engine was initialized
  111674. */
  111675. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111676. /**
  111677. * Disables and disposes the physics engine associated with the scene
  111678. */
  111679. disablePhysicsEngine(): void;
  111680. /**
  111681. * Gets a boolean indicating if there is an active physics engine
  111682. * @returns a boolean indicating if there is an active physics engine
  111683. */
  111684. isPhysicsEnabled(): boolean;
  111685. /**
  111686. * Deletes a physics compound impostor
  111687. * @param compound defines the compound to delete
  111688. */
  111689. deleteCompoundImpostor(compound: any): void;
  111690. /**
  111691. * An event triggered when physic simulation is about to be run
  111692. */
  111693. onBeforePhysicsObservable: Observable<Scene>;
  111694. /**
  111695. * An event triggered when physic simulation has been done
  111696. */
  111697. onAfterPhysicsObservable: Observable<Scene>;
  111698. }
  111699. interface AbstractMesh {
  111700. /** @hidden */
  111701. _physicsImpostor: Nullable<PhysicsImpostor>;
  111702. /**
  111703. * Gets or sets impostor used for physic simulation
  111704. * @see http://doc.babylonjs.com/features/physics_engine
  111705. */
  111706. physicsImpostor: Nullable<PhysicsImpostor>;
  111707. /**
  111708. * Gets the current physics impostor
  111709. * @see http://doc.babylonjs.com/features/physics_engine
  111710. * @returns a physics impostor or null
  111711. */
  111712. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111713. /** Apply a physic impulse to the mesh
  111714. * @param force defines the force to apply
  111715. * @param contactPoint defines where to apply the force
  111716. * @returns the current mesh
  111717. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111718. */
  111719. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111720. /**
  111721. * Creates a physic joint between two meshes
  111722. * @param otherMesh defines the other mesh to use
  111723. * @param pivot1 defines the pivot to use on this mesh
  111724. * @param pivot2 defines the pivot to use on the other mesh
  111725. * @param options defines additional options (can be plugin dependent)
  111726. * @returns the current mesh
  111727. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111728. */
  111729. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111730. /** @hidden */
  111731. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111732. }
  111733. /**
  111734. * Defines the physics engine scene component responsible to manage a physics engine
  111735. */
  111736. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111737. /**
  111738. * The component name helpful to identify the component in the list of scene components.
  111739. */
  111740. readonly name: string;
  111741. /**
  111742. * The scene the component belongs to.
  111743. */
  111744. scene: Scene;
  111745. /**
  111746. * Creates a new instance of the component for the given scene
  111747. * @param scene Defines the scene to register the component in
  111748. */
  111749. constructor(scene: Scene);
  111750. /**
  111751. * Registers the component in a given scene
  111752. */
  111753. register(): void;
  111754. /**
  111755. * Rebuilds the elements related to this component in case of
  111756. * context lost for instance.
  111757. */
  111758. rebuild(): void;
  111759. /**
  111760. * Disposes the component and the associated ressources
  111761. */
  111762. dispose(): void;
  111763. }
  111764. }
  111765. declare module BABYLON {
  111766. /**
  111767. * A helper for physics simulations
  111768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111769. */
  111770. export class PhysicsHelper {
  111771. private _scene;
  111772. private _physicsEngine;
  111773. /**
  111774. * Initializes the Physics helper
  111775. * @param scene Babylon.js scene
  111776. */
  111777. constructor(scene: Scene);
  111778. /**
  111779. * Applies a radial explosion impulse
  111780. * @param origin the origin of the explosion
  111781. * @param radiusOrEventOptions the radius or the options of radial explosion
  111782. * @param strength the explosion strength
  111783. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111784. * @returns A physics radial explosion event, or null
  111785. */
  111786. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111787. /**
  111788. * Applies a radial explosion force
  111789. * @param origin the origin of the explosion
  111790. * @param radiusOrEventOptions the radius or the options of radial explosion
  111791. * @param strength the explosion strength
  111792. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111793. * @returns A physics radial explosion event, or null
  111794. */
  111795. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111796. /**
  111797. * Creates a gravitational field
  111798. * @param origin the origin of the explosion
  111799. * @param radiusOrEventOptions the radius or the options of radial explosion
  111800. * @param strength the explosion strength
  111801. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111802. * @returns A physics gravitational field event, or null
  111803. */
  111804. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111805. /**
  111806. * Creates a physics updraft event
  111807. * @param origin the origin of the updraft
  111808. * @param radiusOrEventOptions the radius or the options of the updraft
  111809. * @param strength the strength of the updraft
  111810. * @param height the height of the updraft
  111811. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111812. * @returns A physics updraft event, or null
  111813. */
  111814. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  111815. /**
  111816. * Creates a physics vortex event
  111817. * @param origin the of the vortex
  111818. * @param radiusOrEventOptions the radius or the options of the vortex
  111819. * @param strength the strength of the vortex
  111820. * @param height the height of the vortex
  111821. * @returns a Physics vortex event, or null
  111822. * A physics vortex event or null
  111823. */
  111824. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  111825. }
  111826. /**
  111827. * Represents a physics radial explosion event
  111828. */
  111829. class PhysicsRadialExplosionEvent {
  111830. private _scene;
  111831. private _options;
  111832. private _sphere;
  111833. private _dataFetched;
  111834. /**
  111835. * Initializes a radial explosioin event
  111836. * @param _scene BabylonJS scene
  111837. * @param _options The options for the vortex event
  111838. */
  111839. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  111840. /**
  111841. * Returns the data related to the radial explosion event (sphere).
  111842. * @returns The radial explosion event data
  111843. */
  111844. getData(): PhysicsRadialExplosionEventData;
  111845. /**
  111846. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111847. * @param impostor A physics imposter
  111848. * @param origin the origin of the explosion
  111849. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  111850. */
  111851. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  111852. /**
  111853. * Triggers affecterd impostors callbacks
  111854. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  111855. */
  111856. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  111857. /**
  111858. * Disposes the sphere.
  111859. * @param force Specifies if the sphere should be disposed by force
  111860. */
  111861. dispose(force?: boolean): void;
  111862. /*** Helpers ***/
  111863. private _prepareSphere;
  111864. private _intersectsWithSphere;
  111865. }
  111866. /**
  111867. * Represents a gravitational field event
  111868. */
  111869. class PhysicsGravitationalFieldEvent {
  111870. private _physicsHelper;
  111871. private _scene;
  111872. private _origin;
  111873. private _options;
  111874. private _tickCallback;
  111875. private _sphere;
  111876. private _dataFetched;
  111877. /**
  111878. * Initializes the physics gravitational field event
  111879. * @param _physicsHelper A physics helper
  111880. * @param _scene BabylonJS scene
  111881. * @param _origin The origin position of the gravitational field event
  111882. * @param _options The options for the vortex event
  111883. */
  111884. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  111885. /**
  111886. * Returns the data related to the gravitational field event (sphere).
  111887. * @returns A gravitational field event
  111888. */
  111889. getData(): PhysicsGravitationalFieldEventData;
  111890. /**
  111891. * Enables the gravitational field.
  111892. */
  111893. enable(): void;
  111894. /**
  111895. * Disables the gravitational field.
  111896. */
  111897. disable(): void;
  111898. /**
  111899. * Disposes the sphere.
  111900. * @param force The force to dispose from the gravitational field event
  111901. */
  111902. dispose(force?: boolean): void;
  111903. private _tick;
  111904. }
  111905. /**
  111906. * Represents a physics updraft event
  111907. */
  111908. class PhysicsUpdraftEvent {
  111909. private _scene;
  111910. private _origin;
  111911. private _options;
  111912. private _physicsEngine;
  111913. private _originTop;
  111914. private _originDirection;
  111915. private _tickCallback;
  111916. private _cylinder;
  111917. private _cylinderPosition;
  111918. private _dataFetched;
  111919. /**
  111920. * Initializes the physics updraft event
  111921. * @param _scene BabylonJS scene
  111922. * @param _origin The origin position of the updraft
  111923. * @param _options The options for the updraft event
  111924. */
  111925. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111926. /**
  111927. * Returns the data related to the updraft event (cylinder).
  111928. * @returns A physics updraft event
  111929. */
  111930. getData(): PhysicsUpdraftEventData;
  111931. /**
  111932. * Enables the updraft.
  111933. */
  111934. enable(): void;
  111935. /**
  111936. * Disables the updraft.
  111937. */
  111938. disable(): void;
  111939. /**
  111940. * Disposes the cylinder.
  111941. * @param force Specifies if the updraft should be disposed by force
  111942. */
  111943. dispose(force?: boolean): void;
  111944. private getImpostorHitData;
  111945. private _tick;
  111946. /*** Helpers ***/
  111947. private _prepareCylinder;
  111948. private _intersectsWithCylinder;
  111949. }
  111950. /**
  111951. * Represents a physics vortex event
  111952. */
  111953. class PhysicsVortexEvent {
  111954. private _scene;
  111955. private _origin;
  111956. private _options;
  111957. private _physicsEngine;
  111958. private _originTop;
  111959. private _tickCallback;
  111960. private _cylinder;
  111961. private _cylinderPosition;
  111962. private _dataFetched;
  111963. /**
  111964. * Initializes the physics vortex event
  111965. * @param _scene The BabylonJS scene
  111966. * @param _origin The origin position of the vortex
  111967. * @param _options The options for the vortex event
  111968. */
  111969. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111970. /**
  111971. * Returns the data related to the vortex event (cylinder).
  111972. * @returns The physics vortex event data
  111973. */
  111974. getData(): PhysicsVortexEventData;
  111975. /**
  111976. * Enables the vortex.
  111977. */
  111978. enable(): void;
  111979. /**
  111980. * Disables the cortex.
  111981. */
  111982. disable(): void;
  111983. /**
  111984. * Disposes the sphere.
  111985. * @param force
  111986. */
  111987. dispose(force?: boolean): void;
  111988. private getImpostorHitData;
  111989. private _tick;
  111990. /*** Helpers ***/
  111991. private _prepareCylinder;
  111992. private _intersectsWithCylinder;
  111993. }
  111994. /**
  111995. * Options fot the radial explosion event
  111996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111997. */
  111998. export class PhysicsRadialExplosionEventOptions {
  111999. /**
  112000. * The radius of the sphere for the radial explosion.
  112001. */
  112002. radius: number;
  112003. /**
  112004. * The strenth of the explosion.
  112005. */
  112006. strength: number;
  112007. /**
  112008. * The strenght of the force in correspondence to the distance of the affected object
  112009. */
  112010. falloff: PhysicsRadialImpulseFalloff;
  112011. /**
  112012. * Sphere options for the radial explosion.
  112013. */
  112014. sphere: {
  112015. segments: number;
  112016. diameter: number;
  112017. };
  112018. /**
  112019. * Sphere options for the radial explosion.
  112020. */
  112021. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  112022. }
  112023. /**
  112024. * Options fot the updraft event
  112025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112026. */
  112027. export class PhysicsUpdraftEventOptions {
  112028. /**
  112029. * The radius of the cylinder for the vortex
  112030. */
  112031. radius: number;
  112032. /**
  112033. * The strenth of the updraft.
  112034. */
  112035. strength: number;
  112036. /**
  112037. * The height of the cylinder for the updraft.
  112038. */
  112039. height: number;
  112040. /**
  112041. * The mode for the the updraft.
  112042. */
  112043. updraftMode: PhysicsUpdraftMode;
  112044. }
  112045. /**
  112046. * Options fot the vortex event
  112047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112048. */
  112049. export class PhysicsVortexEventOptions {
  112050. /**
  112051. * The radius of the cylinder for the vortex
  112052. */
  112053. radius: number;
  112054. /**
  112055. * The strenth of the vortex.
  112056. */
  112057. strength: number;
  112058. /**
  112059. * The height of the cylinder for the vortex.
  112060. */
  112061. height: number;
  112062. /**
  112063. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  112064. */
  112065. centripetalForceThreshold: number;
  112066. /**
  112067. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  112068. */
  112069. centripetalForceMultiplier: number;
  112070. /**
  112071. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  112072. */
  112073. centrifugalForceMultiplier: number;
  112074. /**
  112075. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  112076. */
  112077. updraftForceMultiplier: number;
  112078. }
  112079. /**
  112080. * The strenght of the force in correspondence to the distance of the affected object
  112081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112082. */
  112083. export enum PhysicsRadialImpulseFalloff {
  112084. /** Defines that impulse is constant in strength across it's whole radius */
  112085. Constant = 0,
  112086. /** Defines that impulse gets weaker if it's further from the origin */
  112087. Linear = 1
  112088. }
  112089. /**
  112090. * The strength of the force in correspondence to the distance of the affected object
  112091. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112092. */
  112093. export enum PhysicsUpdraftMode {
  112094. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  112095. Center = 0,
  112096. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  112097. Perpendicular = 1
  112098. }
  112099. /**
  112100. * Interface for a physics hit data
  112101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112102. */
  112103. export interface PhysicsHitData {
  112104. /**
  112105. * The force applied at the contact point
  112106. */
  112107. force: Vector3;
  112108. /**
  112109. * The contact point
  112110. */
  112111. contactPoint: Vector3;
  112112. /**
  112113. * The distance from the origin to the contact point
  112114. */
  112115. distanceFromOrigin: number;
  112116. }
  112117. /**
  112118. * Interface for radial explosion event data
  112119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112120. */
  112121. export interface PhysicsRadialExplosionEventData {
  112122. /**
  112123. * A sphere used for the radial explosion event
  112124. */
  112125. sphere: Mesh;
  112126. }
  112127. /**
  112128. * Interface for gravitational field event data
  112129. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112130. */
  112131. export interface PhysicsGravitationalFieldEventData {
  112132. /**
  112133. * A sphere mesh used for the gravitational field event
  112134. */
  112135. sphere: Mesh;
  112136. }
  112137. /**
  112138. * Interface for updraft event data
  112139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112140. */
  112141. export interface PhysicsUpdraftEventData {
  112142. /**
  112143. * A cylinder used for the updraft event
  112144. */
  112145. cylinder: Mesh;
  112146. }
  112147. /**
  112148. * Interface for vortex event data
  112149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112150. */
  112151. export interface PhysicsVortexEventData {
  112152. /**
  112153. * A cylinder used for the vortex event
  112154. */
  112155. cylinder: Mesh;
  112156. }
  112157. /**
  112158. * Interface for an affected physics impostor
  112159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112160. */
  112161. export interface PhysicsAffectedImpostorWithData {
  112162. /**
  112163. * The impostor affected by the effect
  112164. */
  112165. impostor: PhysicsImpostor;
  112166. /**
  112167. * The data about the hit/horce from the explosion
  112168. */
  112169. hitData: PhysicsHitData;
  112170. }
  112171. }
  112172. declare module BABYLON {
  112173. /** @hidden */
  112174. export var blackAndWhitePixelShader: {
  112175. name: string;
  112176. shader: string;
  112177. };
  112178. }
  112179. declare module BABYLON {
  112180. /**
  112181. * Post process used to render in black and white
  112182. */
  112183. export class BlackAndWhitePostProcess extends PostProcess {
  112184. /**
  112185. * Linear about to convert he result to black and white (default: 1)
  112186. */
  112187. degree: number;
  112188. /**
  112189. * Creates a black and white post process
  112190. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  112191. * @param name The name of the effect.
  112192. * @param options The required width/height ratio to downsize to before computing the render pass.
  112193. * @param camera The camera to apply the render pass to.
  112194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112195. * @param engine The engine which the post process will be applied. (default: current engine)
  112196. * @param reusable If the post process can be reused on the same frame. (default: false)
  112197. */
  112198. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112199. }
  112200. }
  112201. declare module BABYLON {
  112202. /**
  112203. * This represents a set of one or more post processes in Babylon.
  112204. * A post process can be used to apply a shader to a texture after it is rendered.
  112205. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112206. */
  112207. export class PostProcessRenderEffect {
  112208. private _postProcesses;
  112209. private _getPostProcesses;
  112210. private _singleInstance;
  112211. private _cameras;
  112212. private _indicesForCamera;
  112213. /**
  112214. * Name of the effect
  112215. * @hidden
  112216. */
  112217. _name: string;
  112218. /**
  112219. * Instantiates a post process render effect.
  112220. * A post process can be used to apply a shader to a texture after it is rendered.
  112221. * @param engine The engine the effect is tied to
  112222. * @param name The name of the effect
  112223. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  112224. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  112225. */
  112226. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  112227. /**
  112228. * Checks if all the post processes in the effect are supported.
  112229. */
  112230. readonly isSupported: boolean;
  112231. /**
  112232. * Updates the current state of the effect
  112233. * @hidden
  112234. */
  112235. _update(): void;
  112236. /**
  112237. * Attaches the effect on cameras
  112238. * @param cameras The camera to attach to.
  112239. * @hidden
  112240. */
  112241. _attachCameras(cameras: Camera): void;
  112242. /**
  112243. * Attaches the effect on cameras
  112244. * @param cameras The camera to attach to.
  112245. * @hidden
  112246. */
  112247. _attachCameras(cameras: Camera[]): void;
  112248. /**
  112249. * Detaches the effect on cameras
  112250. * @param cameras The camera to detatch from.
  112251. * @hidden
  112252. */
  112253. _detachCameras(cameras: Camera): void;
  112254. /**
  112255. * Detatches the effect on cameras
  112256. * @param cameras The camera to detatch from.
  112257. * @hidden
  112258. */
  112259. _detachCameras(cameras: Camera[]): void;
  112260. /**
  112261. * Enables the effect on given cameras
  112262. * @param cameras The camera to enable.
  112263. * @hidden
  112264. */
  112265. _enable(cameras: Camera): void;
  112266. /**
  112267. * Enables the effect on given cameras
  112268. * @param cameras The camera to enable.
  112269. * @hidden
  112270. */
  112271. _enable(cameras: Nullable<Camera[]>): void;
  112272. /**
  112273. * Disables the effect on the given cameras
  112274. * @param cameras The camera to disable.
  112275. * @hidden
  112276. */
  112277. _disable(cameras: Camera): void;
  112278. /**
  112279. * Disables the effect on the given cameras
  112280. * @param cameras The camera to disable.
  112281. * @hidden
  112282. */
  112283. _disable(cameras: Nullable<Camera[]>): void;
  112284. /**
  112285. * Gets a list of the post processes contained in the effect.
  112286. * @param camera The camera to get the post processes on.
  112287. * @returns The list of the post processes in the effect.
  112288. */
  112289. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  112290. }
  112291. }
  112292. declare module BABYLON {
  112293. /** @hidden */
  112294. export var extractHighlightsPixelShader: {
  112295. name: string;
  112296. shader: string;
  112297. };
  112298. }
  112299. declare module BABYLON {
  112300. /**
  112301. * 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.
  112302. */
  112303. export class ExtractHighlightsPostProcess extends PostProcess {
  112304. /**
  112305. * The luminance threshold, pixels below this value will be set to black.
  112306. */
  112307. threshold: number;
  112308. /** @hidden */
  112309. _exposure: number;
  112310. /**
  112311. * Post process which has the input texture to be used when performing highlight extraction
  112312. * @hidden
  112313. */
  112314. _inputPostProcess: Nullable<PostProcess>;
  112315. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112316. }
  112317. }
  112318. declare module BABYLON {
  112319. /** @hidden */
  112320. export var bloomMergePixelShader: {
  112321. name: string;
  112322. shader: string;
  112323. };
  112324. }
  112325. declare module BABYLON {
  112326. /**
  112327. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112328. */
  112329. export class BloomMergePostProcess extends PostProcess {
  112330. /** Weight of the bloom to be added to the original input. */
  112331. weight: number;
  112332. /**
  112333. * Creates a new instance of @see BloomMergePostProcess
  112334. * @param name The name of the effect.
  112335. * @param originalFromInput Post process which's input will be used for the merge.
  112336. * @param blurred Blurred highlights post process which's output will be used.
  112337. * @param weight Weight of the bloom to be added to the original input.
  112338. * @param options The required width/height ratio to downsize to before computing the render pass.
  112339. * @param camera The camera to apply the render pass to.
  112340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112341. * @param engine The engine which the post process will be applied. (default: current engine)
  112342. * @param reusable If the post process can be reused on the same frame. (default: false)
  112343. * @param textureType Type of textures used when performing the post process. (default: 0)
  112344. * @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)
  112345. */
  112346. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  112347. /** Weight of the bloom to be added to the original input. */
  112348. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112349. }
  112350. }
  112351. declare module BABYLON {
  112352. /**
  112353. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  112354. */
  112355. export class BloomEffect extends PostProcessRenderEffect {
  112356. private bloomScale;
  112357. /**
  112358. * @hidden Internal
  112359. */
  112360. _effects: Array<PostProcess>;
  112361. /**
  112362. * @hidden Internal
  112363. */
  112364. _downscale: ExtractHighlightsPostProcess;
  112365. private _blurX;
  112366. private _blurY;
  112367. private _merge;
  112368. /**
  112369. * The luminance threshold to find bright areas of the image to bloom.
  112370. */
  112371. threshold: number;
  112372. /**
  112373. * The strength of the bloom.
  112374. */
  112375. weight: number;
  112376. /**
  112377. * Specifies the size of the bloom blur kernel, relative to the final output size
  112378. */
  112379. kernel: number;
  112380. /**
  112381. * Creates a new instance of @see BloomEffect
  112382. * @param scene The scene the effect belongs to.
  112383. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  112384. * @param bloomKernel The size of the kernel to be used when applying the blur.
  112385. * @param bloomWeight The the strength of bloom.
  112386. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112387. * @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)
  112388. */
  112389. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  112390. /**
  112391. * Disposes each of the internal effects for a given camera.
  112392. * @param camera The camera to dispose the effect on.
  112393. */
  112394. disposeEffects(camera: Camera): void;
  112395. /**
  112396. * @hidden Internal
  112397. */
  112398. _updateEffects(): void;
  112399. /**
  112400. * Internal
  112401. * @returns if all the contained post processes are ready.
  112402. * @hidden
  112403. */
  112404. _isReady(): boolean;
  112405. }
  112406. }
  112407. declare module BABYLON {
  112408. /** @hidden */
  112409. export var chromaticAberrationPixelShader: {
  112410. name: string;
  112411. shader: string;
  112412. };
  112413. }
  112414. declare module BABYLON {
  112415. /**
  112416. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  112417. */
  112418. export class ChromaticAberrationPostProcess extends PostProcess {
  112419. /**
  112420. * The amount of seperation of rgb channels (default: 30)
  112421. */
  112422. aberrationAmount: number;
  112423. /**
  112424. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  112425. */
  112426. radialIntensity: number;
  112427. /**
  112428. * 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))
  112429. */
  112430. direction: Vector2;
  112431. /**
  112432. * 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))
  112433. */
  112434. centerPosition: Vector2;
  112435. /**
  112436. * Creates a new instance ChromaticAberrationPostProcess
  112437. * @param name The name of the effect.
  112438. * @param screenWidth The width of the screen to apply the effect on.
  112439. * @param screenHeight The height of the screen to apply the effect on.
  112440. * @param options The required width/height ratio to downsize to before computing the render pass.
  112441. * @param camera The camera to apply the render pass to.
  112442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112443. * @param engine The engine which the post process will be applied. (default: current engine)
  112444. * @param reusable If the post process can be reused on the same frame. (default: false)
  112445. * @param textureType Type of textures used when performing the post process. (default: 0)
  112446. * @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)
  112447. */
  112448. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112449. }
  112450. }
  112451. declare module BABYLON {
  112452. /** @hidden */
  112453. export var circleOfConfusionPixelShader: {
  112454. name: string;
  112455. shader: string;
  112456. };
  112457. }
  112458. declare module BABYLON {
  112459. /**
  112460. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  112461. */
  112462. export class CircleOfConfusionPostProcess extends PostProcess {
  112463. /**
  112464. * 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.
  112465. */
  112466. lensSize: number;
  112467. /**
  112468. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112469. */
  112470. fStop: number;
  112471. /**
  112472. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112473. */
  112474. focusDistance: number;
  112475. /**
  112476. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  112477. */
  112478. focalLength: number;
  112479. private _depthTexture;
  112480. /**
  112481. * Creates a new instance CircleOfConfusionPostProcess
  112482. * @param name The name of the effect.
  112483. * @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.
  112484. * @param options The required width/height ratio to downsize to before computing the render pass.
  112485. * @param camera The camera to apply the render pass to.
  112486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112487. * @param engine The engine which the post process will be applied. (default: current engine)
  112488. * @param reusable If the post process can be reused on the same frame. (default: false)
  112489. * @param textureType Type of textures used when performing the post process. (default: 0)
  112490. * @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)
  112491. */
  112492. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112493. /**
  112494. * 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.
  112495. */
  112496. depthTexture: RenderTargetTexture;
  112497. }
  112498. }
  112499. declare module BABYLON {
  112500. /** @hidden */
  112501. export var colorCorrectionPixelShader: {
  112502. name: string;
  112503. shader: string;
  112504. };
  112505. }
  112506. declare module BABYLON {
  112507. /**
  112508. *
  112509. * This post-process allows the modification of rendered colors by using
  112510. * a 'look-up table' (LUT). This effect is also called Color Grading.
  112511. *
  112512. * The object needs to be provided an url to a texture containing the color
  112513. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  112514. * Use an image editing software to tweak the LUT to match your needs.
  112515. *
  112516. * For an example of a color LUT, see here:
  112517. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  112518. * For explanations on color grading, see here:
  112519. * @see http://udn.epicgames.com/Three/ColorGrading.html
  112520. *
  112521. */
  112522. export class ColorCorrectionPostProcess extends PostProcess {
  112523. private _colorTableTexture;
  112524. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112525. }
  112526. }
  112527. declare module BABYLON {
  112528. /** @hidden */
  112529. export var convolutionPixelShader: {
  112530. name: string;
  112531. shader: string;
  112532. };
  112533. }
  112534. declare module BABYLON {
  112535. /**
  112536. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112537. * input texture to perform effects such as edge detection or sharpening
  112538. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112539. */
  112540. export class ConvolutionPostProcess extends PostProcess {
  112541. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112542. kernel: number[];
  112543. /**
  112544. * Creates a new instance ConvolutionPostProcess
  112545. * @param name The name of the effect.
  112546. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112547. * @param options The required width/height ratio to downsize to before computing the render pass.
  112548. * @param camera The camera to apply the render pass to.
  112549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112550. * @param engine The engine which the post process will be applied. (default: current engine)
  112551. * @param reusable If the post process can be reused on the same frame. (default: false)
  112552. * @param textureType Type of textures used when performing the post process. (default: 0)
  112553. */
  112554. constructor(name: string,
  112555. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112556. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112557. /**
  112558. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112559. */
  112560. static EdgeDetect0Kernel: number[];
  112561. /**
  112562. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112563. */
  112564. static EdgeDetect1Kernel: number[];
  112565. /**
  112566. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112567. */
  112568. static EdgeDetect2Kernel: number[];
  112569. /**
  112570. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112571. */
  112572. static SharpenKernel: number[];
  112573. /**
  112574. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112575. */
  112576. static EmbossKernel: number[];
  112577. /**
  112578. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112579. */
  112580. static GaussianKernel: number[];
  112581. }
  112582. }
  112583. declare module BABYLON {
  112584. /**
  112585. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112586. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112587. * based on samples that have a large difference in distance than the center pixel.
  112588. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112589. */
  112590. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112591. direction: Vector2;
  112592. /**
  112593. * Creates a new instance CircleOfConfusionPostProcess
  112594. * @param name The name of the effect.
  112595. * @param scene The scene the effect belongs to.
  112596. * @param direction The direction the blur should be applied.
  112597. * @param kernel The size of the kernel used to blur.
  112598. * @param options The required width/height ratio to downsize to before computing the render pass.
  112599. * @param camera The camera to apply the render pass to.
  112600. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112601. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112603. * @param engine The engine which the post process will be applied. (default: current engine)
  112604. * @param reusable If the post process can be reused on the same frame. (default: false)
  112605. * @param textureType Type of textures used when performing the post process. (default: 0)
  112606. * @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)
  112607. */
  112608. 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);
  112609. }
  112610. }
  112611. declare module BABYLON {
  112612. /** @hidden */
  112613. export var depthOfFieldMergePixelShader: {
  112614. name: string;
  112615. shader: string;
  112616. };
  112617. }
  112618. declare module BABYLON {
  112619. /**
  112620. * Options to be set when merging outputs from the default pipeline.
  112621. */
  112622. export class DepthOfFieldMergePostProcessOptions {
  112623. /**
  112624. * The original image to merge on top of
  112625. */
  112626. originalFromInput: PostProcess;
  112627. /**
  112628. * Parameters to perform the merge of the depth of field effect
  112629. */
  112630. depthOfField?: {
  112631. circleOfConfusion: PostProcess;
  112632. blurSteps: Array<PostProcess>;
  112633. };
  112634. /**
  112635. * Parameters to perform the merge of bloom effect
  112636. */
  112637. bloom?: {
  112638. blurred: PostProcess;
  112639. weight: number;
  112640. };
  112641. }
  112642. /**
  112643. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112644. */
  112645. export class DepthOfFieldMergePostProcess extends PostProcess {
  112646. private blurSteps;
  112647. /**
  112648. * Creates a new instance of DepthOfFieldMergePostProcess
  112649. * @param name The name of the effect.
  112650. * @param originalFromInput Post process which's input will be used for the merge.
  112651. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112652. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112653. * @param options The required width/height ratio to downsize to before computing the render pass.
  112654. * @param camera The camera to apply the render pass to.
  112655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112656. * @param engine The engine which the post process will be applied. (default: current engine)
  112657. * @param reusable If the post process can be reused on the same frame. (default: false)
  112658. * @param textureType Type of textures used when performing the post process. (default: 0)
  112659. * @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)
  112660. */
  112661. 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);
  112662. /**
  112663. * Updates the effect with the current post process compile time values and recompiles the shader.
  112664. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112665. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112666. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112667. * @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
  112668. * @param onCompiled Called when the shader has been compiled.
  112669. * @param onError Called if there is an error when compiling a shader.
  112670. */
  112671. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112672. }
  112673. }
  112674. declare module BABYLON {
  112675. /**
  112676. * Specifies the level of max blur that should be applied when using the depth of field effect
  112677. */
  112678. export enum DepthOfFieldEffectBlurLevel {
  112679. /**
  112680. * Subtle blur
  112681. */
  112682. Low = 0,
  112683. /**
  112684. * Medium blur
  112685. */
  112686. Medium = 1,
  112687. /**
  112688. * Large blur
  112689. */
  112690. High = 2
  112691. }
  112692. /**
  112693. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112694. */
  112695. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112696. private _circleOfConfusion;
  112697. /**
  112698. * @hidden Internal, blurs from high to low
  112699. */
  112700. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112701. private _depthOfFieldBlurY;
  112702. private _dofMerge;
  112703. /**
  112704. * @hidden Internal post processes in depth of field effect
  112705. */
  112706. _effects: Array<PostProcess>;
  112707. /**
  112708. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112709. */
  112710. focalLength: number;
  112711. /**
  112712. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112713. */
  112714. fStop: number;
  112715. /**
  112716. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112717. */
  112718. focusDistance: number;
  112719. /**
  112720. * 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.
  112721. */
  112722. lensSize: number;
  112723. /**
  112724. * Creates a new instance DepthOfFieldEffect
  112725. * @param scene The scene the effect belongs to.
  112726. * @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.
  112727. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112728. * @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)
  112729. */
  112730. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112731. /**
  112732. * Get the current class name of the current effet
  112733. * @returns "DepthOfFieldEffect"
  112734. */
  112735. getClassName(): string;
  112736. /**
  112737. * 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.
  112738. */
  112739. depthTexture: RenderTargetTexture;
  112740. /**
  112741. * Disposes each of the internal effects for a given camera.
  112742. * @param camera The camera to dispose the effect on.
  112743. */
  112744. disposeEffects(camera: Camera): void;
  112745. /**
  112746. * @hidden Internal
  112747. */
  112748. _updateEffects(): void;
  112749. /**
  112750. * Internal
  112751. * @returns if all the contained post processes are ready.
  112752. * @hidden
  112753. */
  112754. _isReady(): boolean;
  112755. }
  112756. }
  112757. declare module BABYLON {
  112758. /** @hidden */
  112759. export var displayPassPixelShader: {
  112760. name: string;
  112761. shader: string;
  112762. };
  112763. }
  112764. declare module BABYLON {
  112765. /**
  112766. * DisplayPassPostProcess which produces an output the same as it's input
  112767. */
  112768. export class DisplayPassPostProcess extends PostProcess {
  112769. /**
  112770. * Creates the DisplayPassPostProcess
  112771. * @param name The name of the effect.
  112772. * @param options The required width/height ratio to downsize to before computing the render pass.
  112773. * @param camera The camera to apply the render pass to.
  112774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112775. * @param engine The engine which the post process will be applied. (default: current engine)
  112776. * @param reusable If the post process can be reused on the same frame. (default: false)
  112777. */
  112778. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112779. }
  112780. }
  112781. declare module BABYLON {
  112782. /** @hidden */
  112783. export var filterPixelShader: {
  112784. name: string;
  112785. shader: string;
  112786. };
  112787. }
  112788. declare module BABYLON {
  112789. /**
  112790. * Applies a kernel filter to the image
  112791. */
  112792. export class FilterPostProcess extends PostProcess {
  112793. /** The matrix to be applied to the image */
  112794. kernelMatrix: Matrix;
  112795. /**
  112796. *
  112797. * @param name The name of the effect.
  112798. * @param kernelMatrix The matrix to be applied to the image
  112799. * @param options The required width/height ratio to downsize to before computing the render pass.
  112800. * @param camera The camera to apply the render pass to.
  112801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112802. * @param engine The engine which the post process will be applied. (default: current engine)
  112803. * @param reusable If the post process can be reused on the same frame. (default: false)
  112804. */
  112805. constructor(name: string,
  112806. /** The matrix to be applied to the image */
  112807. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112808. }
  112809. }
  112810. declare module BABYLON {
  112811. /** @hidden */
  112812. export var fxaaPixelShader: {
  112813. name: string;
  112814. shader: string;
  112815. };
  112816. }
  112817. declare module BABYLON {
  112818. /** @hidden */
  112819. export var fxaaVertexShader: {
  112820. name: string;
  112821. shader: string;
  112822. };
  112823. }
  112824. declare module BABYLON {
  112825. /**
  112826. * Fxaa post process
  112827. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  112828. */
  112829. export class FxaaPostProcess extends PostProcess {
  112830. /** @hidden */
  112831. texelWidth: number;
  112832. /** @hidden */
  112833. texelHeight: number;
  112834. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112835. private _getDefines;
  112836. }
  112837. }
  112838. declare module BABYLON {
  112839. /** @hidden */
  112840. export var grainPixelShader: {
  112841. name: string;
  112842. shader: string;
  112843. };
  112844. }
  112845. declare module BABYLON {
  112846. /**
  112847. * The GrainPostProcess adds noise to the image at mid luminance levels
  112848. */
  112849. export class GrainPostProcess extends PostProcess {
  112850. /**
  112851. * The intensity of the grain added (default: 30)
  112852. */
  112853. intensity: number;
  112854. /**
  112855. * If the grain should be randomized on every frame
  112856. */
  112857. animated: boolean;
  112858. /**
  112859. * Creates a new instance of @see GrainPostProcess
  112860. * @param name The name of the effect.
  112861. * @param options The required width/height ratio to downsize to before computing the render pass.
  112862. * @param camera The camera to apply the render pass to.
  112863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112864. * @param engine The engine which the post process will be applied. (default: current engine)
  112865. * @param reusable If the post process can be reused on the same frame. (default: false)
  112866. * @param textureType Type of textures used when performing the post process. (default: 0)
  112867. * @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)
  112868. */
  112869. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112870. }
  112871. }
  112872. declare module BABYLON {
  112873. /** @hidden */
  112874. export var highlightsPixelShader: {
  112875. name: string;
  112876. shader: string;
  112877. };
  112878. }
  112879. declare module BABYLON {
  112880. /**
  112881. * Extracts highlights from the image
  112882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112883. */
  112884. export class HighlightsPostProcess extends PostProcess {
  112885. /**
  112886. * Extracts highlights from the image
  112887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112888. * @param name The name of the effect.
  112889. * @param options The required width/height ratio to downsize to before computing the render pass.
  112890. * @param camera The camera to apply the render pass to.
  112891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112892. * @param engine The engine which the post process will be applied. (default: current engine)
  112893. * @param reusable If the post process can be reused on the same frame. (default: false)
  112894. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  112895. */
  112896. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112897. }
  112898. }
  112899. declare module BABYLON {
  112900. /** @hidden */
  112901. export var mrtFragmentDeclaration: {
  112902. name: string;
  112903. shader: string;
  112904. };
  112905. }
  112906. declare module BABYLON {
  112907. /** @hidden */
  112908. export var geometryPixelShader: {
  112909. name: string;
  112910. shader: string;
  112911. };
  112912. }
  112913. declare module BABYLON {
  112914. /** @hidden */
  112915. export var geometryVertexShader: {
  112916. name: string;
  112917. shader: string;
  112918. };
  112919. }
  112920. declare module BABYLON {
  112921. /**
  112922. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112923. */
  112924. export class GeometryBufferRenderer {
  112925. /**
  112926. * Constant used to retrieve the position texture index in the G-Buffer textures array
  112927. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  112928. */
  112929. static readonly POSITION_TEXTURE_TYPE: number;
  112930. /**
  112931. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112932. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112933. */
  112934. static readonly VELOCITY_TEXTURE_TYPE: number;
  112935. /**
  112936. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112937. * in order to compute objects velocities when enableVelocity is set to "true"
  112938. * @hidden
  112939. */
  112940. _previousTransformationMatrices: {
  112941. [index: number]: Matrix;
  112942. };
  112943. private _scene;
  112944. private _multiRenderTarget;
  112945. private _ratio;
  112946. private _enablePosition;
  112947. private _enableVelocity;
  112948. private _positionIndex;
  112949. private _velocityIndex;
  112950. protected _effect: Effect;
  112951. protected _cachedDefines: string;
  112952. /**
  112953. * Set the render list (meshes to be rendered) used in the G buffer.
  112954. */
  112955. renderList: Mesh[];
  112956. /**
  112957. * Gets wether or not G buffer are supported by the running hardware.
  112958. * This requires draw buffer supports
  112959. */
  112960. readonly isSupported: boolean;
  112961. /**
  112962. * Returns the index of the given texture type in the G-Buffer textures array
  112963. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112964. * @returns the index of the given texture type in the G-Buffer textures array
  112965. */
  112966. getTextureIndex(textureType: number): number;
  112967. /**
  112968. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112969. */
  112970. /**
  112971. * Sets whether or not objects positions are enabled for the G buffer.
  112972. */
  112973. enablePosition: boolean;
  112974. /**
  112975. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112976. */
  112977. /**
  112978. * Sets wether or not objects velocities are enabled for the G buffer.
  112979. */
  112980. enableVelocity: boolean;
  112981. /**
  112982. * Gets the scene associated with the buffer.
  112983. */
  112984. readonly scene: Scene;
  112985. /**
  112986. * Gets the ratio used by the buffer during its creation.
  112987. * How big is the buffer related to the main canvas.
  112988. */
  112989. readonly ratio: number;
  112990. /** @hidden */
  112991. static _SceneComponentInitialization: (scene: Scene) => void;
  112992. /**
  112993. * Creates a new G Buffer for the scene
  112994. * @param scene The scene the buffer belongs to
  112995. * @param ratio How big is the buffer related to the main canvas.
  112996. */
  112997. constructor(scene: Scene, ratio?: number);
  112998. /**
  112999. * Checks wether everything is ready to render a submesh to the G buffer.
  113000. * @param subMesh the submesh to check readiness for
  113001. * @param useInstances is the mesh drawn using instance or not
  113002. * @returns true if ready otherwise false
  113003. */
  113004. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113005. /**
  113006. * Gets the current underlying G Buffer.
  113007. * @returns the buffer
  113008. */
  113009. getGBuffer(): MultiRenderTarget;
  113010. /**
  113011. * Gets the number of samples used to render the buffer (anti aliasing).
  113012. */
  113013. /**
  113014. * Sets the number of samples used to render the buffer (anti aliasing).
  113015. */
  113016. samples: number;
  113017. /**
  113018. * Disposes the renderer and frees up associated resources.
  113019. */
  113020. dispose(): void;
  113021. protected _createRenderTargets(): void;
  113022. }
  113023. }
  113024. declare module BABYLON {
  113025. interface Scene {
  113026. /** @hidden (Backing field) */
  113027. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113028. /**
  113029. * Gets or Sets the current geometry buffer associated to the scene.
  113030. */
  113031. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113032. /**
  113033. * Enables a GeometryBufferRender and associates it with the scene
  113034. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  113035. * @returns the GeometryBufferRenderer
  113036. */
  113037. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  113038. /**
  113039. * Disables the GeometryBufferRender associated with the scene
  113040. */
  113041. disableGeometryBufferRenderer(): void;
  113042. }
  113043. /**
  113044. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  113045. * in several rendering techniques.
  113046. */
  113047. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  113048. /**
  113049. * The component name helpful to identify the component in the list of scene components.
  113050. */
  113051. readonly name: string;
  113052. /**
  113053. * The scene the component belongs to.
  113054. */
  113055. scene: Scene;
  113056. /**
  113057. * Creates a new instance of the component for the given scene
  113058. * @param scene Defines the scene to register the component in
  113059. */
  113060. constructor(scene: Scene);
  113061. /**
  113062. * Registers the component in a given scene
  113063. */
  113064. register(): void;
  113065. /**
  113066. * Rebuilds the elements related to this component in case of
  113067. * context lost for instance.
  113068. */
  113069. rebuild(): void;
  113070. /**
  113071. * Disposes the component and the associated ressources
  113072. */
  113073. dispose(): void;
  113074. private _gatherRenderTargets;
  113075. }
  113076. }
  113077. declare module BABYLON {
  113078. /** @hidden */
  113079. export var motionBlurPixelShader: {
  113080. name: string;
  113081. shader: string;
  113082. };
  113083. }
  113084. declare module BABYLON {
  113085. /**
  113086. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  113087. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  113088. * As an example, all you have to do is to create the post-process:
  113089. * var mb = new BABYLON.MotionBlurPostProcess(
  113090. * 'mb', // The name of the effect.
  113091. * scene, // The scene containing the objects to blur according to their velocity.
  113092. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  113093. * camera // The camera to apply the render pass to.
  113094. * );
  113095. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  113096. */
  113097. export class MotionBlurPostProcess extends PostProcess {
  113098. /**
  113099. * Defines how much the image is blurred by the movement. Default value is equal to 1
  113100. */
  113101. motionStrength: number;
  113102. /**
  113103. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  113104. */
  113105. /**
  113106. * Sets the number of iterations to be used for motion blur quality
  113107. */
  113108. motionBlurSamples: number;
  113109. private _motionBlurSamples;
  113110. private _geometryBufferRenderer;
  113111. /**
  113112. * Creates a new instance MotionBlurPostProcess
  113113. * @param name The name of the effect.
  113114. * @param scene The scene containing the objects to blur according to their velocity.
  113115. * @param options The required width/height ratio to downsize to before computing the render pass.
  113116. * @param camera The camera to apply the render pass to.
  113117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113118. * @param engine The engine which the post process will be applied. (default: current engine)
  113119. * @param reusable If the post process can be reused on the same frame. (default: false)
  113120. * @param textureType Type of textures used when performing the post process. (default: 0)
  113121. * @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)
  113122. */
  113123. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113124. /**
  113125. * Disposes the post process.
  113126. * @param camera The camera to dispose the post process on.
  113127. */
  113128. dispose(camera?: Camera): void;
  113129. }
  113130. }
  113131. declare module BABYLON {
  113132. /** @hidden */
  113133. export var refractionPixelShader: {
  113134. name: string;
  113135. shader: string;
  113136. };
  113137. }
  113138. declare module BABYLON {
  113139. /**
  113140. * Post process which applies a refractin texture
  113141. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113142. */
  113143. export class RefractionPostProcess extends PostProcess {
  113144. /** the base color of the refraction (used to taint the rendering) */
  113145. color: Color3;
  113146. /** simulated refraction depth */
  113147. depth: number;
  113148. /** the coefficient of the base color (0 to remove base color tainting) */
  113149. colorLevel: number;
  113150. private _refTexture;
  113151. private _ownRefractionTexture;
  113152. /**
  113153. * Gets or sets the refraction texture
  113154. * Please note that you are responsible for disposing the texture if you set it manually
  113155. */
  113156. refractionTexture: Texture;
  113157. /**
  113158. * Initializes the RefractionPostProcess
  113159. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113160. * @param name The name of the effect.
  113161. * @param refractionTextureUrl Url of the refraction texture to use
  113162. * @param color the base color of the refraction (used to taint the rendering)
  113163. * @param depth simulated refraction depth
  113164. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  113165. * @param camera The camera to apply the render pass to.
  113166. * @param options The required width/height ratio to downsize to before computing the render pass.
  113167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113168. * @param engine The engine which the post process will be applied. (default: current engine)
  113169. * @param reusable If the post process can be reused on the same frame. (default: false)
  113170. */
  113171. constructor(name: string, refractionTextureUrl: string,
  113172. /** the base color of the refraction (used to taint the rendering) */
  113173. color: Color3,
  113174. /** simulated refraction depth */
  113175. depth: number,
  113176. /** the coefficient of the base color (0 to remove base color tainting) */
  113177. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113178. /**
  113179. * Disposes of the post process
  113180. * @param camera Camera to dispose post process on
  113181. */
  113182. dispose(camera: Camera): void;
  113183. }
  113184. }
  113185. declare module BABYLON {
  113186. /** @hidden */
  113187. export var sharpenPixelShader: {
  113188. name: string;
  113189. shader: string;
  113190. };
  113191. }
  113192. declare module BABYLON {
  113193. /**
  113194. * The SharpenPostProcess applies a sharpen kernel to every pixel
  113195. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  113196. */
  113197. export class SharpenPostProcess extends PostProcess {
  113198. /**
  113199. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  113200. */
  113201. colorAmount: number;
  113202. /**
  113203. * How much sharpness should be applied (default: 0.3)
  113204. */
  113205. edgeAmount: number;
  113206. /**
  113207. * Creates a new instance ConvolutionPostProcess
  113208. * @param name The name of the effect.
  113209. * @param options The required width/height ratio to downsize to before computing the render pass.
  113210. * @param camera The camera to apply the render pass to.
  113211. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113212. * @param engine The engine which the post process will be applied. (default: current engine)
  113213. * @param reusable If the post process can be reused on the same frame. (default: false)
  113214. * @param textureType Type of textures used when performing the post process. (default: 0)
  113215. * @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)
  113216. */
  113217. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113218. }
  113219. }
  113220. declare module BABYLON {
  113221. /**
  113222. * PostProcessRenderPipeline
  113223. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113224. */
  113225. export class PostProcessRenderPipeline {
  113226. private engine;
  113227. private _renderEffects;
  113228. private _renderEffectsForIsolatedPass;
  113229. /**
  113230. * List of inspectable custom properties (used by the Inspector)
  113231. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113232. */
  113233. inspectableCustomProperties: IInspectable[];
  113234. /**
  113235. * @hidden
  113236. */
  113237. protected _cameras: Camera[];
  113238. /** @hidden */
  113239. _name: string;
  113240. /**
  113241. * Gets pipeline name
  113242. */
  113243. readonly name: string;
  113244. /**
  113245. * Initializes a PostProcessRenderPipeline
  113246. * @param engine engine to add the pipeline to
  113247. * @param name name of the pipeline
  113248. */
  113249. constructor(engine: Engine, name: string);
  113250. /**
  113251. * Gets the class name
  113252. * @returns "PostProcessRenderPipeline"
  113253. */
  113254. getClassName(): string;
  113255. /**
  113256. * If all the render effects in the pipeline are supported
  113257. */
  113258. readonly isSupported: boolean;
  113259. /**
  113260. * Adds an effect to the pipeline
  113261. * @param renderEffect the effect to add
  113262. */
  113263. addEffect(renderEffect: PostProcessRenderEffect): void;
  113264. /** @hidden */
  113265. _rebuild(): void;
  113266. /** @hidden */
  113267. _enableEffect(renderEffectName: string, cameras: Camera): void;
  113268. /** @hidden */
  113269. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  113270. /** @hidden */
  113271. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113272. /** @hidden */
  113273. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113274. /** @hidden */
  113275. _attachCameras(cameras: Camera, unique: boolean): void;
  113276. /** @hidden */
  113277. _attachCameras(cameras: Camera[], unique: boolean): void;
  113278. /** @hidden */
  113279. _detachCameras(cameras: Camera): void;
  113280. /** @hidden */
  113281. _detachCameras(cameras: Nullable<Camera[]>): void;
  113282. /** @hidden */
  113283. _update(): void;
  113284. /** @hidden */
  113285. _reset(): void;
  113286. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  113287. /**
  113288. * Disposes of the pipeline
  113289. */
  113290. dispose(): void;
  113291. }
  113292. }
  113293. declare module BABYLON {
  113294. /**
  113295. * PostProcessRenderPipelineManager class
  113296. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113297. */
  113298. export class PostProcessRenderPipelineManager {
  113299. private _renderPipelines;
  113300. /**
  113301. * Initializes a PostProcessRenderPipelineManager
  113302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113303. */
  113304. constructor();
  113305. /**
  113306. * Gets the list of supported render pipelines
  113307. */
  113308. readonly supportedPipelines: PostProcessRenderPipeline[];
  113309. /**
  113310. * Adds a pipeline to the manager
  113311. * @param renderPipeline The pipeline to add
  113312. */
  113313. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  113314. /**
  113315. * Attaches a camera to the pipeline
  113316. * @param renderPipelineName The name of the pipeline to attach to
  113317. * @param cameras the camera to attach
  113318. * @param unique if the camera can be attached multiple times to the pipeline
  113319. */
  113320. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  113321. /**
  113322. * Detaches a camera from the pipeline
  113323. * @param renderPipelineName The name of the pipeline to detach from
  113324. * @param cameras the camera to detach
  113325. */
  113326. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  113327. /**
  113328. * Enables an effect by name on a pipeline
  113329. * @param renderPipelineName the name of the pipeline to enable the effect in
  113330. * @param renderEffectName the name of the effect to enable
  113331. * @param cameras the cameras that the effect should be enabled on
  113332. */
  113333. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113334. /**
  113335. * Disables an effect by name on a pipeline
  113336. * @param renderPipelineName the name of the pipeline to disable the effect in
  113337. * @param renderEffectName the name of the effect to disable
  113338. * @param cameras the cameras that the effect should be disabled on
  113339. */
  113340. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113341. /**
  113342. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  113343. */
  113344. update(): void;
  113345. /** @hidden */
  113346. _rebuild(): void;
  113347. /**
  113348. * Disposes of the manager and pipelines
  113349. */
  113350. dispose(): void;
  113351. }
  113352. }
  113353. declare module BABYLON {
  113354. interface Scene {
  113355. /** @hidden (Backing field) */
  113356. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113357. /**
  113358. * Gets the postprocess render pipeline manager
  113359. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113360. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113361. */
  113362. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113363. }
  113364. /**
  113365. * Defines the Render Pipeline scene component responsible to rendering pipelines
  113366. */
  113367. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  113368. /**
  113369. * The component name helpfull to identify the component in the list of scene components.
  113370. */
  113371. readonly name: string;
  113372. /**
  113373. * The scene the component belongs to.
  113374. */
  113375. scene: Scene;
  113376. /**
  113377. * Creates a new instance of the component for the given scene
  113378. * @param scene Defines the scene to register the component in
  113379. */
  113380. constructor(scene: Scene);
  113381. /**
  113382. * Registers the component in a given scene
  113383. */
  113384. register(): void;
  113385. /**
  113386. * Rebuilds the elements related to this component in case of
  113387. * context lost for instance.
  113388. */
  113389. rebuild(): void;
  113390. /**
  113391. * Disposes the component and the associated ressources
  113392. */
  113393. dispose(): void;
  113394. private _gatherRenderTargets;
  113395. }
  113396. }
  113397. declare module BABYLON {
  113398. /**
  113399. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113400. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113401. */
  113402. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113403. private _scene;
  113404. private _camerasToBeAttached;
  113405. /**
  113406. * ID of the sharpen post process,
  113407. */
  113408. private readonly SharpenPostProcessId;
  113409. /**
  113410. * @ignore
  113411. * ID of the image processing post process;
  113412. */
  113413. readonly ImageProcessingPostProcessId: string;
  113414. /**
  113415. * @ignore
  113416. * ID of the Fast Approximate Anti-Aliasing post process;
  113417. */
  113418. readonly FxaaPostProcessId: string;
  113419. /**
  113420. * ID of the chromatic aberration post process,
  113421. */
  113422. private readonly ChromaticAberrationPostProcessId;
  113423. /**
  113424. * ID of the grain post process
  113425. */
  113426. private readonly GrainPostProcessId;
  113427. /**
  113428. * Sharpen post process which will apply a sharpen convolution to enhance edges
  113429. */
  113430. sharpen: SharpenPostProcess;
  113431. private _sharpenEffect;
  113432. private bloom;
  113433. /**
  113434. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  113435. */
  113436. depthOfField: DepthOfFieldEffect;
  113437. /**
  113438. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113439. */
  113440. fxaa: FxaaPostProcess;
  113441. /**
  113442. * Image post processing pass used to perform operations such as tone mapping or color grading.
  113443. */
  113444. imageProcessing: ImageProcessingPostProcess;
  113445. /**
  113446. * Chromatic aberration post process which will shift rgb colors in the image
  113447. */
  113448. chromaticAberration: ChromaticAberrationPostProcess;
  113449. private _chromaticAberrationEffect;
  113450. /**
  113451. * Grain post process which add noise to the image
  113452. */
  113453. grain: GrainPostProcess;
  113454. private _grainEffect;
  113455. /**
  113456. * Glow post process which adds a glow to emissive areas of the image
  113457. */
  113458. private _glowLayer;
  113459. /**
  113460. * Animations which can be used to tweak settings over a period of time
  113461. */
  113462. animations: Animation[];
  113463. private _imageProcessingConfigurationObserver;
  113464. private _sharpenEnabled;
  113465. private _bloomEnabled;
  113466. private _depthOfFieldEnabled;
  113467. private _depthOfFieldBlurLevel;
  113468. private _fxaaEnabled;
  113469. private _imageProcessingEnabled;
  113470. private _defaultPipelineTextureType;
  113471. private _bloomScale;
  113472. private _chromaticAberrationEnabled;
  113473. private _grainEnabled;
  113474. private _buildAllowed;
  113475. /**
  113476. * Gets active scene
  113477. */
  113478. readonly scene: Scene;
  113479. /**
  113480. * Enable or disable the sharpen process from the pipeline
  113481. */
  113482. sharpenEnabled: boolean;
  113483. private _resizeObserver;
  113484. private _hardwareScaleLevel;
  113485. private _bloomKernel;
  113486. /**
  113487. * Specifies the size of the bloom blur kernel, relative to the final output size
  113488. */
  113489. bloomKernel: number;
  113490. /**
  113491. * Specifies the weight of the bloom in the final rendering
  113492. */
  113493. private _bloomWeight;
  113494. /**
  113495. * Specifies the luma threshold for the area that will be blurred by the bloom
  113496. */
  113497. private _bloomThreshold;
  113498. private _hdr;
  113499. /**
  113500. * The strength of the bloom.
  113501. */
  113502. bloomWeight: number;
  113503. /**
  113504. * The strength of the bloom.
  113505. */
  113506. bloomThreshold: number;
  113507. /**
  113508. * The scale of the bloom, lower value will provide better performance.
  113509. */
  113510. bloomScale: number;
  113511. /**
  113512. * Enable or disable the bloom from the pipeline
  113513. */
  113514. bloomEnabled: boolean;
  113515. private _rebuildBloom;
  113516. /**
  113517. * If the depth of field is enabled.
  113518. */
  113519. depthOfFieldEnabled: boolean;
  113520. /**
  113521. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113522. */
  113523. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  113524. /**
  113525. * If the anti aliasing is enabled.
  113526. */
  113527. fxaaEnabled: boolean;
  113528. private _samples;
  113529. /**
  113530. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113531. */
  113532. samples: number;
  113533. /**
  113534. * If image processing is enabled.
  113535. */
  113536. imageProcessingEnabled: boolean;
  113537. /**
  113538. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113539. */
  113540. glowLayerEnabled: boolean;
  113541. /**
  113542. * Enable or disable the chromaticAberration process from the pipeline
  113543. */
  113544. chromaticAberrationEnabled: boolean;
  113545. /**
  113546. * Enable or disable the grain process from the pipeline
  113547. */
  113548. grainEnabled: boolean;
  113549. /**
  113550. * @constructor
  113551. * @param name - The rendering pipeline name (default: "")
  113552. * @param hdr - If high dynamic range textures should be used (default: true)
  113553. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113554. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113555. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113556. */
  113557. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113558. /**
  113559. * Get the class name
  113560. * @returns "DefaultRenderingPipeline"
  113561. */
  113562. getClassName(): string;
  113563. /**
  113564. * Force the compilation of the entire pipeline.
  113565. */
  113566. prepare(): void;
  113567. private _hasCleared;
  113568. private _prevPostProcess;
  113569. private _prevPrevPostProcess;
  113570. private _setAutoClearAndTextureSharing;
  113571. private _depthOfFieldSceneObserver;
  113572. private _buildPipeline;
  113573. private _disposePostProcesses;
  113574. /**
  113575. * Adds a camera to the pipeline
  113576. * @param camera the camera to be added
  113577. */
  113578. addCamera(camera: Camera): void;
  113579. /**
  113580. * Removes a camera from the pipeline
  113581. * @param camera the camera to remove
  113582. */
  113583. removeCamera(camera: Camera): void;
  113584. /**
  113585. * Dispose of the pipeline and stop all post processes
  113586. */
  113587. dispose(): void;
  113588. /**
  113589. * Serialize the rendering pipeline (Used when exporting)
  113590. * @returns the serialized object
  113591. */
  113592. serialize(): any;
  113593. /**
  113594. * Parse the serialized pipeline
  113595. * @param source Source pipeline.
  113596. * @param scene The scene to load the pipeline to.
  113597. * @param rootUrl The URL of the serialized pipeline.
  113598. * @returns An instantiated pipeline from the serialized object.
  113599. */
  113600. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113601. }
  113602. }
  113603. declare module BABYLON {
  113604. /** @hidden */
  113605. export var lensHighlightsPixelShader: {
  113606. name: string;
  113607. shader: string;
  113608. };
  113609. }
  113610. declare module BABYLON {
  113611. /** @hidden */
  113612. export var depthOfFieldPixelShader: {
  113613. name: string;
  113614. shader: string;
  113615. };
  113616. }
  113617. declare module BABYLON {
  113618. /**
  113619. * BABYLON.JS Chromatic Aberration GLSL Shader
  113620. * Author: Olivier Guyot
  113621. * Separates very slightly R, G and B colors on the edges of the screen
  113622. * Inspired by Francois Tarlier & Martins Upitis
  113623. */
  113624. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113625. /**
  113626. * @ignore
  113627. * The chromatic aberration PostProcess id in the pipeline
  113628. */
  113629. LensChromaticAberrationEffect: string;
  113630. /**
  113631. * @ignore
  113632. * The highlights enhancing PostProcess id in the pipeline
  113633. */
  113634. HighlightsEnhancingEffect: string;
  113635. /**
  113636. * @ignore
  113637. * The depth-of-field PostProcess id in the pipeline
  113638. */
  113639. LensDepthOfFieldEffect: string;
  113640. private _scene;
  113641. private _depthTexture;
  113642. private _grainTexture;
  113643. private _chromaticAberrationPostProcess;
  113644. private _highlightsPostProcess;
  113645. private _depthOfFieldPostProcess;
  113646. private _edgeBlur;
  113647. private _grainAmount;
  113648. private _chromaticAberration;
  113649. private _distortion;
  113650. private _highlightsGain;
  113651. private _highlightsThreshold;
  113652. private _dofDistance;
  113653. private _dofAperture;
  113654. private _dofDarken;
  113655. private _dofPentagon;
  113656. private _blurNoise;
  113657. /**
  113658. * @constructor
  113659. *
  113660. * Effect parameters are as follow:
  113661. * {
  113662. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113663. * edge_blur: number; // from 0 to x (1 for realism)
  113664. * distortion: number; // from 0 to x (1 for realism)
  113665. * grain_amount: number; // from 0 to 1
  113666. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113667. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113668. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113669. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113670. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113671. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113672. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113673. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113674. * }
  113675. * Note: if an effect parameter is unset, effect is disabled
  113676. *
  113677. * @param name The rendering pipeline name
  113678. * @param parameters - An object containing all parameters (see above)
  113679. * @param scene The scene linked to this pipeline
  113680. * @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)
  113681. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113682. */
  113683. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113684. /**
  113685. * Get the class name
  113686. * @returns "LensRenderingPipeline"
  113687. */
  113688. getClassName(): string;
  113689. /**
  113690. * Gets associated scene
  113691. */
  113692. readonly scene: Scene;
  113693. /**
  113694. * Gets or sets the edge blur
  113695. */
  113696. edgeBlur: number;
  113697. /**
  113698. * Gets or sets the grain amount
  113699. */
  113700. grainAmount: number;
  113701. /**
  113702. * Gets or sets the chromatic aberration amount
  113703. */
  113704. chromaticAberration: number;
  113705. /**
  113706. * Gets or sets the depth of field aperture
  113707. */
  113708. dofAperture: number;
  113709. /**
  113710. * Gets or sets the edge distortion
  113711. */
  113712. edgeDistortion: number;
  113713. /**
  113714. * Gets or sets the depth of field distortion
  113715. */
  113716. dofDistortion: number;
  113717. /**
  113718. * Gets or sets the darken out of focus amount
  113719. */
  113720. darkenOutOfFocus: number;
  113721. /**
  113722. * Gets or sets a boolean indicating if blur noise is enabled
  113723. */
  113724. blurNoise: boolean;
  113725. /**
  113726. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113727. */
  113728. pentagonBokeh: boolean;
  113729. /**
  113730. * Gets or sets the highlight grain amount
  113731. */
  113732. highlightsGain: number;
  113733. /**
  113734. * Gets or sets the highlight threshold
  113735. */
  113736. highlightsThreshold: number;
  113737. /**
  113738. * Sets the amount of blur at the edges
  113739. * @param amount blur amount
  113740. */
  113741. setEdgeBlur(amount: number): void;
  113742. /**
  113743. * Sets edge blur to 0
  113744. */
  113745. disableEdgeBlur(): void;
  113746. /**
  113747. * Sets the amout of grain
  113748. * @param amount Amount of grain
  113749. */
  113750. setGrainAmount(amount: number): void;
  113751. /**
  113752. * Set grain amount to 0
  113753. */
  113754. disableGrain(): void;
  113755. /**
  113756. * Sets the chromatic aberration amount
  113757. * @param amount amount of chromatic aberration
  113758. */
  113759. setChromaticAberration(amount: number): void;
  113760. /**
  113761. * Sets chromatic aberration amount to 0
  113762. */
  113763. disableChromaticAberration(): void;
  113764. /**
  113765. * Sets the EdgeDistortion amount
  113766. * @param amount amount of EdgeDistortion
  113767. */
  113768. setEdgeDistortion(amount: number): void;
  113769. /**
  113770. * Sets edge distortion to 0
  113771. */
  113772. disableEdgeDistortion(): void;
  113773. /**
  113774. * Sets the FocusDistance amount
  113775. * @param amount amount of FocusDistance
  113776. */
  113777. setFocusDistance(amount: number): void;
  113778. /**
  113779. * Disables depth of field
  113780. */
  113781. disableDepthOfField(): void;
  113782. /**
  113783. * Sets the Aperture amount
  113784. * @param amount amount of Aperture
  113785. */
  113786. setAperture(amount: number): void;
  113787. /**
  113788. * Sets the DarkenOutOfFocus amount
  113789. * @param amount amount of DarkenOutOfFocus
  113790. */
  113791. setDarkenOutOfFocus(amount: number): void;
  113792. private _pentagonBokehIsEnabled;
  113793. /**
  113794. * Creates a pentagon bokeh effect
  113795. */
  113796. enablePentagonBokeh(): void;
  113797. /**
  113798. * Disables the pentagon bokeh effect
  113799. */
  113800. disablePentagonBokeh(): void;
  113801. /**
  113802. * Enables noise blur
  113803. */
  113804. enableNoiseBlur(): void;
  113805. /**
  113806. * Disables noise blur
  113807. */
  113808. disableNoiseBlur(): void;
  113809. /**
  113810. * Sets the HighlightsGain amount
  113811. * @param amount amount of HighlightsGain
  113812. */
  113813. setHighlightsGain(amount: number): void;
  113814. /**
  113815. * Sets the HighlightsThreshold amount
  113816. * @param amount amount of HighlightsThreshold
  113817. */
  113818. setHighlightsThreshold(amount: number): void;
  113819. /**
  113820. * Disables highlights
  113821. */
  113822. disableHighlights(): void;
  113823. /**
  113824. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113825. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113826. */
  113827. dispose(disableDepthRender?: boolean): void;
  113828. private _createChromaticAberrationPostProcess;
  113829. private _createHighlightsPostProcess;
  113830. private _createDepthOfFieldPostProcess;
  113831. private _createGrainTexture;
  113832. }
  113833. }
  113834. declare module BABYLON {
  113835. /** @hidden */
  113836. export var ssao2PixelShader: {
  113837. name: string;
  113838. shader: string;
  113839. };
  113840. }
  113841. declare module BABYLON {
  113842. /** @hidden */
  113843. export var ssaoCombinePixelShader: {
  113844. name: string;
  113845. shader: string;
  113846. };
  113847. }
  113848. declare module BABYLON {
  113849. /**
  113850. * Render pipeline to produce ssao effect
  113851. */
  113852. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  113853. /**
  113854. * @ignore
  113855. * The PassPostProcess id in the pipeline that contains the original scene color
  113856. */
  113857. SSAOOriginalSceneColorEffect: string;
  113858. /**
  113859. * @ignore
  113860. * The SSAO PostProcess id in the pipeline
  113861. */
  113862. SSAORenderEffect: string;
  113863. /**
  113864. * @ignore
  113865. * The horizontal blur PostProcess id in the pipeline
  113866. */
  113867. SSAOBlurHRenderEffect: string;
  113868. /**
  113869. * @ignore
  113870. * The vertical blur PostProcess id in the pipeline
  113871. */
  113872. SSAOBlurVRenderEffect: string;
  113873. /**
  113874. * @ignore
  113875. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113876. */
  113877. SSAOCombineRenderEffect: string;
  113878. /**
  113879. * The output strength of the SSAO post-process. Default value is 1.0.
  113880. */
  113881. totalStrength: number;
  113882. /**
  113883. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113884. */
  113885. maxZ: number;
  113886. /**
  113887. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113888. */
  113889. minZAspect: number;
  113890. private _samples;
  113891. /**
  113892. * Number of samples used for the SSAO calculations. Default value is 8
  113893. */
  113894. samples: number;
  113895. private _textureSamples;
  113896. /**
  113897. * Number of samples to use for antialiasing
  113898. */
  113899. textureSamples: number;
  113900. /**
  113901. * Ratio object used for SSAO ratio and blur ratio
  113902. */
  113903. private _ratio;
  113904. /**
  113905. * Dynamically generated sphere sampler.
  113906. */
  113907. private _sampleSphere;
  113908. /**
  113909. * Blur filter offsets
  113910. */
  113911. private _samplerOffsets;
  113912. private _expensiveBlur;
  113913. /**
  113914. * If bilateral blur should be used
  113915. */
  113916. expensiveBlur: boolean;
  113917. /**
  113918. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113919. */
  113920. radius: number;
  113921. /**
  113922. * The base color of the SSAO post-process
  113923. * The final result is "base + ssao" between [0, 1]
  113924. */
  113925. base: number;
  113926. /**
  113927. * Support test.
  113928. */
  113929. static readonly IsSupported: boolean;
  113930. private _scene;
  113931. private _depthTexture;
  113932. private _normalTexture;
  113933. private _randomTexture;
  113934. private _originalColorPostProcess;
  113935. private _ssaoPostProcess;
  113936. private _blurHPostProcess;
  113937. private _blurVPostProcess;
  113938. private _ssaoCombinePostProcess;
  113939. private _firstUpdate;
  113940. /**
  113941. * Gets active scene
  113942. */
  113943. readonly scene: Scene;
  113944. /**
  113945. * @constructor
  113946. * @param name The rendering pipeline name
  113947. * @param scene The scene linked to this pipeline
  113948. * @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 }
  113949. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113950. */
  113951. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113952. /**
  113953. * Get the class name
  113954. * @returns "SSAO2RenderingPipeline"
  113955. */
  113956. getClassName(): string;
  113957. /**
  113958. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113959. */
  113960. dispose(disableGeometryBufferRenderer?: boolean): void;
  113961. private _createBlurPostProcess;
  113962. /** @hidden */
  113963. _rebuild(): void;
  113964. private _bits;
  113965. private _radicalInverse_VdC;
  113966. private _hammersley;
  113967. private _hemisphereSample_uniform;
  113968. private _generateHemisphere;
  113969. private _createSSAOPostProcess;
  113970. private _createSSAOCombinePostProcess;
  113971. private _createRandomTexture;
  113972. /**
  113973. * Serialize the rendering pipeline (Used when exporting)
  113974. * @returns the serialized object
  113975. */
  113976. serialize(): any;
  113977. /**
  113978. * Parse the serialized pipeline
  113979. * @param source Source pipeline.
  113980. * @param scene The scene to load the pipeline to.
  113981. * @param rootUrl The URL of the serialized pipeline.
  113982. * @returns An instantiated pipeline from the serialized object.
  113983. */
  113984. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  113985. }
  113986. }
  113987. declare module BABYLON {
  113988. /** @hidden */
  113989. export var ssaoPixelShader: {
  113990. name: string;
  113991. shader: string;
  113992. };
  113993. }
  113994. declare module BABYLON {
  113995. /**
  113996. * Render pipeline to produce ssao effect
  113997. */
  113998. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  113999. /**
  114000. * @ignore
  114001. * The PassPostProcess id in the pipeline that contains the original scene color
  114002. */
  114003. SSAOOriginalSceneColorEffect: string;
  114004. /**
  114005. * @ignore
  114006. * The SSAO PostProcess id in the pipeline
  114007. */
  114008. SSAORenderEffect: string;
  114009. /**
  114010. * @ignore
  114011. * The horizontal blur PostProcess id in the pipeline
  114012. */
  114013. SSAOBlurHRenderEffect: string;
  114014. /**
  114015. * @ignore
  114016. * The vertical blur PostProcess id in the pipeline
  114017. */
  114018. SSAOBlurVRenderEffect: string;
  114019. /**
  114020. * @ignore
  114021. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114022. */
  114023. SSAOCombineRenderEffect: string;
  114024. /**
  114025. * The output strength of the SSAO post-process. Default value is 1.0.
  114026. */
  114027. totalStrength: number;
  114028. /**
  114029. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114030. */
  114031. radius: number;
  114032. /**
  114033. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114034. * Must not be equal to fallOff and superior to fallOff.
  114035. * Default value is 0.0075
  114036. */
  114037. area: number;
  114038. /**
  114039. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114040. * Must not be equal to area and inferior to area.
  114041. * Default value is 0.000001
  114042. */
  114043. fallOff: number;
  114044. /**
  114045. * The base color of the SSAO post-process
  114046. * The final result is "base + ssao" between [0, 1]
  114047. */
  114048. base: number;
  114049. private _scene;
  114050. private _depthTexture;
  114051. private _randomTexture;
  114052. private _originalColorPostProcess;
  114053. private _ssaoPostProcess;
  114054. private _blurHPostProcess;
  114055. private _blurVPostProcess;
  114056. private _ssaoCombinePostProcess;
  114057. private _firstUpdate;
  114058. /**
  114059. * Gets active scene
  114060. */
  114061. readonly scene: Scene;
  114062. /**
  114063. * @constructor
  114064. * @param name - The rendering pipeline name
  114065. * @param scene - The scene linked to this pipeline
  114066. * @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 }
  114067. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114068. */
  114069. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114070. /**
  114071. * Get the class name
  114072. * @returns "SSAORenderingPipeline"
  114073. */
  114074. getClassName(): string;
  114075. /**
  114076. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114077. */
  114078. dispose(disableDepthRender?: boolean): void;
  114079. private _createBlurPostProcess;
  114080. /** @hidden */
  114081. _rebuild(): void;
  114082. private _createSSAOPostProcess;
  114083. private _createSSAOCombinePostProcess;
  114084. private _createRandomTexture;
  114085. }
  114086. }
  114087. declare module BABYLON {
  114088. /** @hidden */
  114089. export var standardPixelShader: {
  114090. name: string;
  114091. shader: string;
  114092. };
  114093. }
  114094. declare module BABYLON {
  114095. /**
  114096. * Standard rendering pipeline
  114097. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114098. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114099. */
  114100. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  114101. /**
  114102. * Public members
  114103. */
  114104. /**
  114105. * Post-process which contains the original scene color before the pipeline applies all the effects
  114106. */
  114107. originalPostProcess: Nullable<PostProcess>;
  114108. /**
  114109. * Post-process used to down scale an image x4
  114110. */
  114111. downSampleX4PostProcess: Nullable<PostProcess>;
  114112. /**
  114113. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114114. */
  114115. brightPassPostProcess: Nullable<PostProcess>;
  114116. /**
  114117. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114118. */
  114119. blurHPostProcesses: PostProcess[];
  114120. /**
  114121. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114122. */
  114123. blurVPostProcesses: PostProcess[];
  114124. /**
  114125. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114126. */
  114127. textureAdderPostProcess: Nullable<PostProcess>;
  114128. /**
  114129. * Post-process used to create volumetric lighting effect
  114130. */
  114131. volumetricLightPostProcess: Nullable<PostProcess>;
  114132. /**
  114133. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114134. */
  114135. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  114136. /**
  114137. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114138. */
  114139. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  114140. /**
  114141. * Post-process used to merge the volumetric light effect and the real scene color
  114142. */
  114143. volumetricLightMergePostProces: Nullable<PostProcess>;
  114144. /**
  114145. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114146. */
  114147. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  114148. /**
  114149. * Base post-process used to calculate the average luminance of the final image for HDR
  114150. */
  114151. luminancePostProcess: Nullable<PostProcess>;
  114152. /**
  114153. * Post-processes used to create down sample post-processes in order to get
  114154. * the average luminance of the final image for HDR
  114155. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114156. */
  114157. luminanceDownSamplePostProcesses: PostProcess[];
  114158. /**
  114159. * Post-process used to create a HDR effect (light adaptation)
  114160. */
  114161. hdrPostProcess: Nullable<PostProcess>;
  114162. /**
  114163. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114164. */
  114165. textureAdderFinalPostProcess: Nullable<PostProcess>;
  114166. /**
  114167. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114168. */
  114169. lensFlareFinalPostProcess: Nullable<PostProcess>;
  114170. /**
  114171. * Post-process used to merge the final HDR post-process and the real scene color
  114172. */
  114173. hdrFinalPostProcess: Nullable<PostProcess>;
  114174. /**
  114175. * Post-process used to create a lens flare effect
  114176. */
  114177. lensFlarePostProcess: Nullable<PostProcess>;
  114178. /**
  114179. * Post-process that merges the result of the lens flare post-process and the real scene color
  114180. */
  114181. lensFlareComposePostProcess: Nullable<PostProcess>;
  114182. /**
  114183. * Post-process used to create a motion blur effect
  114184. */
  114185. motionBlurPostProcess: Nullable<PostProcess>;
  114186. /**
  114187. * Post-process used to create a depth of field effect
  114188. */
  114189. depthOfFieldPostProcess: Nullable<PostProcess>;
  114190. /**
  114191. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114192. */
  114193. fxaaPostProcess: Nullable<FxaaPostProcess>;
  114194. /**
  114195. * Represents the brightness threshold in order to configure the illuminated surfaces
  114196. */
  114197. brightThreshold: number;
  114198. /**
  114199. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114200. */
  114201. blurWidth: number;
  114202. /**
  114203. * Sets if the blur for highlighted surfaces must be only horizontal
  114204. */
  114205. horizontalBlur: boolean;
  114206. /**
  114207. * Gets the overall exposure used by the pipeline
  114208. */
  114209. /**
  114210. * Sets the overall exposure used by the pipeline
  114211. */
  114212. exposure: number;
  114213. /**
  114214. * Texture used typically to simulate "dirty" on camera lens
  114215. */
  114216. lensTexture: Nullable<Texture>;
  114217. /**
  114218. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114219. */
  114220. volumetricLightCoefficient: number;
  114221. /**
  114222. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114223. */
  114224. volumetricLightPower: number;
  114225. /**
  114226. * Used the set the blur intensity to smooth the volumetric lights
  114227. */
  114228. volumetricLightBlurScale: number;
  114229. /**
  114230. * Light (spot or directional) used to generate the volumetric lights rays
  114231. * The source light must have a shadow generate so the pipeline can get its
  114232. * depth map
  114233. */
  114234. sourceLight: Nullable<SpotLight | DirectionalLight>;
  114235. /**
  114236. * For eye adaptation, represents the minimum luminance the eye can see
  114237. */
  114238. hdrMinimumLuminance: number;
  114239. /**
  114240. * For eye adaptation, represents the decrease luminance speed
  114241. */
  114242. hdrDecreaseRate: number;
  114243. /**
  114244. * For eye adaptation, represents the increase luminance speed
  114245. */
  114246. hdrIncreaseRate: number;
  114247. /**
  114248. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114249. */
  114250. /**
  114251. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114252. */
  114253. hdrAutoExposure: boolean;
  114254. /**
  114255. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114256. */
  114257. lensColorTexture: Nullable<Texture>;
  114258. /**
  114259. * The overall strengh for the lens flare effect
  114260. */
  114261. lensFlareStrength: number;
  114262. /**
  114263. * Dispersion coefficient for lens flare ghosts
  114264. */
  114265. lensFlareGhostDispersal: number;
  114266. /**
  114267. * Main lens flare halo width
  114268. */
  114269. lensFlareHaloWidth: number;
  114270. /**
  114271. * Based on the lens distortion effect, defines how much the lens flare result
  114272. * is distorted
  114273. */
  114274. lensFlareDistortionStrength: number;
  114275. /**
  114276. * Lens star texture must be used to simulate rays on the flares and is available
  114277. * in the documentation
  114278. */
  114279. lensStarTexture: Nullable<Texture>;
  114280. /**
  114281. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114282. * flare effect by taking account of the dirt texture
  114283. */
  114284. lensFlareDirtTexture: Nullable<Texture>;
  114285. /**
  114286. * Represents the focal length for the depth of field effect
  114287. */
  114288. depthOfFieldDistance: number;
  114289. /**
  114290. * Represents the blur intensity for the blurred part of the depth of field effect
  114291. */
  114292. depthOfFieldBlurWidth: number;
  114293. /**
  114294. * For motion blur, defines how much the image is blurred by the movement
  114295. */
  114296. motionStrength: number;
  114297. /**
  114298. * List of animations for the pipeline (IAnimatable implementation)
  114299. */
  114300. animations: Animation[];
  114301. /**
  114302. * Private members
  114303. */
  114304. private _scene;
  114305. private _currentDepthOfFieldSource;
  114306. private _basePostProcess;
  114307. private _fixedExposure;
  114308. private _currentExposure;
  114309. private _hdrAutoExposure;
  114310. private _hdrCurrentLuminance;
  114311. private _floatTextureType;
  114312. private _ratio;
  114313. private _bloomEnabled;
  114314. private _depthOfFieldEnabled;
  114315. private _vlsEnabled;
  114316. private _lensFlareEnabled;
  114317. private _hdrEnabled;
  114318. private _motionBlurEnabled;
  114319. private _fxaaEnabled;
  114320. private _motionBlurSamples;
  114321. private _volumetricLightStepsCount;
  114322. private _samples;
  114323. /**
  114324. * @ignore
  114325. * Specifies if the bloom pipeline is enabled
  114326. */
  114327. BloomEnabled: boolean;
  114328. /**
  114329. * @ignore
  114330. * Specifies if the depth of field pipeline is enabed
  114331. */
  114332. DepthOfFieldEnabled: boolean;
  114333. /**
  114334. * @ignore
  114335. * Specifies if the lens flare pipeline is enabed
  114336. */
  114337. LensFlareEnabled: boolean;
  114338. /**
  114339. * @ignore
  114340. * Specifies if the HDR pipeline is enabled
  114341. */
  114342. HDREnabled: boolean;
  114343. /**
  114344. * @ignore
  114345. * Specifies if the volumetric lights scattering effect is enabled
  114346. */
  114347. VLSEnabled: boolean;
  114348. /**
  114349. * @ignore
  114350. * Specifies if the motion blur effect is enabled
  114351. */
  114352. MotionBlurEnabled: boolean;
  114353. /**
  114354. * Specifies if anti-aliasing is enabled
  114355. */
  114356. fxaaEnabled: boolean;
  114357. /**
  114358. * Specifies the number of steps used to calculate the volumetric lights
  114359. * Typically in interval [50, 200]
  114360. */
  114361. volumetricLightStepsCount: number;
  114362. /**
  114363. * Specifies the number of samples used for the motion blur effect
  114364. * Typically in interval [16, 64]
  114365. */
  114366. motionBlurSamples: number;
  114367. /**
  114368. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114369. */
  114370. samples: number;
  114371. /**
  114372. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114373. * @constructor
  114374. * @param name The rendering pipeline name
  114375. * @param scene The scene linked to this pipeline
  114376. * @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)
  114377. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114378. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114379. */
  114380. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  114381. private _buildPipeline;
  114382. private _createDownSampleX4PostProcess;
  114383. private _createBrightPassPostProcess;
  114384. private _createBlurPostProcesses;
  114385. private _createTextureAdderPostProcess;
  114386. private _createVolumetricLightPostProcess;
  114387. private _createLuminancePostProcesses;
  114388. private _createHdrPostProcess;
  114389. private _createLensFlarePostProcess;
  114390. private _createDepthOfFieldPostProcess;
  114391. private _createMotionBlurPostProcess;
  114392. private _getDepthTexture;
  114393. private _disposePostProcesses;
  114394. /**
  114395. * Dispose of the pipeline and stop all post processes
  114396. */
  114397. dispose(): void;
  114398. /**
  114399. * Serialize the rendering pipeline (Used when exporting)
  114400. * @returns the serialized object
  114401. */
  114402. serialize(): any;
  114403. /**
  114404. * Parse the serialized pipeline
  114405. * @param source Source pipeline.
  114406. * @param scene The scene to load the pipeline to.
  114407. * @param rootUrl The URL of the serialized pipeline.
  114408. * @returns An instantiated pipeline from the serialized object.
  114409. */
  114410. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  114411. /**
  114412. * Luminance steps
  114413. */
  114414. static LuminanceSteps: number;
  114415. }
  114416. }
  114417. declare module BABYLON {
  114418. /** @hidden */
  114419. export var tonemapPixelShader: {
  114420. name: string;
  114421. shader: string;
  114422. };
  114423. }
  114424. declare module BABYLON {
  114425. /** Defines operator used for tonemapping */
  114426. export enum TonemappingOperator {
  114427. /** Hable */
  114428. Hable = 0,
  114429. /** Reinhard */
  114430. Reinhard = 1,
  114431. /** HejiDawson */
  114432. HejiDawson = 2,
  114433. /** Photographic */
  114434. Photographic = 3
  114435. }
  114436. /**
  114437. * Defines a post process to apply tone mapping
  114438. */
  114439. export class TonemapPostProcess extends PostProcess {
  114440. private _operator;
  114441. /** Defines the required exposure adjustement */
  114442. exposureAdjustment: number;
  114443. /**
  114444. * Creates a new TonemapPostProcess
  114445. * @param name defines the name of the postprocess
  114446. * @param _operator defines the operator to use
  114447. * @param exposureAdjustment defines the required exposure adjustement
  114448. * @param camera defines the camera to use (can be null)
  114449. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  114450. * @param engine defines the hosting engine (can be ignore if camera is set)
  114451. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114452. */
  114453. constructor(name: string, _operator: TonemappingOperator,
  114454. /** Defines the required exposure adjustement */
  114455. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  114456. }
  114457. }
  114458. declare module BABYLON {
  114459. /** @hidden */
  114460. export var depthVertexShader: {
  114461. name: string;
  114462. shader: string;
  114463. };
  114464. }
  114465. declare module BABYLON {
  114466. /** @hidden */
  114467. export var volumetricLightScatteringPixelShader: {
  114468. name: string;
  114469. shader: string;
  114470. };
  114471. }
  114472. declare module BABYLON {
  114473. /** @hidden */
  114474. export var volumetricLightScatteringPassPixelShader: {
  114475. name: string;
  114476. shader: string;
  114477. };
  114478. }
  114479. declare module BABYLON {
  114480. /**
  114481. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  114482. */
  114483. export class VolumetricLightScatteringPostProcess extends PostProcess {
  114484. private _volumetricLightScatteringPass;
  114485. private _volumetricLightScatteringRTT;
  114486. private _viewPort;
  114487. private _screenCoordinates;
  114488. private _cachedDefines;
  114489. /**
  114490. * If not undefined, the mesh position is computed from the attached node position
  114491. */
  114492. attachedNode: {
  114493. position: Vector3;
  114494. };
  114495. /**
  114496. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  114497. */
  114498. customMeshPosition: Vector3;
  114499. /**
  114500. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  114501. */
  114502. useCustomMeshPosition: boolean;
  114503. /**
  114504. * If the post-process should inverse the light scattering direction
  114505. */
  114506. invert: boolean;
  114507. /**
  114508. * The internal mesh used by the post-process
  114509. */
  114510. mesh: Mesh;
  114511. /**
  114512. * @hidden
  114513. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  114514. */
  114515. useDiffuseColor: boolean;
  114516. /**
  114517. * Array containing the excluded meshes not rendered in the internal pass
  114518. */
  114519. excludedMeshes: AbstractMesh[];
  114520. /**
  114521. * Controls the overall intensity of the post-process
  114522. */
  114523. exposure: number;
  114524. /**
  114525. * Dissipates each sample's contribution in range [0, 1]
  114526. */
  114527. decay: number;
  114528. /**
  114529. * Controls the overall intensity of each sample
  114530. */
  114531. weight: number;
  114532. /**
  114533. * Controls the density of each sample
  114534. */
  114535. density: number;
  114536. /**
  114537. * @constructor
  114538. * @param name The post-process name
  114539. * @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)
  114540. * @param camera The camera that the post-process will be attached to
  114541. * @param mesh The mesh used to create the light scattering
  114542. * @param samples The post-process quality, default 100
  114543. * @param samplingModeThe post-process filtering mode
  114544. * @param engine The babylon engine
  114545. * @param reusable If the post-process is reusable
  114546. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114547. */
  114548. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114549. /**
  114550. * Returns the string "VolumetricLightScatteringPostProcess"
  114551. * @returns "VolumetricLightScatteringPostProcess"
  114552. */
  114553. getClassName(): string;
  114554. private _isReady;
  114555. /**
  114556. * Sets the new light position for light scattering effect
  114557. * @param position The new custom light position
  114558. */
  114559. setCustomMeshPosition(position: Vector3): void;
  114560. /**
  114561. * Returns the light position for light scattering effect
  114562. * @return Vector3 The custom light position
  114563. */
  114564. getCustomMeshPosition(): Vector3;
  114565. /**
  114566. * Disposes the internal assets and detaches the post-process from the camera
  114567. */
  114568. dispose(camera: Camera): void;
  114569. /**
  114570. * Returns the render target texture used by the post-process
  114571. * @return the render target texture used by the post-process
  114572. */
  114573. getPass(): RenderTargetTexture;
  114574. private _meshExcluded;
  114575. private _createPass;
  114576. private _updateMeshScreenCoordinates;
  114577. /**
  114578. * Creates a default mesh for the Volumeric Light Scattering post-process
  114579. * @param name The mesh name
  114580. * @param scene The scene where to create the mesh
  114581. * @return the default mesh
  114582. */
  114583. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114584. }
  114585. }
  114586. declare module BABYLON {
  114587. interface Scene {
  114588. /** @hidden (Backing field) */
  114589. _boundingBoxRenderer: BoundingBoxRenderer;
  114590. /** @hidden (Backing field) */
  114591. _forceShowBoundingBoxes: boolean;
  114592. /**
  114593. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114594. */
  114595. forceShowBoundingBoxes: boolean;
  114596. /**
  114597. * Gets the bounding box renderer associated with the scene
  114598. * @returns a BoundingBoxRenderer
  114599. */
  114600. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114601. }
  114602. interface AbstractMesh {
  114603. /** @hidden (Backing field) */
  114604. _showBoundingBox: boolean;
  114605. /**
  114606. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114607. */
  114608. showBoundingBox: boolean;
  114609. }
  114610. /**
  114611. * Component responsible of rendering the bounding box of the meshes in a scene.
  114612. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114613. */
  114614. export class BoundingBoxRenderer implements ISceneComponent {
  114615. /**
  114616. * The component name helpfull to identify the component in the list of scene components.
  114617. */
  114618. readonly name: string;
  114619. /**
  114620. * The scene the component belongs to.
  114621. */
  114622. scene: Scene;
  114623. /**
  114624. * Color of the bounding box lines placed in front of an object
  114625. */
  114626. frontColor: Color3;
  114627. /**
  114628. * Color of the bounding box lines placed behind an object
  114629. */
  114630. backColor: Color3;
  114631. /**
  114632. * Defines if the renderer should show the back lines or not
  114633. */
  114634. showBackLines: boolean;
  114635. /**
  114636. * @hidden
  114637. */
  114638. renderList: SmartArray<BoundingBox>;
  114639. private _colorShader;
  114640. private _vertexBuffers;
  114641. private _indexBuffer;
  114642. /**
  114643. * Instantiates a new bounding box renderer in a scene.
  114644. * @param scene the scene the renderer renders in
  114645. */
  114646. constructor(scene: Scene);
  114647. /**
  114648. * Registers the component in a given scene
  114649. */
  114650. register(): void;
  114651. private _evaluateSubMesh;
  114652. private _activeMesh;
  114653. private _prepareRessources;
  114654. private _createIndexBuffer;
  114655. /**
  114656. * Rebuilds the elements related to this component in case of
  114657. * context lost for instance.
  114658. */
  114659. rebuild(): void;
  114660. /**
  114661. * @hidden
  114662. */
  114663. reset(): void;
  114664. /**
  114665. * Render the bounding boxes of a specific rendering group
  114666. * @param renderingGroupId defines the rendering group to render
  114667. */
  114668. render(renderingGroupId: number): void;
  114669. /**
  114670. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114671. * @param mesh Define the mesh to render the occlusion bounding box for
  114672. */
  114673. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114674. /**
  114675. * Dispose and release the resources attached to this renderer.
  114676. */
  114677. dispose(): void;
  114678. }
  114679. }
  114680. declare module BABYLON {
  114681. /** @hidden */
  114682. export var depthPixelShader: {
  114683. name: string;
  114684. shader: string;
  114685. };
  114686. }
  114687. declare module BABYLON {
  114688. /**
  114689. * This represents a depth renderer in Babylon.
  114690. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114691. */
  114692. export class DepthRenderer {
  114693. private _scene;
  114694. private _depthMap;
  114695. private _effect;
  114696. private _cachedDefines;
  114697. private _camera;
  114698. /**
  114699. * Specifiess that the depth renderer will only be used within
  114700. * the camera it is created for.
  114701. * This can help forcing its rendering during the camera processing.
  114702. */
  114703. useOnlyInActiveCamera: boolean;
  114704. /** @hidden */
  114705. static _SceneComponentInitialization: (scene: Scene) => void;
  114706. /**
  114707. * Instantiates a depth renderer
  114708. * @param scene The scene the renderer belongs to
  114709. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114710. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114711. */
  114712. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114713. /**
  114714. * Creates the depth rendering effect and checks if the effect is ready.
  114715. * @param subMesh The submesh to be used to render the depth map of
  114716. * @param useInstances If multiple world instances should be used
  114717. * @returns if the depth renderer is ready to render the depth map
  114718. */
  114719. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114720. /**
  114721. * Gets the texture which the depth map will be written to.
  114722. * @returns The depth map texture
  114723. */
  114724. getDepthMap(): RenderTargetTexture;
  114725. /**
  114726. * Disposes of the depth renderer.
  114727. */
  114728. dispose(): void;
  114729. }
  114730. }
  114731. declare module BABYLON {
  114732. interface Scene {
  114733. /** @hidden (Backing field) */
  114734. _depthRenderer: {
  114735. [id: string]: DepthRenderer;
  114736. };
  114737. /**
  114738. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114739. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114740. * @returns the created depth renderer
  114741. */
  114742. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114743. /**
  114744. * Disables a depth renderer for a given camera
  114745. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114746. */
  114747. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114748. }
  114749. /**
  114750. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114751. * in several rendering techniques.
  114752. */
  114753. export class DepthRendererSceneComponent implements ISceneComponent {
  114754. /**
  114755. * The component name helpfull to identify the component in the list of scene components.
  114756. */
  114757. readonly name: string;
  114758. /**
  114759. * The scene the component belongs to.
  114760. */
  114761. scene: Scene;
  114762. /**
  114763. * Creates a new instance of the component for the given scene
  114764. * @param scene Defines the scene to register the component in
  114765. */
  114766. constructor(scene: Scene);
  114767. /**
  114768. * Registers the component in a given scene
  114769. */
  114770. register(): void;
  114771. /**
  114772. * Rebuilds the elements related to this component in case of
  114773. * context lost for instance.
  114774. */
  114775. rebuild(): void;
  114776. /**
  114777. * Disposes the component and the associated ressources
  114778. */
  114779. dispose(): void;
  114780. private _gatherRenderTargets;
  114781. private _gatherActiveCameraRenderTargets;
  114782. }
  114783. }
  114784. declare module BABYLON {
  114785. /** @hidden */
  114786. export var outlinePixelShader: {
  114787. name: string;
  114788. shader: string;
  114789. };
  114790. }
  114791. declare module BABYLON {
  114792. /** @hidden */
  114793. export var outlineVertexShader: {
  114794. name: string;
  114795. shader: string;
  114796. };
  114797. }
  114798. declare module BABYLON {
  114799. interface Scene {
  114800. /** @hidden */
  114801. _outlineRenderer: OutlineRenderer;
  114802. /**
  114803. * Gets the outline renderer associated with the scene
  114804. * @returns a OutlineRenderer
  114805. */
  114806. getOutlineRenderer(): OutlineRenderer;
  114807. }
  114808. interface AbstractMesh {
  114809. /** @hidden (Backing field) */
  114810. _renderOutline: boolean;
  114811. /**
  114812. * Gets or sets a boolean indicating if the outline must be rendered as well
  114813. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  114814. */
  114815. renderOutline: boolean;
  114816. /** @hidden (Backing field) */
  114817. _renderOverlay: boolean;
  114818. /**
  114819. * Gets or sets a boolean indicating if the overlay must be rendered as well
  114820. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  114821. */
  114822. renderOverlay: boolean;
  114823. }
  114824. /**
  114825. * This class is responsible to draw bothe outline/overlay of meshes.
  114826. * It should not be used directly but through the available method on mesh.
  114827. */
  114828. export class OutlineRenderer implements ISceneComponent {
  114829. /**
  114830. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  114831. */
  114832. private static _StencilReference;
  114833. /**
  114834. * The name of the component. Each component must have a unique name.
  114835. */
  114836. name: string;
  114837. /**
  114838. * The scene the component belongs to.
  114839. */
  114840. scene: Scene;
  114841. /**
  114842. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  114843. */
  114844. zOffset: number;
  114845. private _engine;
  114846. private _effect;
  114847. private _cachedDefines;
  114848. private _savedDepthWrite;
  114849. /**
  114850. * Instantiates a new outline renderer. (There could be only one per scene).
  114851. * @param scene Defines the scene it belongs to
  114852. */
  114853. constructor(scene: Scene);
  114854. /**
  114855. * Register the component to one instance of a scene.
  114856. */
  114857. register(): void;
  114858. /**
  114859. * Rebuilds the elements related to this component in case of
  114860. * context lost for instance.
  114861. */
  114862. rebuild(): void;
  114863. /**
  114864. * Disposes the component and the associated ressources.
  114865. */
  114866. dispose(): void;
  114867. /**
  114868. * Renders the outline in the canvas.
  114869. * @param subMesh Defines the sumesh to render
  114870. * @param batch Defines the batch of meshes in case of instances
  114871. * @param useOverlay Defines if the rendering is for the overlay or the outline
  114872. */
  114873. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  114874. /**
  114875. * Returns whether or not the outline renderer is ready for a given submesh.
  114876. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  114877. * @param subMesh Defines the submesh to check readyness for
  114878. * @param useInstances Defines wheter wee are trying to render instances or not
  114879. * @returns true if ready otherwise false
  114880. */
  114881. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114882. private _beforeRenderingMesh;
  114883. private _afterRenderingMesh;
  114884. }
  114885. }
  114886. declare module BABYLON {
  114887. /**
  114888. * Defines the list of states available for a task inside a AssetsManager
  114889. */
  114890. export enum AssetTaskState {
  114891. /**
  114892. * Initialization
  114893. */
  114894. INIT = 0,
  114895. /**
  114896. * Running
  114897. */
  114898. RUNNING = 1,
  114899. /**
  114900. * Done
  114901. */
  114902. DONE = 2,
  114903. /**
  114904. * Error
  114905. */
  114906. ERROR = 3
  114907. }
  114908. /**
  114909. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  114910. */
  114911. export abstract class AbstractAssetTask {
  114912. /**
  114913. * Task name
  114914. */ name: string;
  114915. /**
  114916. * Callback called when the task is successful
  114917. */
  114918. onSuccess: (task: any) => void;
  114919. /**
  114920. * Callback called when the task is not successful
  114921. */
  114922. onError: (task: any, message?: string, exception?: any) => void;
  114923. /**
  114924. * Creates a new AssetsManager
  114925. * @param name defines the name of the task
  114926. */
  114927. constructor(
  114928. /**
  114929. * Task name
  114930. */ name: string);
  114931. private _isCompleted;
  114932. private _taskState;
  114933. private _errorObject;
  114934. /**
  114935. * Get if the task is completed
  114936. */
  114937. readonly isCompleted: boolean;
  114938. /**
  114939. * Gets the current state of the task
  114940. */
  114941. readonly taskState: AssetTaskState;
  114942. /**
  114943. * Gets the current error object (if task is in error)
  114944. */
  114945. readonly errorObject: {
  114946. message?: string;
  114947. exception?: any;
  114948. };
  114949. /**
  114950. * Internal only
  114951. * @hidden
  114952. */
  114953. _setErrorObject(message?: string, exception?: any): void;
  114954. /**
  114955. * Execute the current task
  114956. * @param scene defines the scene where you want your assets to be loaded
  114957. * @param onSuccess is a callback called when the task is successfully executed
  114958. * @param onError is a callback called if an error occurs
  114959. */
  114960. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114961. /**
  114962. * Execute the current task
  114963. * @param scene defines the scene where you want your assets to be loaded
  114964. * @param onSuccess is a callback called when the task is successfully executed
  114965. * @param onError is a callback called if an error occurs
  114966. */
  114967. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114968. /**
  114969. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114970. * This can be used with failed tasks that have the reason for failure fixed.
  114971. */
  114972. reset(): void;
  114973. private onErrorCallback;
  114974. private onDoneCallback;
  114975. }
  114976. /**
  114977. * Define the interface used by progress events raised during assets loading
  114978. */
  114979. export interface IAssetsProgressEvent {
  114980. /**
  114981. * Defines the number of remaining tasks to process
  114982. */
  114983. remainingCount: number;
  114984. /**
  114985. * Defines the total number of tasks
  114986. */
  114987. totalCount: number;
  114988. /**
  114989. * Defines the task that was just processed
  114990. */
  114991. task: AbstractAssetTask;
  114992. }
  114993. /**
  114994. * Class used to share progress information about assets loading
  114995. */
  114996. export class AssetsProgressEvent implements IAssetsProgressEvent {
  114997. /**
  114998. * Defines the number of remaining tasks to process
  114999. */
  115000. remainingCount: number;
  115001. /**
  115002. * Defines the total number of tasks
  115003. */
  115004. totalCount: number;
  115005. /**
  115006. * Defines the task that was just processed
  115007. */
  115008. task: AbstractAssetTask;
  115009. /**
  115010. * Creates a AssetsProgressEvent
  115011. * @param remainingCount defines the number of remaining tasks to process
  115012. * @param totalCount defines the total number of tasks
  115013. * @param task defines the task that was just processed
  115014. */
  115015. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  115016. }
  115017. /**
  115018. * Define a task used by AssetsManager to load meshes
  115019. */
  115020. export class MeshAssetTask extends AbstractAssetTask {
  115021. /**
  115022. * Defines the name of the task
  115023. */
  115024. name: string;
  115025. /**
  115026. * Defines the list of mesh's names you want to load
  115027. */
  115028. meshesNames: any;
  115029. /**
  115030. * Defines the root url to use as a base to load your meshes and associated resources
  115031. */
  115032. rootUrl: string;
  115033. /**
  115034. * Defines the filename of the scene to load from
  115035. */
  115036. sceneFilename: string;
  115037. /**
  115038. * Gets the list of loaded meshes
  115039. */
  115040. loadedMeshes: Array<AbstractMesh>;
  115041. /**
  115042. * Gets the list of loaded particle systems
  115043. */
  115044. loadedParticleSystems: Array<IParticleSystem>;
  115045. /**
  115046. * Gets the list of loaded skeletons
  115047. */
  115048. loadedSkeletons: Array<Skeleton>;
  115049. /**
  115050. * Gets the list of loaded animation groups
  115051. */
  115052. loadedAnimationGroups: Array<AnimationGroup>;
  115053. /**
  115054. * Callback called when the task is successful
  115055. */
  115056. onSuccess: (task: MeshAssetTask) => void;
  115057. /**
  115058. * Callback called when the task is successful
  115059. */
  115060. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  115061. /**
  115062. * Creates a new MeshAssetTask
  115063. * @param name defines the name of the task
  115064. * @param meshesNames defines the list of mesh's names you want to load
  115065. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  115066. * @param sceneFilename defines the filename of the scene to load from
  115067. */
  115068. constructor(
  115069. /**
  115070. * Defines the name of the task
  115071. */
  115072. name: string,
  115073. /**
  115074. * Defines the list of mesh's names you want to load
  115075. */
  115076. meshesNames: any,
  115077. /**
  115078. * Defines the root url to use as a base to load your meshes and associated resources
  115079. */
  115080. rootUrl: string,
  115081. /**
  115082. * Defines the filename of the scene to load from
  115083. */
  115084. sceneFilename: string);
  115085. /**
  115086. * Execute the current task
  115087. * @param scene defines the scene where you want your assets to be loaded
  115088. * @param onSuccess is a callback called when the task is successfully executed
  115089. * @param onError is a callback called if an error occurs
  115090. */
  115091. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115092. }
  115093. /**
  115094. * Define a task used by AssetsManager to load text content
  115095. */
  115096. export class TextFileAssetTask extends AbstractAssetTask {
  115097. /**
  115098. * Defines the name of the task
  115099. */
  115100. name: string;
  115101. /**
  115102. * Defines the location of the file to load
  115103. */
  115104. url: string;
  115105. /**
  115106. * Gets the loaded text string
  115107. */
  115108. text: string;
  115109. /**
  115110. * Callback called when the task is successful
  115111. */
  115112. onSuccess: (task: TextFileAssetTask) => void;
  115113. /**
  115114. * Callback called when the task is successful
  115115. */
  115116. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  115117. /**
  115118. * Creates a new TextFileAssetTask object
  115119. * @param name defines the name of the task
  115120. * @param url defines the location of the file to load
  115121. */
  115122. constructor(
  115123. /**
  115124. * Defines the name of the task
  115125. */
  115126. name: string,
  115127. /**
  115128. * Defines the location of the file to load
  115129. */
  115130. url: string);
  115131. /**
  115132. * Execute the current task
  115133. * @param scene defines the scene where you want your assets to be loaded
  115134. * @param onSuccess is a callback called when the task is successfully executed
  115135. * @param onError is a callback called if an error occurs
  115136. */
  115137. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115138. }
  115139. /**
  115140. * Define a task used by AssetsManager to load binary data
  115141. */
  115142. export class BinaryFileAssetTask extends AbstractAssetTask {
  115143. /**
  115144. * Defines the name of the task
  115145. */
  115146. name: string;
  115147. /**
  115148. * Defines the location of the file to load
  115149. */
  115150. url: string;
  115151. /**
  115152. * Gets the lodaded data (as an array buffer)
  115153. */
  115154. data: ArrayBuffer;
  115155. /**
  115156. * Callback called when the task is successful
  115157. */
  115158. onSuccess: (task: BinaryFileAssetTask) => void;
  115159. /**
  115160. * Callback called when the task is successful
  115161. */
  115162. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  115163. /**
  115164. * Creates a new BinaryFileAssetTask object
  115165. * @param name defines the name of the new task
  115166. * @param url defines the location of the file to load
  115167. */
  115168. constructor(
  115169. /**
  115170. * Defines the name of the task
  115171. */
  115172. name: string,
  115173. /**
  115174. * Defines the location of the file to load
  115175. */
  115176. url: string);
  115177. /**
  115178. * Execute the current task
  115179. * @param scene defines the scene where you want your assets to be loaded
  115180. * @param onSuccess is a callback called when the task is successfully executed
  115181. * @param onError is a callback called if an error occurs
  115182. */
  115183. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115184. }
  115185. /**
  115186. * Define a task used by AssetsManager to load images
  115187. */
  115188. export class ImageAssetTask extends AbstractAssetTask {
  115189. /**
  115190. * Defines the name of the task
  115191. */
  115192. name: string;
  115193. /**
  115194. * Defines the location of the image to load
  115195. */
  115196. url: string;
  115197. /**
  115198. * Gets the loaded images
  115199. */
  115200. image: HTMLImageElement;
  115201. /**
  115202. * Callback called when the task is successful
  115203. */
  115204. onSuccess: (task: ImageAssetTask) => void;
  115205. /**
  115206. * Callback called when the task is successful
  115207. */
  115208. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  115209. /**
  115210. * Creates a new ImageAssetTask
  115211. * @param name defines the name of the task
  115212. * @param url defines the location of the image to load
  115213. */
  115214. constructor(
  115215. /**
  115216. * Defines the name of the task
  115217. */
  115218. name: string,
  115219. /**
  115220. * Defines the location of the image to load
  115221. */
  115222. url: string);
  115223. /**
  115224. * Execute the current task
  115225. * @param scene defines the scene where you want your assets to be loaded
  115226. * @param onSuccess is a callback called when the task is successfully executed
  115227. * @param onError is a callback called if an error occurs
  115228. */
  115229. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115230. }
  115231. /**
  115232. * Defines the interface used by texture loading tasks
  115233. */
  115234. export interface ITextureAssetTask<TEX extends BaseTexture> {
  115235. /**
  115236. * Gets the loaded texture
  115237. */
  115238. texture: TEX;
  115239. }
  115240. /**
  115241. * Define a task used by AssetsManager to load 2D textures
  115242. */
  115243. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  115244. /**
  115245. * Defines the name of the task
  115246. */
  115247. name: string;
  115248. /**
  115249. * Defines the location of the file to load
  115250. */
  115251. url: string;
  115252. /**
  115253. * Defines if mipmap should not be generated (default is false)
  115254. */
  115255. noMipmap?: boolean | undefined;
  115256. /**
  115257. * Defines if texture must be inverted on Y axis (default is false)
  115258. */
  115259. invertY?: boolean | undefined;
  115260. /**
  115261. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115262. */
  115263. samplingMode: number;
  115264. /**
  115265. * Gets the loaded texture
  115266. */
  115267. texture: Texture;
  115268. /**
  115269. * Callback called when the task is successful
  115270. */
  115271. onSuccess: (task: TextureAssetTask) => void;
  115272. /**
  115273. * Callback called when the task is successful
  115274. */
  115275. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  115276. /**
  115277. * Creates a new TextureAssetTask object
  115278. * @param name defines the name of the task
  115279. * @param url defines the location of the file to load
  115280. * @param noMipmap defines if mipmap should not be generated (default is false)
  115281. * @param invertY defines if texture must be inverted on Y axis (default is false)
  115282. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115283. */
  115284. constructor(
  115285. /**
  115286. * Defines the name of the task
  115287. */
  115288. name: string,
  115289. /**
  115290. * Defines the location of the file to load
  115291. */
  115292. url: string,
  115293. /**
  115294. * Defines if mipmap should not be generated (default is false)
  115295. */
  115296. noMipmap?: boolean | undefined,
  115297. /**
  115298. * Defines if texture must be inverted on Y axis (default is false)
  115299. */
  115300. invertY?: boolean | undefined,
  115301. /**
  115302. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115303. */
  115304. samplingMode?: number);
  115305. /**
  115306. * Execute the current task
  115307. * @param scene defines the scene where you want your assets to be loaded
  115308. * @param onSuccess is a callback called when the task is successfully executed
  115309. * @param onError is a callback called if an error occurs
  115310. */
  115311. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115312. }
  115313. /**
  115314. * Define a task used by AssetsManager to load cube textures
  115315. */
  115316. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  115317. /**
  115318. * Defines the name of the task
  115319. */
  115320. name: string;
  115321. /**
  115322. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115323. */
  115324. url: string;
  115325. /**
  115326. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115327. */
  115328. extensions?: string[] | undefined;
  115329. /**
  115330. * Defines if mipmaps should not be generated (default is false)
  115331. */
  115332. noMipmap?: boolean | undefined;
  115333. /**
  115334. * Defines the explicit list of files (undefined by default)
  115335. */
  115336. files?: string[] | undefined;
  115337. /**
  115338. * Gets the loaded texture
  115339. */
  115340. texture: CubeTexture;
  115341. /**
  115342. * Callback called when the task is successful
  115343. */
  115344. onSuccess: (task: CubeTextureAssetTask) => void;
  115345. /**
  115346. * Callback called when the task is successful
  115347. */
  115348. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  115349. /**
  115350. * Creates a new CubeTextureAssetTask
  115351. * @param name defines the name of the task
  115352. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115353. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115354. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115355. * @param files defines the explicit list of files (undefined by default)
  115356. */
  115357. constructor(
  115358. /**
  115359. * Defines the name of the task
  115360. */
  115361. name: string,
  115362. /**
  115363. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115364. */
  115365. url: string,
  115366. /**
  115367. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115368. */
  115369. extensions?: string[] | undefined,
  115370. /**
  115371. * Defines if mipmaps should not be generated (default is false)
  115372. */
  115373. noMipmap?: boolean | undefined,
  115374. /**
  115375. * Defines the explicit list of files (undefined by default)
  115376. */
  115377. files?: string[] | undefined);
  115378. /**
  115379. * Execute the current task
  115380. * @param scene defines the scene where you want your assets to be loaded
  115381. * @param onSuccess is a callback called when the task is successfully executed
  115382. * @param onError is a callback called if an error occurs
  115383. */
  115384. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115385. }
  115386. /**
  115387. * Define a task used by AssetsManager to load HDR cube textures
  115388. */
  115389. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  115390. /**
  115391. * Defines the name of the task
  115392. */
  115393. name: string;
  115394. /**
  115395. * Defines the location of the file to load
  115396. */
  115397. url: string;
  115398. /**
  115399. * Defines the desired size (the more it increases the longer the generation will be)
  115400. */
  115401. size: number;
  115402. /**
  115403. * Defines if mipmaps should not be generated (default is false)
  115404. */
  115405. noMipmap: boolean;
  115406. /**
  115407. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115408. */
  115409. generateHarmonics: boolean;
  115410. /**
  115411. * 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)
  115412. */
  115413. gammaSpace: boolean;
  115414. /**
  115415. * Internal Use Only
  115416. */
  115417. reserved: boolean;
  115418. /**
  115419. * Gets the loaded texture
  115420. */
  115421. texture: HDRCubeTexture;
  115422. /**
  115423. * Callback called when the task is successful
  115424. */
  115425. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  115426. /**
  115427. * Callback called when the task is successful
  115428. */
  115429. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  115430. /**
  115431. * Creates a new HDRCubeTextureAssetTask object
  115432. * @param name defines the name of the task
  115433. * @param url defines the location of the file to load
  115434. * @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.
  115435. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115436. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115437. * @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)
  115438. * @param reserved Internal use only
  115439. */
  115440. constructor(
  115441. /**
  115442. * Defines the name of the task
  115443. */
  115444. name: string,
  115445. /**
  115446. * Defines the location of the file to load
  115447. */
  115448. url: string,
  115449. /**
  115450. * Defines the desired size (the more it increases the longer the generation will be)
  115451. */
  115452. size: number,
  115453. /**
  115454. * Defines if mipmaps should not be generated (default is false)
  115455. */
  115456. noMipmap?: boolean,
  115457. /**
  115458. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115459. */
  115460. generateHarmonics?: boolean,
  115461. /**
  115462. * 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)
  115463. */
  115464. gammaSpace?: boolean,
  115465. /**
  115466. * Internal Use Only
  115467. */
  115468. reserved?: boolean);
  115469. /**
  115470. * Execute the current task
  115471. * @param scene defines the scene where you want your assets to be loaded
  115472. * @param onSuccess is a callback called when the task is successfully executed
  115473. * @param onError is a callback called if an error occurs
  115474. */
  115475. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115476. }
  115477. /**
  115478. * Define a task used by AssetsManager to load Equirectangular cube textures
  115479. */
  115480. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  115481. /**
  115482. * Defines the name of the task
  115483. */
  115484. name: string;
  115485. /**
  115486. * Defines the location of the file to load
  115487. */
  115488. url: string;
  115489. /**
  115490. * Defines the desired size (the more it increases the longer the generation will be)
  115491. */
  115492. size: number;
  115493. /**
  115494. * Defines if mipmaps should not be generated (default is false)
  115495. */
  115496. noMipmap: boolean;
  115497. /**
  115498. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115499. * but the standard material would require them in Gamma space) (default is true)
  115500. */
  115501. gammaSpace: boolean;
  115502. /**
  115503. * Gets the loaded texture
  115504. */
  115505. texture: EquiRectangularCubeTexture;
  115506. /**
  115507. * Callback called when the task is successful
  115508. */
  115509. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  115510. /**
  115511. * Callback called when the task is successful
  115512. */
  115513. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  115514. /**
  115515. * Creates a new EquiRectangularCubeTextureAssetTask object
  115516. * @param name defines the name of the task
  115517. * @param url defines the location of the file to load
  115518. * @param size defines the desired size (the more it increases the longer the generation will be)
  115519. * If the size is omitted this implies you are using a preprocessed cubemap.
  115520. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115521. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  115522. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  115523. * (default is true)
  115524. */
  115525. constructor(
  115526. /**
  115527. * Defines the name of the task
  115528. */
  115529. name: string,
  115530. /**
  115531. * Defines the location of the file to load
  115532. */
  115533. url: string,
  115534. /**
  115535. * Defines the desired size (the more it increases the longer the generation will be)
  115536. */
  115537. size: number,
  115538. /**
  115539. * Defines if mipmaps should not be generated (default is false)
  115540. */
  115541. noMipmap?: boolean,
  115542. /**
  115543. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115544. * but the standard material would require them in Gamma space) (default is true)
  115545. */
  115546. gammaSpace?: boolean);
  115547. /**
  115548. * Execute the current task
  115549. * @param scene defines the scene where you want your assets to be loaded
  115550. * @param onSuccess is a callback called when the task is successfully executed
  115551. * @param onError is a callback called if an error occurs
  115552. */
  115553. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115554. }
  115555. /**
  115556. * This class can be used to easily import assets into a scene
  115557. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115558. */
  115559. export class AssetsManager {
  115560. private _scene;
  115561. private _isLoading;
  115562. protected _tasks: AbstractAssetTask[];
  115563. protected _waitingTasksCount: number;
  115564. protected _totalTasksCount: number;
  115565. /**
  115566. * Callback called when all tasks are processed
  115567. */
  115568. onFinish: (tasks: AbstractAssetTask[]) => void;
  115569. /**
  115570. * Callback called when a task is successful
  115571. */
  115572. onTaskSuccess: (task: AbstractAssetTask) => void;
  115573. /**
  115574. * Callback called when a task had an error
  115575. */
  115576. onTaskError: (task: AbstractAssetTask) => void;
  115577. /**
  115578. * Callback called when a task is done (whatever the result is)
  115579. */
  115580. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115581. /**
  115582. * Observable called when all tasks are processed
  115583. */
  115584. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115585. /**
  115586. * Observable called when a task had an error
  115587. */
  115588. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115589. /**
  115590. * Observable called when all tasks were executed
  115591. */
  115592. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115593. /**
  115594. * Observable called when a task is done (whatever the result is)
  115595. */
  115596. onProgressObservable: Observable<IAssetsProgressEvent>;
  115597. /**
  115598. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115599. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115600. */
  115601. useDefaultLoadingScreen: boolean;
  115602. /**
  115603. * Creates a new AssetsManager
  115604. * @param scene defines the scene to work on
  115605. */
  115606. constructor(scene: Scene);
  115607. /**
  115608. * Add a MeshAssetTask to the list of active tasks
  115609. * @param taskName defines the name of the new task
  115610. * @param meshesNames defines the name of meshes to load
  115611. * @param rootUrl defines the root url to use to locate files
  115612. * @param sceneFilename defines the filename of the scene file
  115613. * @returns a new MeshAssetTask object
  115614. */
  115615. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115616. /**
  115617. * Add a TextFileAssetTask to the list of active tasks
  115618. * @param taskName defines the name of the new task
  115619. * @param url defines the url of the file to load
  115620. * @returns a new TextFileAssetTask object
  115621. */
  115622. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115623. /**
  115624. * Add a BinaryFileAssetTask to the list of active tasks
  115625. * @param taskName defines the name of the new task
  115626. * @param url defines the url of the file to load
  115627. * @returns a new BinaryFileAssetTask object
  115628. */
  115629. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115630. /**
  115631. * Add a ImageAssetTask to the list of active tasks
  115632. * @param taskName defines the name of the new task
  115633. * @param url defines the url of the file to load
  115634. * @returns a new ImageAssetTask object
  115635. */
  115636. addImageTask(taskName: string, url: string): ImageAssetTask;
  115637. /**
  115638. * Add a TextureAssetTask to the list of active tasks
  115639. * @param taskName defines the name of the new task
  115640. * @param url defines the url of the file to load
  115641. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115642. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115643. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115644. * @returns a new TextureAssetTask object
  115645. */
  115646. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115647. /**
  115648. * Add a CubeTextureAssetTask to the list of active tasks
  115649. * @param taskName defines the name of the new task
  115650. * @param url defines the url of the file to load
  115651. * @param extensions defines the extension to use to load the cube map (can be null)
  115652. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115653. * @param files defines the list of files to load (can be null)
  115654. * @returns a new CubeTextureAssetTask object
  115655. */
  115656. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115657. /**
  115658. *
  115659. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115660. * @param taskName defines the name of the new task
  115661. * @param url defines the url of the file to load
  115662. * @param size defines the size you want for the cubemap (can be null)
  115663. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115664. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115665. * @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)
  115666. * @param reserved Internal use only
  115667. * @returns a new HDRCubeTextureAssetTask object
  115668. */
  115669. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115670. /**
  115671. *
  115672. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115673. * @param taskName defines the name of the new task
  115674. * @param url defines the url of the file to load
  115675. * @param size defines the size you want for the cubemap (can be null)
  115676. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115677. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115678. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115679. * @returns a new EquiRectangularCubeTextureAssetTask object
  115680. */
  115681. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115682. /**
  115683. * Remove a task from the assets manager.
  115684. * @param task the task to remove
  115685. */
  115686. removeTask(task: AbstractAssetTask): void;
  115687. private _decreaseWaitingTasksCount;
  115688. private _runTask;
  115689. /**
  115690. * Reset the AssetsManager and remove all tasks
  115691. * @return the current instance of the AssetsManager
  115692. */
  115693. reset(): AssetsManager;
  115694. /**
  115695. * Start the loading process
  115696. * @return the current instance of the AssetsManager
  115697. */
  115698. load(): AssetsManager;
  115699. /**
  115700. * Start the loading process as an async operation
  115701. * @return a promise returning the list of failed tasks
  115702. */
  115703. loadAsync(): Promise<void>;
  115704. }
  115705. }
  115706. declare module BABYLON {
  115707. /**
  115708. * Wrapper class for promise with external resolve and reject.
  115709. */
  115710. export class Deferred<T> {
  115711. /**
  115712. * The promise associated with this deferred object.
  115713. */
  115714. readonly promise: Promise<T>;
  115715. private _resolve;
  115716. private _reject;
  115717. /**
  115718. * The resolve method of the promise associated with this deferred object.
  115719. */
  115720. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115721. /**
  115722. * The reject method of the promise associated with this deferred object.
  115723. */
  115724. readonly reject: (reason?: any) => void;
  115725. /**
  115726. * Constructor for this deferred object.
  115727. */
  115728. constructor();
  115729. }
  115730. }
  115731. declare module BABYLON {
  115732. /**
  115733. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115734. */
  115735. export class MeshExploder {
  115736. private _centerMesh;
  115737. private _meshes;
  115738. private _meshesOrigins;
  115739. private _toCenterVectors;
  115740. private _scaledDirection;
  115741. private _newPosition;
  115742. private _centerPosition;
  115743. /**
  115744. * Explodes meshes from a center mesh.
  115745. * @param meshes The meshes to explode.
  115746. * @param centerMesh The mesh to be center of explosion.
  115747. */
  115748. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115749. private _setCenterMesh;
  115750. /**
  115751. * Get class name
  115752. * @returns "MeshExploder"
  115753. */
  115754. getClassName(): string;
  115755. /**
  115756. * "Exploded meshes"
  115757. * @returns Array of meshes with the centerMesh at index 0.
  115758. */
  115759. getMeshes(): Array<Mesh>;
  115760. /**
  115761. * Explodes meshes giving a specific direction
  115762. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115763. */
  115764. explode(direction?: number): void;
  115765. }
  115766. }
  115767. declare module BABYLON {
  115768. /**
  115769. * Class used to help managing file picking and drag'n'drop
  115770. */
  115771. export class FilesInput {
  115772. /**
  115773. * List of files ready to be loaded
  115774. */
  115775. static readonly FilesToLoad: {
  115776. [key: string]: File;
  115777. };
  115778. /**
  115779. * Callback called when a file is processed
  115780. */
  115781. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  115782. private _engine;
  115783. private _currentScene;
  115784. private _sceneLoadedCallback;
  115785. private _progressCallback;
  115786. private _additionalRenderLoopLogicCallback;
  115787. private _textureLoadingCallback;
  115788. private _startingProcessingFilesCallback;
  115789. private _onReloadCallback;
  115790. private _errorCallback;
  115791. private _elementToMonitor;
  115792. private _sceneFileToLoad;
  115793. private _filesToLoad;
  115794. /**
  115795. * Creates a new FilesInput
  115796. * @param engine defines the rendering engine
  115797. * @param scene defines the hosting scene
  115798. * @param sceneLoadedCallback callback called when scene is loaded
  115799. * @param progressCallback callback called to track progress
  115800. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  115801. * @param textureLoadingCallback callback called when a texture is loading
  115802. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  115803. * @param onReloadCallback callback called when a reload is requested
  115804. * @param errorCallback callback call if an error occurs
  115805. */
  115806. 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);
  115807. private _dragEnterHandler;
  115808. private _dragOverHandler;
  115809. private _dropHandler;
  115810. /**
  115811. * Calls this function to listen to drag'n'drop events on a specific DOM element
  115812. * @param elementToMonitor defines the DOM element to track
  115813. */
  115814. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  115815. /**
  115816. * Release all associated resources
  115817. */
  115818. dispose(): void;
  115819. private renderFunction;
  115820. private drag;
  115821. private drop;
  115822. private _traverseFolder;
  115823. private _processFiles;
  115824. /**
  115825. * Load files from a drop event
  115826. * @param event defines the drop event to use as source
  115827. */
  115828. loadFiles(event: any): void;
  115829. private _processReload;
  115830. /**
  115831. * Reload the current scene from the loaded files
  115832. */
  115833. reload(): void;
  115834. }
  115835. }
  115836. declare module BABYLON {
  115837. /**
  115838. * Defines the root class used to create scene optimization to use with SceneOptimizer
  115839. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115840. */
  115841. export class SceneOptimization {
  115842. /**
  115843. * Defines the priority of this optimization (0 by default which means first in the list)
  115844. */
  115845. priority: number;
  115846. /**
  115847. * Gets a string describing the action executed by the current optimization
  115848. * @returns description string
  115849. */
  115850. getDescription(): string;
  115851. /**
  115852. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115853. * @param scene defines the current scene where to apply this optimization
  115854. * @param optimizer defines the current optimizer
  115855. * @returns true if everything that can be done was applied
  115856. */
  115857. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115858. /**
  115859. * Creates the SceneOptimization object
  115860. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115861. * @param desc defines the description associated with the optimization
  115862. */
  115863. constructor(
  115864. /**
  115865. * Defines the priority of this optimization (0 by default which means first in the list)
  115866. */
  115867. priority?: number);
  115868. }
  115869. /**
  115870. * Defines an optimization used to reduce the size of render target textures
  115871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115872. */
  115873. export class TextureOptimization extends SceneOptimization {
  115874. /**
  115875. * Defines the priority of this optimization (0 by default which means first in the list)
  115876. */
  115877. priority: number;
  115878. /**
  115879. * 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
  115880. */
  115881. maximumSize: number;
  115882. /**
  115883. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115884. */
  115885. step: number;
  115886. /**
  115887. * Gets a string describing the action executed by the current optimization
  115888. * @returns description string
  115889. */
  115890. getDescription(): string;
  115891. /**
  115892. * Creates the TextureOptimization object
  115893. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115894. * @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
  115895. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115896. */
  115897. constructor(
  115898. /**
  115899. * Defines the priority of this optimization (0 by default which means first in the list)
  115900. */
  115901. priority?: number,
  115902. /**
  115903. * 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
  115904. */
  115905. maximumSize?: number,
  115906. /**
  115907. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115908. */
  115909. step?: number);
  115910. /**
  115911. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115912. * @param scene defines the current scene where to apply this optimization
  115913. * @param optimizer defines the current optimizer
  115914. * @returns true if everything that can be done was applied
  115915. */
  115916. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115917. }
  115918. /**
  115919. * Defines an optimization used to increase or decrease the rendering resolution
  115920. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115921. */
  115922. export class HardwareScalingOptimization extends SceneOptimization {
  115923. /**
  115924. * Defines the priority of this optimization (0 by default which means first in the list)
  115925. */
  115926. priority: number;
  115927. /**
  115928. * Defines the maximum scale to use (2 by default)
  115929. */
  115930. maximumScale: number;
  115931. /**
  115932. * Defines the step to use between two passes (0.5 by default)
  115933. */
  115934. step: number;
  115935. private _currentScale;
  115936. private _directionOffset;
  115937. /**
  115938. * Gets a string describing the action executed by the current optimization
  115939. * @return description string
  115940. */
  115941. getDescription(): string;
  115942. /**
  115943. * Creates the HardwareScalingOptimization object
  115944. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115945. * @param maximumScale defines the maximum scale to use (2 by default)
  115946. * @param step defines the step to use between two passes (0.5 by default)
  115947. */
  115948. constructor(
  115949. /**
  115950. * Defines the priority of this optimization (0 by default which means first in the list)
  115951. */
  115952. priority?: number,
  115953. /**
  115954. * Defines the maximum scale to use (2 by default)
  115955. */
  115956. maximumScale?: number,
  115957. /**
  115958. * Defines the step to use between two passes (0.5 by default)
  115959. */
  115960. step?: number);
  115961. /**
  115962. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115963. * @param scene defines the current scene where to apply this optimization
  115964. * @param optimizer defines the current optimizer
  115965. * @returns true if everything that can be done was applied
  115966. */
  115967. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115968. }
  115969. /**
  115970. * Defines an optimization used to remove shadows
  115971. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115972. */
  115973. export class ShadowsOptimization extends SceneOptimization {
  115974. /**
  115975. * Gets a string describing the action executed by the current optimization
  115976. * @return description string
  115977. */
  115978. getDescription(): string;
  115979. /**
  115980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115981. * @param scene defines the current scene where to apply this optimization
  115982. * @param optimizer defines the current optimizer
  115983. * @returns true if everything that can be done was applied
  115984. */
  115985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115986. }
  115987. /**
  115988. * Defines an optimization used to turn post-processes off
  115989. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115990. */
  115991. export class PostProcessesOptimization extends SceneOptimization {
  115992. /**
  115993. * Gets a string describing the action executed by the current optimization
  115994. * @return description string
  115995. */
  115996. getDescription(): string;
  115997. /**
  115998. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115999. * @param scene defines the current scene where to apply this optimization
  116000. * @param optimizer defines the current optimizer
  116001. * @returns true if everything that can be done was applied
  116002. */
  116003. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116004. }
  116005. /**
  116006. * Defines an optimization used to turn lens flares off
  116007. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116008. */
  116009. export class LensFlaresOptimization extends SceneOptimization {
  116010. /**
  116011. * Gets a string describing the action executed by the current optimization
  116012. * @return description string
  116013. */
  116014. getDescription(): string;
  116015. /**
  116016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116017. * @param scene defines the current scene where to apply this optimization
  116018. * @param optimizer defines the current optimizer
  116019. * @returns true if everything that can be done was applied
  116020. */
  116021. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116022. }
  116023. /**
  116024. * Defines an optimization based on user defined callback.
  116025. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116026. */
  116027. export class CustomOptimization extends SceneOptimization {
  116028. /**
  116029. * Callback called to apply the custom optimization.
  116030. */
  116031. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  116032. /**
  116033. * Callback called to get custom description
  116034. */
  116035. onGetDescription: () => string;
  116036. /**
  116037. * Gets a string describing the action executed by the current optimization
  116038. * @returns description string
  116039. */
  116040. getDescription(): string;
  116041. /**
  116042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116043. * @param scene defines the current scene where to apply this optimization
  116044. * @param optimizer defines the current optimizer
  116045. * @returns true if everything that can be done was applied
  116046. */
  116047. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116048. }
  116049. /**
  116050. * Defines an optimization used to turn particles off
  116051. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116052. */
  116053. export class ParticlesOptimization extends SceneOptimization {
  116054. /**
  116055. * Gets a string describing the action executed by the current optimization
  116056. * @return description string
  116057. */
  116058. getDescription(): string;
  116059. /**
  116060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116061. * @param scene defines the current scene where to apply this optimization
  116062. * @param optimizer defines the current optimizer
  116063. * @returns true if everything that can be done was applied
  116064. */
  116065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116066. }
  116067. /**
  116068. * Defines an optimization used to turn render targets off
  116069. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116070. */
  116071. export class RenderTargetsOptimization extends SceneOptimization {
  116072. /**
  116073. * Gets a string describing the action executed by the current optimization
  116074. * @return description string
  116075. */
  116076. getDescription(): string;
  116077. /**
  116078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116079. * @param scene defines the current scene where to apply this optimization
  116080. * @param optimizer defines the current optimizer
  116081. * @returns true if everything that can be done was applied
  116082. */
  116083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116084. }
  116085. /**
  116086. * Defines an optimization used to merge meshes with compatible materials
  116087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116088. */
  116089. export class MergeMeshesOptimization extends SceneOptimization {
  116090. private static _UpdateSelectionTree;
  116091. /**
  116092. * Gets or sets a boolean which defines if optimization octree has to be updated
  116093. */
  116094. /**
  116095. * Gets or sets a boolean which defines if optimization octree has to be updated
  116096. */
  116097. static UpdateSelectionTree: boolean;
  116098. /**
  116099. * Gets a string describing the action executed by the current optimization
  116100. * @return description string
  116101. */
  116102. getDescription(): string;
  116103. private _canBeMerged;
  116104. /**
  116105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116106. * @param scene defines the current scene where to apply this optimization
  116107. * @param optimizer defines the current optimizer
  116108. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  116109. * @returns true if everything that can be done was applied
  116110. */
  116111. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  116112. }
  116113. /**
  116114. * Defines a list of options used by SceneOptimizer
  116115. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116116. */
  116117. export class SceneOptimizerOptions {
  116118. /**
  116119. * Defines the target frame rate to reach (60 by default)
  116120. */
  116121. targetFrameRate: number;
  116122. /**
  116123. * Defines the interval between two checkes (2000ms by default)
  116124. */
  116125. trackerDuration: number;
  116126. /**
  116127. * Gets the list of optimizations to apply
  116128. */
  116129. optimizations: SceneOptimization[];
  116130. /**
  116131. * Creates a new list of options used by SceneOptimizer
  116132. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  116133. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  116134. */
  116135. constructor(
  116136. /**
  116137. * Defines the target frame rate to reach (60 by default)
  116138. */
  116139. targetFrameRate?: number,
  116140. /**
  116141. * Defines the interval between two checkes (2000ms by default)
  116142. */
  116143. trackerDuration?: number);
  116144. /**
  116145. * Add a new optimization
  116146. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  116147. * @returns the current SceneOptimizerOptions
  116148. */
  116149. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  116150. /**
  116151. * Add a new custom optimization
  116152. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  116153. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  116154. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116155. * @returns the current SceneOptimizerOptions
  116156. */
  116157. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  116158. /**
  116159. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  116160. * @param targetFrameRate defines the target frame rate (60 by default)
  116161. * @returns a SceneOptimizerOptions object
  116162. */
  116163. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116164. /**
  116165. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  116166. * @param targetFrameRate defines the target frame rate (60 by default)
  116167. * @returns a SceneOptimizerOptions object
  116168. */
  116169. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116170. /**
  116171. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  116172. * @param targetFrameRate defines the target frame rate (60 by default)
  116173. * @returns a SceneOptimizerOptions object
  116174. */
  116175. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116176. }
  116177. /**
  116178. * Class used to run optimizations in order to reach a target frame rate
  116179. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116180. */
  116181. export class SceneOptimizer implements IDisposable {
  116182. private _isRunning;
  116183. private _options;
  116184. private _scene;
  116185. private _currentPriorityLevel;
  116186. private _targetFrameRate;
  116187. private _trackerDuration;
  116188. private _currentFrameRate;
  116189. private _sceneDisposeObserver;
  116190. private _improvementMode;
  116191. /**
  116192. * Defines an observable called when the optimizer reaches the target frame rate
  116193. */
  116194. onSuccessObservable: Observable<SceneOptimizer>;
  116195. /**
  116196. * Defines an observable called when the optimizer enables an optimization
  116197. */
  116198. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  116199. /**
  116200. * Defines an observable called when the optimizer is not able to reach the target frame rate
  116201. */
  116202. onFailureObservable: Observable<SceneOptimizer>;
  116203. /**
  116204. * Gets a boolean indicating if the optimizer is in improvement mode
  116205. */
  116206. readonly isInImprovementMode: boolean;
  116207. /**
  116208. * Gets the current priority level (0 at start)
  116209. */
  116210. readonly currentPriorityLevel: number;
  116211. /**
  116212. * Gets the current frame rate checked by the SceneOptimizer
  116213. */
  116214. readonly currentFrameRate: number;
  116215. /**
  116216. * Gets or sets the current target frame rate (60 by default)
  116217. */
  116218. /**
  116219. * Gets or sets the current target frame rate (60 by default)
  116220. */
  116221. targetFrameRate: number;
  116222. /**
  116223. * Gets or sets the current interval between two checks (every 2000ms by default)
  116224. */
  116225. /**
  116226. * Gets or sets the current interval between two checks (every 2000ms by default)
  116227. */
  116228. trackerDuration: number;
  116229. /**
  116230. * Gets the list of active optimizations
  116231. */
  116232. readonly optimizations: SceneOptimization[];
  116233. /**
  116234. * Creates a new SceneOptimizer
  116235. * @param scene defines the scene to work on
  116236. * @param options defines the options to use with the SceneOptimizer
  116237. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  116238. * @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)
  116239. */
  116240. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  116241. /**
  116242. * Stops the current optimizer
  116243. */
  116244. stop(): void;
  116245. /**
  116246. * Reset the optimizer to initial step (current priority level = 0)
  116247. */
  116248. reset(): void;
  116249. /**
  116250. * Start the optimizer. By default it will try to reach a specific framerate
  116251. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  116252. */
  116253. start(): void;
  116254. private _checkCurrentState;
  116255. /**
  116256. * Release all resources
  116257. */
  116258. dispose(): void;
  116259. /**
  116260. * Helper function to create a SceneOptimizer with one single line of code
  116261. * @param scene defines the scene to work on
  116262. * @param options defines the options to use with the SceneOptimizer
  116263. * @param onSuccess defines a callback to call on success
  116264. * @param onFailure defines a callback to call on failure
  116265. * @returns the new SceneOptimizer object
  116266. */
  116267. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  116268. }
  116269. }
  116270. declare module BABYLON {
  116271. /**
  116272. * Class used to serialize a scene into a string
  116273. */
  116274. export class SceneSerializer {
  116275. /**
  116276. * Clear cache used by a previous serialization
  116277. */
  116278. static ClearCache(): void;
  116279. /**
  116280. * Serialize a scene into a JSON compatible object
  116281. * @param scene defines the scene to serialize
  116282. * @returns a JSON compatible object
  116283. */
  116284. static Serialize(scene: Scene): any;
  116285. /**
  116286. * Serialize a mesh into a JSON compatible object
  116287. * @param toSerialize defines the mesh to serialize
  116288. * @param withParents defines if parents must be serialized as well
  116289. * @param withChildren defines if children must be serialized as well
  116290. * @returns a JSON compatible object
  116291. */
  116292. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  116293. }
  116294. }
  116295. declare module BABYLON {
  116296. /**
  116297. * Class used to host texture specific utilities
  116298. */
  116299. export class TextureTools {
  116300. /**
  116301. * Uses the GPU to create a copy texture rescaled at a given size
  116302. * @param texture Texture to copy from
  116303. * @param width defines the desired width
  116304. * @param height defines the desired height
  116305. * @param useBilinearMode defines if bilinear mode has to be used
  116306. * @return the generated texture
  116307. */
  116308. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  116309. }
  116310. }
  116311. declare module BABYLON {
  116312. /**
  116313. * This represents the different options avilable for the video capture.
  116314. */
  116315. export interface VideoRecorderOptions {
  116316. /** Defines the mime type of the video */
  116317. mimeType: string;
  116318. /** Defines the video the video should be recorded at */
  116319. fps: number;
  116320. /** Defines the chunk size for the recording data */
  116321. recordChunckSize: number;
  116322. /** The audio tracks to attach to the record */
  116323. audioTracks?: MediaStreamTrack[];
  116324. }
  116325. /**
  116326. * This can helps recording videos from BabylonJS.
  116327. * This is based on the available WebRTC functionalities of the browser.
  116328. *
  116329. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  116330. */
  116331. export class VideoRecorder {
  116332. private static readonly _defaultOptions;
  116333. /**
  116334. * Returns wehther or not the VideoRecorder is available in your browser.
  116335. * @param engine Defines the Babylon Engine to check the support for
  116336. * @returns true if supported otherwise false
  116337. */
  116338. static IsSupported(engine: Engine): boolean;
  116339. private readonly _options;
  116340. private _canvas;
  116341. private _mediaRecorder;
  116342. private _recordedChunks;
  116343. private _fileName;
  116344. private _resolve;
  116345. private _reject;
  116346. /**
  116347. * True wether a recording is already in progress.
  116348. */
  116349. readonly isRecording: boolean;
  116350. /**
  116351. * Create a new VideoCapture object which can help converting what you see in Babylon to
  116352. * a video file.
  116353. * @param engine Defines the BabylonJS Engine you wish to record
  116354. * @param options Defines options that can be used to customized the capture
  116355. */
  116356. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  116357. /**
  116358. * Stops the current recording before the default capture timeout passed in the startRecording
  116359. * functions.
  116360. */
  116361. stopRecording(): void;
  116362. /**
  116363. * Starts recording the canvas for a max duration specified in parameters.
  116364. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  116365. * @param maxDuration Defines the maximum recording time in seconds.
  116366. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  116367. * @return a promise callback at the end of the recording with the video data in Blob.
  116368. */
  116369. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  116370. /**
  116371. * Releases internal resources used during the recording.
  116372. */
  116373. dispose(): void;
  116374. private _handleDataAvailable;
  116375. private _handleError;
  116376. private _handleStop;
  116377. }
  116378. }
  116379. declare module BABYLON {
  116380. /**
  116381. * Class containing a set of static utilities functions for screenshots
  116382. */
  116383. export class ScreenshotTools {
  116384. /**
  116385. * Captures a screenshot of the current rendering
  116386. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116387. * @param engine defines the rendering engine
  116388. * @param camera defines the source camera
  116389. * @param size This parameter can be set to a single number or to an object with the
  116390. * following (optional) properties: precision, width, height. If a single number is passed,
  116391. * it will be used for both width and height. If an object is passed, the screenshot size
  116392. * will be derived from the parameters. The precision property is a multiplier allowing
  116393. * rendering at a higher or lower resolution
  116394. * @param successCallback defines the callback receives a single parameter which contains the
  116395. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116396. * src parameter of an <img> to display it
  116397. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116398. * Check your browser for supported MIME types
  116399. */
  116400. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  116401. /**
  116402. * Generates an image screenshot from the specified camera.
  116403. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116404. * @param engine The engine to use for rendering
  116405. * @param camera The camera to use for rendering
  116406. * @param size This parameter can be set to a single number or to an object with the
  116407. * following (optional) properties: precision, width, height. If a single number is passed,
  116408. * it will be used for both width and height. If an object is passed, the screenshot size
  116409. * will be derived from the parameters. The precision property is a multiplier allowing
  116410. * rendering at a higher or lower resolution
  116411. * @param successCallback The callback receives a single parameter which contains the
  116412. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116413. * src parameter of an <img> to display it
  116414. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116415. * Check your browser for supported MIME types
  116416. * @param samples Texture samples (default: 1)
  116417. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116418. * @param fileName A name for for the downloaded file.
  116419. */
  116420. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116421. }
  116422. }
  116423. declare module BABYLON {
  116424. /**
  116425. * A cursor which tracks a point on a path
  116426. */
  116427. export class PathCursor {
  116428. private path;
  116429. /**
  116430. * Stores path cursor callbacks for when an onchange event is triggered
  116431. */
  116432. private _onchange;
  116433. /**
  116434. * The value of the path cursor
  116435. */
  116436. value: number;
  116437. /**
  116438. * The animation array of the path cursor
  116439. */
  116440. animations: Animation[];
  116441. /**
  116442. * Initializes the path cursor
  116443. * @param path The path to track
  116444. */
  116445. constructor(path: Path2);
  116446. /**
  116447. * Gets the cursor point on the path
  116448. * @returns A point on the path cursor at the cursor location
  116449. */
  116450. getPoint(): Vector3;
  116451. /**
  116452. * Moves the cursor ahead by the step amount
  116453. * @param step The amount to move the cursor forward
  116454. * @returns This path cursor
  116455. */
  116456. moveAhead(step?: number): PathCursor;
  116457. /**
  116458. * Moves the cursor behind by the step amount
  116459. * @param step The amount to move the cursor back
  116460. * @returns This path cursor
  116461. */
  116462. moveBack(step?: number): PathCursor;
  116463. /**
  116464. * Moves the cursor by the step amount
  116465. * If the step amount is greater than one, an exception is thrown
  116466. * @param step The amount to move the cursor
  116467. * @returns This path cursor
  116468. */
  116469. move(step: number): PathCursor;
  116470. /**
  116471. * Ensures that the value is limited between zero and one
  116472. * @returns This path cursor
  116473. */
  116474. private ensureLimits;
  116475. /**
  116476. * Runs onchange callbacks on change (used by the animation engine)
  116477. * @returns This path cursor
  116478. */
  116479. private raiseOnChange;
  116480. /**
  116481. * Executes a function on change
  116482. * @param f A path cursor onchange callback
  116483. * @returns This path cursor
  116484. */
  116485. onchange(f: (cursor: PathCursor) => void): PathCursor;
  116486. }
  116487. }
  116488. declare module BABYLON {
  116489. /** @hidden */
  116490. export var blurPixelShader: {
  116491. name: string;
  116492. shader: string;
  116493. };
  116494. }
  116495. declare module BABYLON {
  116496. /** @hidden */
  116497. export var bones300Declaration: {
  116498. name: string;
  116499. shader: string;
  116500. };
  116501. }
  116502. declare module BABYLON {
  116503. /** @hidden */
  116504. export var instances300Declaration: {
  116505. name: string;
  116506. shader: string;
  116507. };
  116508. }
  116509. declare module BABYLON {
  116510. /** @hidden */
  116511. export var pointCloudVertexDeclaration: {
  116512. name: string;
  116513. shader: string;
  116514. };
  116515. }
  116516. // Mixins
  116517. interface Window {
  116518. mozIndexedDB: IDBFactory;
  116519. webkitIndexedDB: IDBFactory;
  116520. msIndexedDB: IDBFactory;
  116521. webkitURL: typeof URL;
  116522. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  116523. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  116524. WebGLRenderingContext: WebGLRenderingContext;
  116525. MSGesture: MSGesture;
  116526. CANNON: any;
  116527. AudioContext: AudioContext;
  116528. webkitAudioContext: AudioContext;
  116529. PointerEvent: any;
  116530. Math: Math;
  116531. Uint8Array: Uint8ArrayConstructor;
  116532. Float32Array: Float32ArrayConstructor;
  116533. mozURL: typeof URL;
  116534. msURL: typeof URL;
  116535. VRFrameData: any; // WebVR, from specs 1.1
  116536. DracoDecoderModule: any;
  116537. setImmediate(handler: (...args: any[]) => void): number;
  116538. }
  116539. interface HTMLCanvasElement {
  116540. requestPointerLock(): void;
  116541. msRequestPointerLock?(): void;
  116542. mozRequestPointerLock?(): void;
  116543. webkitRequestPointerLock?(): void;
  116544. /** Track wether a record is in progress */
  116545. isRecording: boolean;
  116546. /** Capture Stream method defined by some browsers */
  116547. captureStream(fps?: number): MediaStream;
  116548. }
  116549. interface CanvasRenderingContext2D {
  116550. msImageSmoothingEnabled: boolean;
  116551. }
  116552. interface MouseEvent {
  116553. mozMovementX: number;
  116554. mozMovementY: number;
  116555. webkitMovementX: number;
  116556. webkitMovementY: number;
  116557. msMovementX: number;
  116558. msMovementY: number;
  116559. }
  116560. interface Navigator {
  116561. mozGetVRDevices: (any: any) => any;
  116562. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116563. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116564. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116565. webkitGetGamepads(): Gamepad[];
  116566. msGetGamepads(): Gamepad[];
  116567. webkitGamepads(): Gamepad[];
  116568. }
  116569. interface HTMLVideoElement {
  116570. mozSrcObject: any;
  116571. }
  116572. interface Math {
  116573. fround(x: number): number;
  116574. imul(a: number, b: number): number;
  116575. }
  116576. interface WebGLRenderingContext {
  116577. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116578. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116579. vertexAttribDivisor(index: number, divisor: number): void;
  116580. createVertexArray(): any;
  116581. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116582. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116583. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116584. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116585. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116586. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116587. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116588. // Queries
  116589. createQuery(): WebGLQuery;
  116590. deleteQuery(query: WebGLQuery): void;
  116591. beginQuery(target: number, query: WebGLQuery): void;
  116592. endQuery(target: number): void;
  116593. getQueryParameter(query: WebGLQuery, pname: number): any;
  116594. getQuery(target: number, pname: number): any;
  116595. MAX_SAMPLES: number;
  116596. RGBA8: number;
  116597. READ_FRAMEBUFFER: number;
  116598. DRAW_FRAMEBUFFER: number;
  116599. UNIFORM_BUFFER: number;
  116600. HALF_FLOAT_OES: number;
  116601. RGBA16F: number;
  116602. RGBA32F: number;
  116603. R32F: number;
  116604. RG32F: number;
  116605. RGB32F: number;
  116606. R16F: number;
  116607. RG16F: number;
  116608. RGB16F: number;
  116609. RED: number;
  116610. RG: number;
  116611. R8: number;
  116612. RG8: number;
  116613. UNSIGNED_INT_24_8: number;
  116614. DEPTH24_STENCIL8: number;
  116615. /* Multiple Render Targets */
  116616. drawBuffers(buffers: number[]): void;
  116617. readBuffer(src: number): void;
  116618. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116619. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116620. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116621. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116622. // Occlusion Query
  116623. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116624. ANY_SAMPLES_PASSED: number;
  116625. QUERY_RESULT_AVAILABLE: number;
  116626. QUERY_RESULT: number;
  116627. }
  116628. interface WebGLProgram {
  116629. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116630. }
  116631. interface EXT_disjoint_timer_query {
  116632. QUERY_COUNTER_BITS_EXT: number;
  116633. TIME_ELAPSED_EXT: number;
  116634. TIMESTAMP_EXT: number;
  116635. GPU_DISJOINT_EXT: number;
  116636. QUERY_RESULT_EXT: number;
  116637. QUERY_RESULT_AVAILABLE_EXT: number;
  116638. queryCounterEXT(query: WebGLQuery, target: number): void;
  116639. createQueryEXT(): WebGLQuery;
  116640. beginQueryEXT(target: number, query: WebGLQuery): void;
  116641. endQueryEXT(target: number): void;
  116642. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116643. deleteQueryEXT(query: WebGLQuery): void;
  116644. }
  116645. interface WebGLUniformLocation {
  116646. _currentState: any;
  116647. }
  116648. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116649. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116650. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116651. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116652. interface WebGLRenderingContext {
  116653. readonly RASTERIZER_DISCARD: number;
  116654. readonly DEPTH_COMPONENT24: number;
  116655. readonly TEXTURE_3D: number;
  116656. readonly TEXTURE_2D_ARRAY: number;
  116657. readonly TEXTURE_COMPARE_FUNC: number;
  116658. readonly TEXTURE_COMPARE_MODE: number;
  116659. readonly COMPARE_REF_TO_TEXTURE: number;
  116660. readonly TEXTURE_WRAP_R: number;
  116661. readonly HALF_FLOAT: number;
  116662. readonly RGB8: number;
  116663. readonly RED_INTEGER: number;
  116664. readonly RG_INTEGER: number;
  116665. readonly RGB_INTEGER: number;
  116666. readonly RGBA_INTEGER: number;
  116667. readonly R8_SNORM: number;
  116668. readonly RG8_SNORM: number;
  116669. readonly RGB8_SNORM: number;
  116670. readonly RGBA8_SNORM: number;
  116671. readonly R8I: number;
  116672. readonly RG8I: number;
  116673. readonly RGB8I: number;
  116674. readonly RGBA8I: number;
  116675. readonly R8UI: number;
  116676. readonly RG8UI: number;
  116677. readonly RGB8UI: number;
  116678. readonly RGBA8UI: number;
  116679. readonly R16I: number;
  116680. readonly RG16I: number;
  116681. readonly RGB16I: number;
  116682. readonly RGBA16I: number;
  116683. readonly R16UI: number;
  116684. readonly RG16UI: number;
  116685. readonly RGB16UI: number;
  116686. readonly RGBA16UI: number;
  116687. readonly R32I: number;
  116688. readonly RG32I: number;
  116689. readonly RGB32I: number;
  116690. readonly RGBA32I: number;
  116691. readonly R32UI: number;
  116692. readonly RG32UI: number;
  116693. readonly RGB32UI: number;
  116694. readonly RGBA32UI: number;
  116695. readonly RGB10_A2UI: number;
  116696. readonly R11F_G11F_B10F: number;
  116697. readonly RGB9_E5: number;
  116698. readonly RGB10_A2: number;
  116699. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116700. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116701. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116702. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116703. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116704. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116705. 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;
  116706. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116707. readonly TRANSFORM_FEEDBACK: number;
  116708. readonly INTERLEAVED_ATTRIBS: number;
  116709. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116710. createTransformFeedback(): WebGLTransformFeedback;
  116711. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116712. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116713. beginTransformFeedback(primitiveMode: number): void;
  116714. endTransformFeedback(): void;
  116715. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116716. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116717. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116718. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116719. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116720. }
  116721. interface ImageBitmap {
  116722. readonly width: number;
  116723. readonly height: number;
  116724. close(): void;
  116725. }
  116726. interface WebGLQuery extends WebGLObject {
  116727. }
  116728. declare var WebGLQuery: {
  116729. prototype: WebGLQuery;
  116730. new(): WebGLQuery;
  116731. };
  116732. interface WebGLSampler extends WebGLObject {
  116733. }
  116734. declare var WebGLSampler: {
  116735. prototype: WebGLSampler;
  116736. new(): WebGLSampler;
  116737. };
  116738. interface WebGLSync extends WebGLObject {
  116739. }
  116740. declare var WebGLSync: {
  116741. prototype: WebGLSync;
  116742. new(): WebGLSync;
  116743. };
  116744. interface WebGLTransformFeedback extends WebGLObject {
  116745. }
  116746. declare var WebGLTransformFeedback: {
  116747. prototype: WebGLTransformFeedback;
  116748. new(): WebGLTransformFeedback;
  116749. };
  116750. interface WebGLVertexArrayObject extends WebGLObject {
  116751. }
  116752. declare var WebGLVertexArrayObject: {
  116753. prototype: WebGLVertexArrayObject;
  116754. new(): WebGLVertexArrayObject;
  116755. };
  116756. // Type definitions for WebVR API
  116757. // Project: https://w3c.github.io/webvr/
  116758. // Definitions by: six a <https://github.com/lostfictions>
  116759. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116760. interface VRDisplay extends EventTarget {
  116761. /**
  116762. * Dictionary of capabilities describing the VRDisplay.
  116763. */
  116764. readonly capabilities: VRDisplayCapabilities;
  116765. /**
  116766. * z-depth defining the far plane of the eye view frustum
  116767. * enables mapping of values in the render target depth
  116768. * attachment to scene coordinates. Initially set to 10000.0.
  116769. */
  116770. depthFar: number;
  116771. /**
  116772. * z-depth defining the near plane of the eye view frustum
  116773. * enables mapping of values in the render target depth
  116774. * attachment to scene coordinates. Initially set to 0.01.
  116775. */
  116776. depthNear: number;
  116777. /**
  116778. * An identifier for this distinct VRDisplay. Used as an
  116779. * association point in the Gamepad API.
  116780. */
  116781. readonly displayId: number;
  116782. /**
  116783. * A display name, a user-readable name identifying it.
  116784. */
  116785. readonly displayName: string;
  116786. readonly isConnected: boolean;
  116787. readonly isPresenting: boolean;
  116788. /**
  116789. * If this VRDisplay supports room-scale experiences, the optional
  116790. * stage attribute contains details on the room-scale parameters.
  116791. */
  116792. readonly stageParameters: VRStageParameters | null;
  116793. /**
  116794. * Passing the value returned by `requestAnimationFrame` to
  116795. * `cancelAnimationFrame` will unregister the callback.
  116796. * @param handle Define the hanle of the request to cancel
  116797. */
  116798. cancelAnimationFrame(handle: number): void;
  116799. /**
  116800. * Stops presenting to the VRDisplay.
  116801. * @returns a promise to know when it stopped
  116802. */
  116803. exitPresent(): Promise<void>;
  116804. /**
  116805. * Return the current VREyeParameters for the given eye.
  116806. * @param whichEye Define the eye we want the parameter for
  116807. * @returns the eye parameters
  116808. */
  116809. getEyeParameters(whichEye: string): VREyeParameters;
  116810. /**
  116811. * Populates the passed VRFrameData with the information required to render
  116812. * the current frame.
  116813. * @param frameData Define the data structure to populate
  116814. * @returns true if ok otherwise false
  116815. */
  116816. getFrameData(frameData: VRFrameData): boolean;
  116817. /**
  116818. * Get the layers currently being presented.
  116819. * @returns the list of VR layers
  116820. */
  116821. getLayers(): VRLayer[];
  116822. /**
  116823. * Return a VRPose containing the future predicted pose of the VRDisplay
  116824. * when the current frame will be presented. The value returned will not
  116825. * change until JavaScript has returned control to the browser.
  116826. *
  116827. * The VRPose will contain the position, orientation, velocity,
  116828. * and acceleration of each of these properties.
  116829. * @returns the pose object
  116830. */
  116831. getPose(): VRPose;
  116832. /**
  116833. * Return the current instantaneous pose of the VRDisplay, with no
  116834. * prediction applied.
  116835. * @returns the current instantaneous pose
  116836. */
  116837. getImmediatePose(): VRPose;
  116838. /**
  116839. * The callback passed to `requestAnimationFrame` will be called
  116840. * any time a new frame should be rendered. When the VRDisplay is
  116841. * presenting the callback will be called at the native refresh
  116842. * rate of the HMD. When not presenting this function acts
  116843. * identically to how window.requestAnimationFrame acts. Content should
  116844. * make no assumptions of frame rate or vsync behavior as the HMD runs
  116845. * asynchronously from other displays and at differing refresh rates.
  116846. * @param callback Define the eaction to run next frame
  116847. * @returns the request handle it
  116848. */
  116849. requestAnimationFrame(callback: FrameRequestCallback): number;
  116850. /**
  116851. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  116852. * Repeat calls while already presenting will update the VRLayers being displayed.
  116853. * @param layers Define the list of layer to present
  116854. * @returns a promise to know when the request has been fulfilled
  116855. */
  116856. requestPresent(layers: VRLayer[]): Promise<void>;
  116857. /**
  116858. * Reset the pose for this display, treating its current position and
  116859. * orientation as the "origin/zero" values. VRPose.position,
  116860. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  116861. * updated when calling resetPose(). This should be called in only
  116862. * sitting-space experiences.
  116863. */
  116864. resetPose(): void;
  116865. /**
  116866. * The VRLayer provided to the VRDisplay will be captured and presented
  116867. * in the HMD. Calling this function has the same effect on the source
  116868. * canvas as any other operation that uses its source image, and canvases
  116869. * created without preserveDrawingBuffer set to true will be cleared.
  116870. * @param pose Define the pose to submit
  116871. */
  116872. submitFrame(pose?: VRPose): void;
  116873. }
  116874. declare var VRDisplay: {
  116875. prototype: VRDisplay;
  116876. new(): VRDisplay;
  116877. };
  116878. interface VRLayer {
  116879. leftBounds?: number[] | Float32Array | null;
  116880. rightBounds?: number[] | Float32Array | null;
  116881. source?: HTMLCanvasElement | null;
  116882. }
  116883. interface VRDisplayCapabilities {
  116884. readonly canPresent: boolean;
  116885. readonly hasExternalDisplay: boolean;
  116886. readonly hasOrientation: boolean;
  116887. readonly hasPosition: boolean;
  116888. readonly maxLayers: number;
  116889. }
  116890. interface VREyeParameters {
  116891. /** @deprecated */
  116892. readonly fieldOfView: VRFieldOfView;
  116893. readonly offset: Float32Array;
  116894. readonly renderHeight: number;
  116895. readonly renderWidth: number;
  116896. }
  116897. interface VRFieldOfView {
  116898. readonly downDegrees: number;
  116899. readonly leftDegrees: number;
  116900. readonly rightDegrees: number;
  116901. readonly upDegrees: number;
  116902. }
  116903. interface VRFrameData {
  116904. readonly leftProjectionMatrix: Float32Array;
  116905. readonly leftViewMatrix: Float32Array;
  116906. readonly pose: VRPose;
  116907. readonly rightProjectionMatrix: Float32Array;
  116908. readonly rightViewMatrix: Float32Array;
  116909. readonly timestamp: number;
  116910. }
  116911. interface VRPose {
  116912. readonly angularAcceleration: Float32Array | null;
  116913. readonly angularVelocity: Float32Array | null;
  116914. readonly linearAcceleration: Float32Array | null;
  116915. readonly linearVelocity: Float32Array | null;
  116916. readonly orientation: Float32Array | null;
  116917. readonly position: Float32Array | null;
  116918. readonly timestamp: number;
  116919. }
  116920. interface VRStageParameters {
  116921. sittingToStandingTransform?: Float32Array;
  116922. sizeX?: number;
  116923. sizeY?: number;
  116924. }
  116925. interface Navigator {
  116926. getVRDisplays(): Promise<VRDisplay[]>;
  116927. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116928. }
  116929. interface Window {
  116930. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116931. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116932. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116933. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116934. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116935. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116936. }
  116937. interface Gamepad {
  116938. readonly displayId: number;
  116939. }
  116940. interface XRDevice {
  116941. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116942. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116943. }
  116944. interface XRSession {
  116945. getInputSources(): Array<any>;
  116946. baseLayer: XRWebGLLayer;
  116947. requestFrameOfReference(type: string): Promise<void>;
  116948. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116949. end(): Promise<void>;
  116950. requestAnimationFrame: Function;
  116951. addEventListener: Function;
  116952. }
  116953. interface XRSessionCreationOptions {
  116954. outputContext?: WebGLRenderingContext | null;
  116955. immersive?: boolean;
  116956. environmentIntegration?: boolean;
  116957. }
  116958. interface XRLayer {
  116959. getViewport: Function;
  116960. framebufferWidth: number;
  116961. framebufferHeight: number;
  116962. }
  116963. interface XRView {
  116964. projectionMatrix: Float32Array;
  116965. }
  116966. interface XRFrame {
  116967. getDevicePose: Function;
  116968. getInputPose: Function;
  116969. views: Array<XRView>;
  116970. baseLayer: XRLayer;
  116971. }
  116972. interface XRFrameOfReference {
  116973. }
  116974. interface XRWebGLLayer extends XRLayer {
  116975. framebuffer: WebGLFramebuffer;
  116976. }
  116977. declare var XRWebGLLayer: {
  116978. prototype: XRWebGLLayer;
  116979. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  116980. };